commit 1e0f640a2068d2db5bae2c36a9477fb2042282e1 Author: Nathan Freitas nathan@freitas.net Date: Mon Nov 24 23:12:53 2014 -0500
adding dummyactivity to stop task/broadcast from killing foreground service --- AndroidManifest.xml | 24 ++++++++++++++++---- .../torproject/android/service/DummyActivity.java | 15 ++++++++++++ src/org/torproject/android/service/TorService.java | 6 ++++- 3 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index de175f9..223475f 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,11 +2,11 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.torproject.android" android:versionName="14.1.3-PIE" - android:versionCode="130" + android:versionCode="131" android:installLocation="auto" > - <uses-sdk android:minSdkVersion="21" android:maxSdkVersion="21" android:targetSdkVersion="21"/> + <uses-sdk android:minSdkVersion="9" android:maxSdkVersion="20" android:targetSdkVersion="19"/> <permission android:name="org.torproject.android.MANAGE_TOR" android:label="@string/permission_manage_tor_label" android:description="@string/permission_manage_tor_description" android:protectionLevel="signature"></permission>
<uses-permission android:name="android.permission.INTERNET" /> @@ -24,10 +24,13 @@ android:allowClearUserData="true" android:persistent="true" android:stopWithTask="false" + >
- <activity android:name=".Orbot" android:configChanges="orientation|screenSize" + <activity android:name=".Orbot" + android:configChanges="orientation|screenSize" android:launchMode="singleTop" + android:excludeFromRecents="true" > <intent-filter> <action android:name="android.intent.action.MAIN" /> @@ -73,7 +76,20 @@ <!-- <activity android:name=".OrbotDiagnosticsActivity" android:label="OrbotDiag"/> --> - + <activity + android:name=".service.DummyActivity" + android:theme="@android:style/Theme.NoDisplay" + android:enabled="true" + android:allowTaskReparenting="true" + android:noHistory="true" + android:excludeFromRecents="true" + android:alwaysRetainTaskState="false" + android:stateNotNeeded="true" + android:clearTaskOnLaunch="true" + android:finishOnTaskLaunch="true" + /> + + <activity android:name=".wizard.LotsaText" android:exported="false"/> <activity android:name=".wizard.Permissions" android:exported="false"/> <activity android:name=".wizard.TipsAndTricks" android:exported="false"/> diff --git a/src/org/torproject/android/service/DummyActivity.java b/src/org/torproject/android/service/DummyActivity.java new file mode 100644 index 0000000..5400ba4 --- /dev/null +++ b/src/org/torproject/android/service/DummyActivity.java @@ -0,0 +1,15 @@ +package org.torproject.android.service; + +import android.app.Activity; +import android.os.Bundle; + +/* + * To combat background service being stopped/swiped + */ +public class DummyActivity extends Activity { + @Override + public void onCreate( Bundle icicle ) { + super.onCreate( icicle ); + finish(); + } +} \ No newline at end of file diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java index 6323d83..71b2ed7 100644 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@ -412,7 +412,11 @@ public class TorService extends Service implements TorServiceConstants, TorConst @Override public void onTaskRemoved(Intent rootIntent) { - logNotice("Orbot was swiped away... background service will keep running"); + //logNotice("Orbot was swiped away... background service will keep running"); + + Intent intent = new Intent( this, DummyActivity.class ); + intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); + startActivity( intent ); }
@Override
tor-commits@lists.torproject.org