adding dummyactivity to stop task/broadcast from killing foreground service

This commit is contained in:
Nathan Freitas 2014-11-24 23:12:53 -05:00
parent 88873193c2
commit 1e0f640a20
3 changed files with 40 additions and 5 deletions

View File

@ -2,11 +2,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.torproject.android" package="org.torproject.android"
android:versionName="14.1.3-PIE" android:versionName="14.1.3-PIE"
android:versionCode="130" android:versionCode="131"
android:installLocation="auto" 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> <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" /> <uses-permission android:name="android.permission.INTERNET" />
@ -24,10 +24,13 @@
android:allowClearUserData="true" android:allowClearUserData="true"
android:persistent="true" android:persistent="true"
android:stopWithTask="false" android:stopWithTask="false"
> >
<activity android:name=".Orbot" android:configChanges="orientation|screenSize" <activity android:name=".Orbot"
android:configChanges="orientation|screenSize"
android:launchMode="singleTop" android:launchMode="singleTop"
android:excludeFromRecents="true"
> >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -73,6 +76,19 @@
<!-- <!--
<activity android:name=".OrbotDiagnosticsActivity" android:label="OrbotDiag"/> <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.LotsaText" android:exported="false"/>
<activity android:name=".wizard.Permissions" android:exported="false"/> <activity android:name=".wizard.Permissions" android:exported="false"/>

View File

@ -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();
}
}

View File

@ -412,7 +412,11 @@ public class TorService extends Service implements TorServiceConstants, TorConst
@Override @Override
public void onTaskRemoved(Intent rootIntent) { 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 @Override