mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Hold a wake lock while signing out.
This commit is contained in:
@@ -24,4 +24,12 @@ public interface AndroidWakeLockManager {
|
|||||||
* thrown while submitting or running the task.
|
* thrown while submitting or running the task.
|
||||||
*/
|
*/
|
||||||
void executeWakefully(Runnable r, Executor executor, String tag);
|
void executeWakefully(Runnable r, Executor executor, String tag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a dedicated thread to run the given task asynchronously. A wake
|
||||||
|
* lock is acquired before starting the thread and released when the task
|
||||||
|
* completes, or if an exception is thrown while starting the thread or
|
||||||
|
* running the task.
|
||||||
|
*/
|
||||||
|
void executeWakefully(Runnable r, String tag);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,24 @@ class AndroidWakeLockManagerImpl implements AndroidWakeLockManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeWakefully(Runnable r, String tag) {
|
||||||
|
AndroidWakeLock wakeLock = createWakeLock(tag);
|
||||||
|
wakeLock.acquire();
|
||||||
|
try {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
r.run();
|
||||||
|
} finally {
|
||||||
|
wakeLock.release();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
wakeLock.release();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getWakeLockTag(Context ctx) {
|
private String getWakeLockTag(Context ctx) {
|
||||||
PackageManager pm = ctx.getPackageManager();
|
PackageManager pm = ctx.getPackageManager();
|
||||||
for (PackageInfo info : pm.getInstalledPackages(0)) {
|
for (PackageInfo info : pm.getInstalledPackages(0)) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
|||||||
import org.briarproject.bramble.api.plugin.PluginManager;
|
import org.briarproject.bramble.api.plugin.PluginManager;
|
||||||
import org.briarproject.bramble.api.settings.SettingsManager;
|
import org.briarproject.bramble.api.settings.SettingsManager;
|
||||||
import org.briarproject.bramble.api.system.AndroidExecutor;
|
import org.briarproject.bramble.api.system.AndroidExecutor;
|
||||||
|
import org.briarproject.bramble.api.system.AndroidWakeLockManager;
|
||||||
import org.briarproject.bramble.api.system.Clock;
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.api.system.LocationUtils;
|
import org.briarproject.bramble.api.system.LocationUtils;
|
||||||
import org.briarproject.bramble.plugin.tor.CircumventionProvider;
|
import org.briarproject.bramble.plugin.tor.CircumventionProvider;
|
||||||
@@ -166,6 +167,8 @@ public interface AndroidComponent
|
|||||||
|
|
||||||
FeatureFlags featureFlags();
|
FeatureFlags featureFlags();
|
||||||
|
|
||||||
|
AndroidWakeLockManager wakeLockManager();
|
||||||
|
|
||||||
void inject(SignInReminderReceiver briarService);
|
void inject(SignInReminderReceiver briarService);
|
||||||
|
|
||||||
void inject(BriarService briarService);
|
void inject(BriarService briarService);
|
||||||
|
|||||||
@@ -20,14 +20,12 @@ import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
|||||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager.StartResult;
|
import org.briarproject.bramble.api.lifecycle.LifecycleManager.StartResult;
|
||||||
import org.briarproject.bramble.api.system.AndroidExecutor;
|
import org.briarproject.bramble.api.system.AndroidExecutor;
|
||||||
import org.briarproject.bramble.api.system.AndroidWakeLockManager;
|
import org.briarproject.bramble.api.system.AndroidWakeLockManager;
|
||||||
import org.briarproject.bramble.api.system.WakefulIoExecutor;
|
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.logout.HideUiActivity;
|
import org.briarproject.briar.android.logout.HideUiActivity;
|
||||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||||
import org.briarproject.briar.api.android.LockManager;
|
import org.briarproject.briar.api.android.LockManager;
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -86,9 +84,6 @@ public class BriarService extends Service {
|
|||||||
LockManager lockManager;
|
LockManager lockManager;
|
||||||
@Inject
|
@Inject
|
||||||
AndroidWakeLockManager wakeLockManager;
|
AndroidWakeLockManager wakeLockManager;
|
||||||
@Inject
|
|
||||||
@WakefulIoExecutor
|
|
||||||
Executor wakefulIoExecutor;
|
|
||||||
|
|
||||||
// Fields that are accessed from background threads must be volatile
|
// Fields that are accessed from background threads must be volatile
|
||||||
@Inject
|
@Inject
|
||||||
@@ -140,7 +135,7 @@ public class BriarService extends Service {
|
|||||||
notificationManager.getForegroundNotification();
|
notificationManager.getForegroundNotification();
|
||||||
startForeground(ONGOING_NOTIFICATION_ID, foregroundNotification);
|
startForeground(ONGOING_NOTIFICATION_ID, foregroundNotification);
|
||||||
// Start the services in a background thread
|
// Start the services in a background thread
|
||||||
wakefulIoExecutor.execute(() -> {
|
wakeLockManager.executeWakefully(() -> {
|
||||||
StartResult result = lifecycleManager.startServices(dbKey);
|
StartResult result = lifecycleManager.startServices(dbKey);
|
||||||
if (result == SUCCESS) {
|
if (result == SUCCESS) {
|
||||||
started = true;
|
started = true;
|
||||||
@@ -153,7 +148,7 @@ public class BriarService extends Service {
|
|||||||
showStartupFailureNotification(result);
|
showStartupFailureNotification(result);
|
||||||
stopSelf();
|
stopSelf();
|
||||||
}
|
}
|
||||||
});
|
}, "LifecycleStartup");
|
||||||
// Register for device shutdown broadcasts
|
// Register for device shutdown broadcasts
|
||||||
receiver = new BroadcastReceiver() {
|
receiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@@ -224,9 +219,9 @@ public class BriarService extends Service {
|
|||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
if (receiver != null) unregisterReceiver(receiver);
|
if (receiver != null) unregisterReceiver(receiver);
|
||||||
// Stop the services in a background thread
|
// Stop the services in a background thread
|
||||||
wakefulIoExecutor.execute(() -> {
|
wakeLockManager.executeWakefully(() -> {
|
||||||
if (started) lifecycleManager.stopServices();
|
if (started) lifecycleManager.stopServices();
|
||||||
});
|
}, "LifecycleShutdown");
|
||||||
}, "LifecycleShutdown");
|
}, "LifecycleShutdown");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +274,7 @@ public class BriarService extends Service {
|
|||||||
// Hide the UI
|
// Hide the UI
|
||||||
hideUi();
|
hideUi();
|
||||||
// Wait for shutdown to complete, then exit
|
// Wait for shutdown to complete, then exit
|
||||||
wakefulIoExecutor.execute(() -> {
|
wakeLockManager.executeWakefully(() -> {
|
||||||
try {
|
try {
|
||||||
if (started) lifecycleManager.waitForShutdown();
|
if (started) lifecycleManager.waitForShutdown();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -287,7 +282,7 @@ public class BriarService extends Service {
|
|||||||
}
|
}
|
||||||
LOG.info("Exiting");
|
LOG.info("Exiting");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
});
|
}, "BackgroundShutdown");
|
||||||
}, "BackgroundShutdown");
|
}, "BackgroundShutdown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,13 +82,19 @@ import org.briarproject.briar.android.test.TestDataActivity;
|
|||||||
import dagger.Component;
|
import dagger.Component;
|
||||||
|
|
||||||
@ActivityScope
|
@ActivityScope
|
||||||
@Component(
|
@Component(modules = {
|
||||||
modules = {ActivityModule.class, ForumModule.class, SharingModule.class,
|
ActivityModule.class,
|
||||||
BlogModule.class, ContactModule.class, GroupListModule.class,
|
BlogModule.class,
|
||||||
CreateGroupModule.class, GroupInvitationModule.class,
|
ContactModule.class,
|
||||||
GroupConversationModule.class, GroupMemberModule.class,
|
CreateGroupModule.class,
|
||||||
GroupRevealModule.class},
|
ForumModule.class,
|
||||||
dependencies = AndroidComponent.class)
|
GroupInvitationModule.class,
|
||||||
|
GroupConversationModule.class,
|
||||||
|
GroupListModule.class,
|
||||||
|
GroupMemberModule.class,
|
||||||
|
GroupRevealModule.class,
|
||||||
|
SharingModule.class
|
||||||
|
}, dependencies = AndroidComponent.class)
|
||||||
public interface ActivityComponent {
|
public interface ActivityComponent {
|
||||||
|
|
||||||
Activity activity();
|
Activity activity();
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import android.widget.CheckBox;
|
|||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
|
import org.briarproject.bramble.api.system.AndroidWakeLockManager;
|
||||||
|
import org.briarproject.bramble.api.system.Wakeful;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.account.UnlockActivity;
|
import org.briarproject.briar.android.account.UnlockActivity;
|
||||||
import org.briarproject.briar.android.controller.BriarController;
|
import org.briarproject.briar.android.controller.BriarController;
|
||||||
@@ -32,6 +34,7 @@ import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
|||||||
import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION;
|
import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION;
|
||||||
import static android.os.Build.VERSION.SDK_INT;
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_DOZE_WHITELISTING;
|
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_DOZE_WHITELISTING;
|
||||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_PASSWORD;
|
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_PASSWORD;
|
||||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_UNLOCK;
|
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_UNLOCK;
|
||||||
@@ -47,7 +50,7 @@ public abstract class BriarActivity extends BaseActivity {
|
|||||||
public static final String GROUP_NAME = "briar.GROUP_NAME";
|
public static final String GROUP_NAME = "briar.GROUP_NAME";
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(BriarActivity.class.getName());
|
getLogger(BriarActivity.class.getName());
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BriarController briarController;
|
BriarController briarController;
|
||||||
@@ -56,6 +59,8 @@ public abstract class BriarActivity extends BaseActivity {
|
|||||||
DbController dbController;
|
DbController dbController;
|
||||||
@Inject
|
@Inject
|
||||||
protected LockManager lockManager;
|
protected LockManager lockManager;
|
||||||
|
@Inject
|
||||||
|
AndroidWakeLockManager wakeLockManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
@@ -130,6 +135,7 @@ public abstract class BriarActivity extends BaseActivity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the transition animations.
|
* Sets the transition animations.
|
||||||
|
*
|
||||||
* @param enterTransition used to move views into initial positions
|
* @param enterTransition used to move views into initial positions
|
||||||
* @param exitTransition used to move views out when starting a <b>new</b> activity.
|
* @param exitTransition used to move views out when starting a <b>new</b> activity.
|
||||||
* @param returnTransition used when window is closing, because the activity is finishing.
|
* @param returnTransition used when window is closing, because the activity is finishing.
|
||||||
@@ -197,22 +203,29 @@ public abstract class BriarActivity extends BaseActivity {
|
|||||||
|
|
||||||
protected void signOut(boolean removeFromRecentApps,
|
protected void signOut(boolean removeFromRecentApps,
|
||||||
boolean deleteAccount) {
|
boolean deleteAccount) {
|
||||||
if (briarController.accountSignedIn()) {
|
// Hold a wake lock to ensure we exit before the device goes to sleep
|
||||||
// Don't use UiResultHandler because we want the result even if
|
wakeLockManager.runWakefully(() -> {
|
||||||
// this activity has been destroyed
|
if (briarController.accountSignedIn()) {
|
||||||
briarController.signOut(result -> runOnUiThread(
|
// Don't use UiResultHandler because we want the result even if
|
||||||
() -> exit(removeFromRecentApps)), deleteAccount);
|
// this activity has been destroyed
|
||||||
} else {
|
briarController.signOut(result ->
|
||||||
if (deleteAccount) briarController.deleteAccount();
|
wakeLockManager.executeWakefully(() ->
|
||||||
exit(removeFromRecentApps);
|
exit(removeFromRecentApps),
|
||||||
}
|
this::runOnUiThread, "SignOut"), deleteAccount);
|
||||||
|
} else {
|
||||||
|
if (deleteAccount) briarController.deleteAccount();
|
||||||
|
exit(removeFromRecentApps);
|
||||||
|
}
|
||||||
|
}, "SignOut");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Wakeful
|
||||||
private void exit(boolean removeFromRecentApps) {
|
private void exit(boolean removeFromRecentApps) {
|
||||||
if (removeFromRecentApps) startExitActivity();
|
if (removeFromRecentApps) startExitActivity();
|
||||||
else finishAndExit();
|
else finishAndExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Wakeful
|
||||||
private void startExitActivity() {
|
private void startExitActivity() {
|
||||||
Intent i = new Intent(this, ExitActivity.class);
|
Intent i = new Intent(this, ExitActivity.class);
|
||||||
i.addFlags(FLAG_ACTIVITY_NEW_TASK
|
i.addFlags(FLAG_ACTIVITY_NEW_TASK
|
||||||
@@ -222,6 +235,7 @@ public abstract class BriarActivity extends BaseActivity {
|
|||||||
startActivity(i);
|
startActivity(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Wakeful
|
||||||
private void finishAndExit() {
|
private void finishAndExit() {
|
||||||
if (SDK_INT >= 21) finishAndRemoveTask();
|
if (SDK_INT >= 21) finishAndRemoveTask();
|
||||||
else supportFinishAfterTransition();
|
else supportFinishAfterTransition();
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package org.briarproject.briar.android.controller;
|
package org.briarproject.briar.android.controller;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
import org.briarproject.bramble.api.system.Wakeful;
|
||||||
import org.briarproject.briar.android.controller.handler.ResultHandler;
|
import org.briarproject.briar.android.controller.handler.ResultHandler;
|
||||||
|
|
||||||
|
@NotNullByDefault
|
||||||
public interface BriarController extends ActivityLifecycleController {
|
public interface BriarController extends ActivityLifecycleController {
|
||||||
|
|
||||||
void startAndBindService();
|
void startAndBindService();
|
||||||
@@ -16,7 +19,8 @@ public interface BriarController extends ActivityLifecycleController {
|
|||||||
|
|
||||||
void doNotAskAgainForDozeWhiteListing();
|
void doNotAskAgainForDozeWhiteListing();
|
||||||
|
|
||||||
void signOut(ResultHandler<Void> eventHandler, boolean deleteAccount);
|
@Wakeful
|
||||||
|
void signOut(ResultHandler<Void> handler, boolean deleteAccount);
|
||||||
|
|
||||||
void deleteAccount();
|
void deleteAccount();
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ import org.briarproject.bramble.api.account.AccountManager;
|
|||||||
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.settings.Settings;
|
import org.briarproject.bramble.api.settings.Settings;
|
||||||
import org.briarproject.bramble.api.settings.SettingsManager;
|
import org.briarproject.bramble.api.settings.SettingsManager;
|
||||||
|
import org.briarproject.bramble.api.system.AndroidWakeLockManager;
|
||||||
import org.briarproject.briar.android.BriarService;
|
import org.briarproject.briar.android.BriarService;
|
||||||
import org.briarproject.briar.android.BriarService.BriarServiceConnection;
|
import org.briarproject.briar.android.BriarService.BriarServiceConnection;
|
||||||
import org.briarproject.briar.android.controller.handler.ResultHandler;
|
import org.briarproject.briar.android.controller.handler.ResultHandler;
|
||||||
@@ -23,15 +25,17 @@ import javax.inject.Inject;
|
|||||||
import androidx.annotation.CallSuper;
|
import androidx.annotation.CallSuper;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.api.lifecycle.LifecycleManager.LifecycleState.STARTING_SERVICES;
|
import static org.briarproject.bramble.api.lifecycle.LifecycleManager.LifecycleState.STARTING_SERVICES;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
import static org.briarproject.briar.android.settings.SettingsFragment.SETTINGS_NAMESPACE;
|
import static org.briarproject.briar.android.settings.SettingsFragment.SETTINGS_NAMESPACE;
|
||||||
import static org.briarproject.briar.android.util.UiUtils.needsDozeWhitelisting;
|
import static org.briarproject.briar.android.util.UiUtils.needsDozeWhitelisting;
|
||||||
|
|
||||||
|
@NotNullByDefault
|
||||||
public class BriarControllerImpl implements BriarController {
|
public class BriarControllerImpl implements BriarController {
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(BriarControllerImpl.class.getName());
|
getLogger(BriarControllerImpl.class.getName());
|
||||||
|
|
||||||
public static final String DOZE_ASK_AGAIN = "dozeAskAgain";
|
public static final String DOZE_ASK_AGAIN = "dozeAskAgain";
|
||||||
|
|
||||||
@@ -41,6 +45,7 @@ public class BriarControllerImpl implements BriarController {
|
|||||||
private final Executor databaseExecutor;
|
private final Executor databaseExecutor;
|
||||||
private final SettingsManager settingsManager;
|
private final SettingsManager settingsManager;
|
||||||
private final DozeWatchdog dozeWatchdog;
|
private final DozeWatchdog dozeWatchdog;
|
||||||
|
private final AndroidWakeLockManager wakeLockManager;
|
||||||
private final Activity activity;
|
private final Activity activity;
|
||||||
|
|
||||||
private boolean bound = false;
|
private boolean bound = false;
|
||||||
@@ -50,7 +55,9 @@ public class BriarControllerImpl implements BriarController {
|
|||||||
AccountManager accountManager,
|
AccountManager accountManager,
|
||||||
LifecycleManager lifecycleManager,
|
LifecycleManager lifecycleManager,
|
||||||
@DatabaseExecutor Executor databaseExecutor,
|
@DatabaseExecutor Executor databaseExecutor,
|
||||||
SettingsManager settingsManager, DozeWatchdog dozeWatchdog,
|
SettingsManager settingsManager,
|
||||||
|
DozeWatchdog dozeWatchdog,
|
||||||
|
AndroidWakeLockManager wakeLockManager,
|
||||||
Activity activity) {
|
Activity activity) {
|
||||||
this.serviceConnection = serviceConnection;
|
this.serviceConnection = serviceConnection;
|
||||||
this.accountManager = accountManager;
|
this.accountManager = accountManager;
|
||||||
@@ -58,6 +65,7 @@ public class BriarControllerImpl implements BriarController {
|
|||||||
this.databaseExecutor = databaseExecutor;
|
this.databaseExecutor = databaseExecutor;
|
||||||
this.settingsManager = settingsManager;
|
this.settingsManager = settingsManager;
|
||||||
this.dozeWatchdog = dozeWatchdog;
|
this.dozeWatchdog = dozeWatchdog;
|
||||||
|
this.wakeLockManager = wakeLockManager;
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,9 +135,8 @@ public class BriarControllerImpl implements BriarController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void signOut(ResultHandler<Void> eventHandler,
|
public void signOut(ResultHandler<Void> handler, boolean deleteAccount) {
|
||||||
boolean deleteAccount) {
|
wakeLockManager.executeWakefully(() -> {
|
||||||
new Thread(() -> {
|
|
||||||
try {
|
try {
|
||||||
// Wait for the service to finish starting up
|
// Wait for the service to finish starting up
|
||||||
IBinder binder = serviceConnection.waitForBinder();
|
IBinder binder = serviceConnection.waitForBinder();
|
||||||
@@ -145,8 +152,8 @@ public class BriarControllerImpl implements BriarController {
|
|||||||
} finally {
|
} finally {
|
||||||
if (deleteAccount) accountManager.deleteAccount();
|
if (deleteAccount) accountManager.deleteAccount();
|
||||||
}
|
}
|
||||||
eventHandler.onResult(null);
|
handler.onResult(null);
|
||||||
}).start();
|
}, "SignOut");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,17 +4,14 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.system.AndroidExecutor;
|
|
||||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||||
import org.briarproject.briar.android.activity.BriarActivity;
|
import org.briarproject.briar.android.activity.BriarActivity;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import info.guardianproject.GuardianProjectRSA4096;
|
import info.guardianproject.GuardianProjectRSA4096;
|
||||||
@@ -23,6 +20,7 @@ import info.guardianproject.panic.PanicResponder;
|
|||||||
import info.guardianproject.trustedintents.TrustedIntents;
|
import info.guardianproject.trustedintents.TrustedIntents;
|
||||||
|
|
||||||
import static android.os.Build.VERSION.SDK_INT;
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.briar.android.panic.PanicPreferencesFragment.KEY_LOCK;
|
import static org.briarproject.briar.android.panic.PanicPreferencesFragment.KEY_LOCK;
|
||||||
import static org.briarproject.briar.android.panic.PanicPreferencesFragment.KEY_PURGE;
|
import static org.briarproject.briar.android.panic.PanicPreferencesFragment.KEY_PURGE;
|
||||||
|
|
||||||
@@ -31,12 +29,7 @@ import static org.briarproject.briar.android.panic.PanicPreferencesFragment.KEY_
|
|||||||
public class PanicResponderActivity extends BriarActivity {
|
public class PanicResponderActivity extends BriarActivity {
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(PanicResponderActivity.class.getName());
|
getLogger(PanicResponderActivity.class.getName());
|
||||||
|
|
||||||
@Inject
|
|
||||||
protected LifecycleManager lifecycleManager;
|
|
||||||
@Inject
|
|
||||||
protected AndroidExecutor androidExecutor;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
@@ -63,11 +56,14 @@ public class PanicResponderActivity extends BriarActivity {
|
|||||||
// Performing panic responses
|
// Performing panic responses
|
||||||
if (sharedPref.getBoolean(KEY_PURGE, false)) {
|
if (sharedPref.getBoolean(KEY_PURGE, false)) {
|
||||||
LOG.info("Purging all data...");
|
LOG.info("Purging all data...");
|
||||||
deleteAllData();
|
signOut(true, true);
|
||||||
|
} else {
|
||||||
|
LOG.info("Signing out...");
|
||||||
|
signOut(true, false);
|
||||||
}
|
}
|
||||||
}
|
} else if (sharedPref.getBoolean(KEY_LOCK, true)) {
|
||||||
// non-destructive actions are allowed by non-connected trusted apps
|
// non-destructive actions are allowed by non-connected
|
||||||
if (sharedPref.getBoolean(KEY_LOCK, true)) {
|
// trusted apps
|
||||||
LOG.info("Signing out...");
|
LOG.info("Signing out...");
|
||||||
signOut(true, false);
|
signOut(true, false);
|
||||||
}
|
}
|
||||||
@@ -85,11 +81,4 @@ public class PanicResponderActivity extends BriarActivity {
|
|||||||
public void injectActivity(ActivityComponent component) {
|
public void injectActivity(ActivityComponent component) {
|
||||||
component.inject(this);
|
component.inject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteAllData() {
|
|
||||||
androidExecutor.runOnBackgroundThread(() -> {
|
|
||||||
LOG.info("Signing out...");
|
|
||||||
signOut(true, true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user