mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 21:29:54 +01:00
Merge branch '932-panic-button-terminate-process' into 'master'
Terminate the process after handling a panic trigger Closes #932 See merge request !513
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,3 +23,4 @@ local.properties
|
|||||||
.gradle
|
.gradle
|
||||||
build/
|
build/
|
||||||
*.iml
|
*.iml
|
||||||
|
projectFilesBackup/
|
||||||
@@ -14,7 +14,7 @@ import android.view.Window;
|
|||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.controller.BriarController;
|
import org.briarproject.briar.android.controller.BriarController;
|
||||||
import org.briarproject.briar.android.controller.DbController;
|
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.fragment.BaseFragment;
|
||||||
import org.briarproject.briar.android.login.PasswordActivity;
|
import org.briarproject.briar.android.login.PasswordActivity;
|
||||||
import org.briarproject.briar.android.panic.ExitActivity;
|
import org.briarproject.briar.android.panic.ExitActivity;
|
||||||
@@ -116,17 +116,28 @@ public abstract class BriarActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void signOut(final boolean removeFromRecentApps) {
|
protected void signOut(final boolean removeFromRecentApps) {
|
||||||
briarController.signOut(new UiResultHandler<Void>(this) {
|
if (briarController.hasEncryptionKey()) {
|
||||||
@Override
|
// Don't use UiResultHandler because we want the result even if
|
||||||
public void onResultUi(Void result) {
|
// this activity has been destroyed
|
||||||
if (removeFromRecentApps) startExitActivity();
|
briarController.signOut(new ResultHandler<Void>() {
|
||||||
else finishAndExit();
|
@Override
|
||||||
}
|
public void onResult(Void result) {
|
||||||
});
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
exit(removeFromRecentApps);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
exit(removeFromRecentApps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void signOut() {
|
private void exit(boolean removeFromRecentApps) {
|
||||||
signOut(false);
|
if (removeFromRecentApps) startExitActivity();
|
||||||
|
else finishAndExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startExitActivity() {
|
private void startExitActivity() {
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class NavDrawerActivity extends BriarActivity implements
|
|||||||
} else if (getSupportFragmentManager().getBackStackEntryCount() == 0 &&
|
} else if (getSupportFragmentManager().getBackStackEntryCount() == 0 &&
|
||||||
getSupportFragmentManager()
|
getSupportFragmentManager()
|
||||||
.findFragmentByTag(ContactListFragment.TAG) == null) {
|
.findFragmentByTag(ContactListFragment.TAG) == null) {
|
||||||
/**
|
/*
|
||||||
* This Makes sure that the first fragment (ContactListFragment) the
|
* This Makes sure that the first fragment (ContactListFragment) the
|
||||||
* user sees is the same as the last fragment the user sees before
|
* user sees is the same as the last fragment the user sees before
|
||||||
* exiting. This models the typical Google navigation behaviour such
|
* exiting. This models the typical Google navigation behaviour such
|
||||||
@@ -212,11 +212,10 @@ public class NavDrawerActivity extends BriarActivity implements
|
|||||||
drawerToggle.onConfigurationChanged(newConfig);
|
drawerToggle.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void signOut() {
|
||||||
protected void signOut() {
|
|
||||||
drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED);
|
drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED);
|
||||||
startFragment(new SignOutFragment());
|
startFragment(new SignOutFragment());
|
||||||
super.signOut();
|
signOut(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startFragment(BaseFragment fragment, int itemId){
|
private void startFragment(BaseFragment fragment, int itemId){
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ public class PanicResponderActivity extends BriarActivity {
|
|||||||
LOG.info("Received Panic Trigger...");
|
LOG.info("Received Panic Trigger...");
|
||||||
|
|
||||||
if (PanicResponder.receivedTriggerFromConnectedApp(this)) {
|
if (PanicResponder.receivedTriggerFromConnectedApp(this)) {
|
||||||
LOG.info("Panic Trigger came from connected app.");
|
LOG.info("Panic Trigger came from connected app");
|
||||||
LOG.info("Performing destructive responses...");
|
|
||||||
|
|
||||||
// Performing panic responses
|
// Performing panic responses
|
||||||
if (sharedPref.getBoolean(KEY_UNINSTALL, false)) {
|
if (sharedPref.getBoolean(KEY_UNINSTALL, false)) {
|
||||||
@@ -73,21 +72,13 @@ public class PanicResponderActivity extends BriarActivity {
|
|||||||
} else if (sharedPref.getBoolean(KEY_PURGE, false)) {
|
} else if (sharedPref.getBoolean(KEY_PURGE, false)) {
|
||||||
LOG.info("Purging all data...");
|
LOG.info("Purging all data...");
|
||||||
deleteAllData();
|
deleteAllData();
|
||||||
} else if (sharedPref.getBoolean(KEY_LOCK, false)) {
|
} else if (sharedPref.getBoolean(KEY_LOCK, true)) {
|
||||||
LOG.info("Signing out...");
|
LOG.info("Signing out...");
|
||||||
signOut(true);
|
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) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
finishAndRemoveTask();
|
finishAndRemoveTask();
|
||||||
|
|||||||
Reference in New Issue
Block a user