mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
[android] add review comments for panic induced account deletion
This commit is contained in:
@@ -185,13 +185,15 @@ public abstract class BriarActivity extends BaseActivity {
|
||||
b.show();
|
||||
}
|
||||
|
||||
protected void signOut(boolean removeFromRecentApps) {
|
||||
protected void signOut(boolean removeFromRecentApps,
|
||||
boolean deleteAccount) {
|
||||
if (briarController.accountSignedIn()) {
|
||||
// Don't use UiResultHandler because we want the result even if
|
||||
// this activity has been destroyed
|
||||
briarController.signOut(result -> runOnUiThread(
|
||||
() -> exit(removeFromRecentApps)));
|
||||
() -> exit(removeFromRecentApps)), deleteAccount);
|
||||
} else {
|
||||
if (deleteAccount) briarController.deleteAccount();
|
||||
exit(removeFromRecentApps);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,8 @@ public interface BriarController extends ActivityLifecycleController {
|
||||
|
||||
void doNotAskAgainForDozeWhiteListing();
|
||||
|
||||
void signOut(ResultHandler<Void> eventHandler);
|
||||
void signOut(ResultHandler<Void> eventHandler, boolean deleteAccount);
|
||||
|
||||
void deleteAccount();
|
||||
|
||||
}
|
||||
|
||||
@@ -120,7 +120,8 @@ public class BriarControllerImpl implements BriarController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void signOut(ResultHandler<Void> eventHandler) {
|
||||
public void signOut(ResultHandler<Void> eventHandler,
|
||||
boolean deleteAccount) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
// Wait for the service to finish starting up
|
||||
@@ -134,11 +135,18 @@ public class BriarControllerImpl implements BriarController {
|
||||
service.waitForShutdown();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.warning("Interrupted while waiting for service");
|
||||
} finally {
|
||||
if (deleteAccount) accountManager.deleteAccount();
|
||||
}
|
||||
eventHandler.onResult(null);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAccount() {
|
||||
accountManager.deleteAccount();
|
||||
}
|
||||
|
||||
private void unbindService() {
|
||||
if (bound) activity.unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class NavDrawerActivity extends BriarActivity implements
|
||||
} else if (intent.getBooleanExtra(INTENT_BLOGS, false)) {
|
||||
startFragment(FeedFragment.newInstance(), R.id.nav_btn_blogs);
|
||||
} else if (intent.getBooleanExtra(INTENT_SIGN_OUT, false)) {
|
||||
signOut(false);
|
||||
signOut(false, false);
|
||||
}
|
||||
setIntent(null);
|
||||
}
|
||||
@@ -279,7 +279,7 @@ public class NavDrawerActivity extends BriarActivity implements
|
||||
|
||||
private void signOut() {
|
||||
drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED);
|
||||
signOut(false);
|
||||
signOut(false, false);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
|
||||
import org.briarproject.bramble.api.account.AccountManager;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
@@ -24,8 +23,6 @@ import info.guardianproject.panic.PanicResponder;
|
||||
import info.guardianproject.trustedintents.TrustedIntents;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
import static org.briarproject.briar.android.panic.PanicPreferencesFragment.KEY_LOCK;
|
||||
import static org.briarproject.briar.android.panic.PanicPreferencesFragment.KEY_PURGE;
|
||||
|
||||
@@ -39,8 +36,6 @@ public class PanicResponderActivity extends BriarActivity {
|
||||
@Inject
|
||||
protected LifecycleManager lifecycleManager;
|
||||
@Inject
|
||||
protected AccountManager accountManager;
|
||||
@Inject
|
||||
protected AndroidExecutor androidExecutor;
|
||||
|
||||
@Override
|
||||
@@ -74,7 +69,7 @@ public class PanicResponderActivity extends BriarActivity {
|
||||
// non-destructive actions are allowed by non-connected trusted apps
|
||||
if (sharedPref.getBoolean(KEY_LOCK, true)) {
|
||||
LOG.info("Signing out...");
|
||||
signOut(true);
|
||||
signOut(true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,17 +88,8 @@ public class PanicResponderActivity extends BriarActivity {
|
||||
|
||||
private void deleteAllData() {
|
||||
androidExecutor.runOnBackgroundThread(() -> {
|
||||
lifecycleManager.stopServices();
|
||||
try {
|
||||
lifecycleManager.waitForShutdown();
|
||||
} catch (InterruptedException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
} finally {
|
||||
accountManager.deleteAccount();
|
||||
// nothing left to do after everything is deleted, so sign out
|
||||
LOG.info("Signing out...");
|
||||
signOut(true);
|
||||
}
|
||||
LOG.info("Signing out...");
|
||||
signOut(true, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user