mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-20 14:54:09 +00:00
Refactor MasterSecret initialization, access, and timeout paths.
1) Consolidate all of the KeyCachingService interaction into a single mixin. Activities extend delegates which call through to the mixin. 2) Switch Activity increment/decrement triggers from onStop to onPause in order to account for some screen locks that don't stop activities.
This commit is contained in:
@@ -20,6 +20,7 @@ import android.app.AlarmManager;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Binder;
|
||||
@@ -44,8 +45,7 @@ import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
|
||||
public class KeyCachingService extends Service {
|
||||
|
||||
public static final int NOTIFICATION_ID = 1337;
|
||||
public static final int SERVICE_RUNNING_ID = 4141;
|
||||
public static final int SERVICE_RUNNING_ID = 4141;
|
||||
|
||||
public static final String KEY_PERMISSION = "org.thoughtcrime.securesms.ACCESS_SECRETS";
|
||||
public static final String NEW_KEY_EVENT = "org.thoughtcrime.securesms.service.action.NEW_KEY_EVENT";
|
||||
@@ -215,4 +215,16 @@ public class KeyCachingService extends Service {
|
||||
return KeyCachingService.this;
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerPassphraseActivityStarted(Context activity) {
|
||||
Intent intent = new Intent(activity, KeyCachingService.class);
|
||||
intent.setAction(KeyCachingService.ACTIVITY_START_EVENT);
|
||||
activity.startService(intent);
|
||||
}
|
||||
|
||||
public static void registerPassphraseActivityStopped(Context activity) {
|
||||
Intent intent = new Intent(activity, KeyCachingService.class);
|
||||
intent.setAction(KeyCachingService.ACTIVITY_STOP_EVENT);
|
||||
activity.startService(intent);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user