mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-02 14:52:51 -08:00
Change timeout handling so service does not persist as long.
This commit is contained in:
1 parent
fa97eb8eb2
commit
e21b55fec5
3 files changed
+20
-7
No files matched your search
@@ -24,7 +24,6 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.keepassdroid.fileselect.FileSelectActivity;
|
||||
import com.keepassdroid.services.TimeoutService;
|
||||
|
||||
public class KeePass extends Activity {
|
||||
|
||||
@@ -37,7 +36,6 @@ public class KeePass extends Activity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
startService(new Intent(this, TimeoutService.class));
|
||||
|
||||
}
|
||||
|
||||
@@ -56,8 +54,6 @@ public class KeePass extends Activity {
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
stopService(new Intent(this, TimeoutService.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,18 +57,29 @@ public class TimeoutService extends Service {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(Intent intent, int startId) {
|
||||
super.onStart(intent, startId);
|
||||
|
||||
Log.d(TAG, "Timeout service started");
|
||||
}
|
||||
|
||||
private void timeout(Context context) {
|
||||
Log.d(TAG, "Timeout");
|
||||
App.setShutdown();
|
||||
|
||||
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
nm.cancelAll();
|
||||
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
|
||||
Log.d(TAG, "Timeout service stopped");
|
||||
|
||||
unregisterReceiver(mIntentReceiver);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,11 @@ import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.keepassdroid.intents.Intents;
|
||||
import com.keepassdroid.services.TimeoutService;
|
||||
|
||||
public class Timeout {
|
||||
private static final int REQUEST_ID = 0;
|
||||
private static final long DEFAULT_TIMEOUT = 5 * 60 * 1000; // 5 minutes
|
||||
private static final long DEFAULT_TIMEOUT = 20 * 1000; // 5 minutes
|
||||
private static String TAG = "KeePass Timeout";
|
||||
|
||||
private static PendingIntent buildIntent(Context ctx) {
|
||||
@@ -21,8 +22,10 @@ public class Timeout {
|
||||
}
|
||||
|
||||
public static void start(Context ctx) {
|
||||
|
||||
ctx.startService(new Intent(ctx, TimeoutService.class));
|
||||
|
||||
long triggerTime = System.currentTimeMillis() + DEFAULT_TIMEOUT;
|
||||
|
||||
AlarmManager am = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
|
||||
|
||||
Log.d(TAG, "Timeout start");
|
||||
@@ -34,6 +37,9 @@ public class Timeout {
|
||||
|
||||
Log.d(TAG, "Timeout cancel");
|
||||
am.cancel(buildIntent(ctx));
|
||||
|
||||
ctx.stopService(new Intent(ctx, TimeoutService.class));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user