Terminate the process after handling a panic trigger.

This commit is contained in:
akwizgran
2017-04-07 10:53:56 +01:00
parent 9d0dbe9210
commit d5d9436e28
4 changed files with 27 additions and 25 deletions

1
.gitignore vendored
View File

@@ -23,3 +23,4 @@ local.properties
.gradle
build/
*.iml
projectFilesBackup/

View File

@@ -14,7 +14,7 @@ import android.view.Window;
import org.briarproject.briar.R;
import org.briarproject.briar.android.controller.BriarController;
import org.briarproject.briar.android.controller.DbController;
import org.briarproject.briar.android.controller.handler.UiResultHandler;
import org.briarproject.briar.android.controller.handler.ResultHandler;
import org.briarproject.briar.android.fragment.BaseFragment;
import org.briarproject.briar.android.login.PasswordActivity;
import org.briarproject.briar.android.panic.ExitActivity;
@@ -116,17 +116,28 @@ public abstract class BriarActivity extends BaseActivity {
}
protected void signOut(final boolean removeFromRecentApps) {
briarController.signOut(new UiResultHandler<Void>(this) {
@Override
public void onResultUi(Void result) {
if (removeFromRecentApps) startExitActivity();
else finishAndExit();
}
});
if (briarController.hasEncryptionKey()) {
// Don't use UiResultHandler because we want the result even if
// this activity has been destroyed
briarController.signOut(new ResultHandler<Void>() {
@Override
public void onResult(Void result) {
runOnUiThread(new Runnable() {
@Override
public void run() {
exit(removeFromRecentApps);
}
});
}
});
} else {
exit(removeFromRecentApps);
}
}
protected void signOut() {
signOut(false);
private void exit(boolean removeFromRecentApps) {
if (removeFromRecentApps) startExitActivity();
else finishAndExit();
}
private void startExitActivity() {

View File

@@ -188,7 +188,7 @@ public class NavDrawerActivity extends BriarActivity implements
} else if (getSupportFragmentManager().getBackStackEntryCount() == 0 &&
getSupportFragmentManager()
.findFragmentByTag(ContactListFragment.TAG) == null) {
/**
/*
* This Makes sure that the first fragment (ContactListFragment) the
* user sees is the same as the last fragment the user sees before
* exiting. This models the typical Google navigation behaviour such
@@ -212,11 +212,10 @@ public class NavDrawerActivity extends BriarActivity implements
drawerToggle.onConfigurationChanged(newConfig);
}
@Override
protected void signOut() {
private void signOut() {
drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED);
startFragment(new SignOutFragment());
super.signOut();
signOut(false);
}
private void startFragment(BaseFragment fragment, int itemId){

View File

@@ -57,8 +57,7 @@ public class PanicResponderActivity extends BriarActivity {
LOG.info("Received Panic Trigger...");
if (PanicResponder.receivedTriggerFromConnectedApp(this)) {
LOG.info("Panic Trigger came from connected app.");
LOG.info("Performing destructive responses...");
LOG.info("Panic Trigger came from connected app");
// Performing panic responses
if (sharedPref.getBoolean(KEY_UNINSTALL, false)) {
@@ -73,21 +72,13 @@ public class PanicResponderActivity extends BriarActivity {
} else if (sharedPref.getBoolean(KEY_PURGE, false)) {
LOG.info("Purging all data...");
deleteAllData();
} else if (sharedPref.getBoolean(KEY_LOCK, false)) {
} else if (sharedPref.getBoolean(KEY_LOCK, true)) {
LOG.info("Signing out...");
signOut(true);
}
}
}
}
// received intent from non-trusted app
else {
intent = getIntent();
if (intent != null && Panic.isTriggerIntent(intent)) {
LOG.info("Signing out...");
signOut(true);
}
}
if (Build.VERSION.SDK_INT >= 21) {
finishAndRemoveTask();