Commit 15cb5409 authored by akwizgran's avatar akwizgran

Merge branch '1352-panic-ripple-fdroid' into 'master'

Fix Panic Button bugs

Closes #1109 and #1352

See merge request !937
parents cc87c4e3 fd07dc00
package org.briarproject.briar.android.panic;
import info.guardianproject.trustedintents.ApkSignaturePin;
// needs to be public, because TrustedIntents will instantiate
public final class FDroidSignaturePin extends ApkSignaturePin {
public FDroidSignaturePin() {
this.fingerprints = new String[] {
"927f7e38b6acbecd84e02dace33efa9a7a2f0979750f28f585688ee38b3a4e28"};
this.certificates = new byte[][] {
{48, -126, 3, 95, 48, -126, 2, 71, -96, 3, 2, 1, 2, 2, 4, 28,
-30, 107, -102, 48, 13, 6, 9, 42, -122, 72, -122, -9,
13, 1, 1, 11, 5, 0, 48, 96, 49, 11, 48, 9, 6, 3, 85, 4,
6, 19, 2, 85, 75, 49, 12, 48, 10, 6, 3, 85, 4, 8, 19, 3,
79, 82, 71, 49, 12, 48, 10, 6, 3, 85, 4, 7, 19, 3, 79,
82, 71, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10, 102,
100, 114, 111, 105, 100, 46, 111, 114, 103, 49, 15, 48,
13, 6, 3, 85, 4, 11, 19, 6, 70, 68, 114, 111, 105, 100,
49, 15, 48, 13, 6, 3, 85, 4, 3, 19, 6, 70, 68, 114, 111,
105, 100, 48, 30, 23, 13, 49, 55, 49, 50, 48, 55, 49,
55, 51, 48, 52, 50, 90, 23, 13, 52, 53, 48, 52, 50, 52,
49, 55, 51, 48, 52, 50, 90, 48, 96, 49, 11, 48, 9, 6, 3,
85, 4, 6, 19, 2, 85, 75, 49, 12, 48, 10, 6, 3, 85, 4, 8,
19, 3, 79, 82, 71, 49, 12, 48, 10, 6, 3, 85, 4, 7, 19,
3, 79, 82, 71, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
102, 100, 114, 111, 105, 100, 46, 111, 114, 103, 49, 15,
48, 13, 6, 3, 85, 4, 11, 19, 6, 70, 68, 114, 111, 105,
100, 49, 15, 48, 13, 6, 3, 85, 4, 3, 19, 6, 70, 68, 114,
111, 105, 100, 48, -126, 1, 34, 48, 13, 6, 9, 42, -122,
72, -122, -9, 13, 1, 1, 1, 5, 0, 3, -126, 1, 15, 0, 48,
-126, 1, 10, 2, -126, 1, 1, 0, -107, -115, -106, 1, -26,
72, -105, -99, 62, 3, -55, 34, 99, -112, -68, -20, -115,
31, 34, 118, -50, 12, -32, -59, 74, -58, -37, -87, 21,
105, 36, -82, 13, -51, 66, 4, 55, -111, 13, -46, -7,
-69, -15, 36, 118, -7, 101, -86, 123, -83, -103, 110,
116, -54, 112, 46, 12, 96, -76, -48, -70, -33, -81, 52,
59, 73, 107, -126, -72, -25, 32, 93, 29, -20, 5, -41,
-27, 123, -9, 104, -31, -59, -1, -83, -93, 99, 85, -116,
-62, -55, 18, -63, 6, -51, -110, 33, 9, 7, -49, 102,
-20, -122, -124, -68, 93, -102, 31, 48, 86, 96, -99,
105, -52, 95, 12, 57, 99, 12, -24, 70, 40, -99, -20,
-21, -85, -70, -105, 95, 117, -31, 126, -126, -39, 46,
-62, 59, -23, -74, 108, -12, -56, -40, -96, 79, -37,
-82, 1, 99, -104, 48, -60, 92, 14, 109, 127, -22, 31,
115, -27, 108, 9, 92, 118, -45, 103, 117, 57, -50, -82,
114, -113, 68, -82, 87, 96, 111, 72, 65, -63, 12, 31,
-34, -31, -55, -101, 101, 101, 59, 73, -119, -122, 82,
28, 47, -108, -85, 59, 46, 89, -93, -1, 9, -11, -51, 63,
-44, 109, -76, -103, -26, -49, -80, 6, 52, -27, 73,
-104, 40, 2, -101, -124, 60, -52, -105, -70, -24, -62,
88, 38, 53, -99, -92, 31, 119, 26, 79, 60, -124, 25,
-115, -89, -115, -109, 0, 6, 122, -78, 116, 82, 3, 39,
-67, 45, -43, 17, -39, 2, 3, 1, 0, 1, -93, 33, 48, 31,
48, 29, 6, 3, 85, 29, 14, 4, 22, 4, 20, 63, 109, -42,
-109, 25, 22, 7, -37, -22, -41, -38, 58, -56, 2, -68,
-38, -22, 65, -28, -60, 48, 13, 6, 9, 42, -122, 72,
-122, -9, 13, 1, 1, 11, 5, 0, 3, -126, 1, 1, 0, 94, 17,
31, 36, 85, -11, 85, 44, 19, -80, -20, -92, -118, 93,
40, 45, 96, 31, -3, -37, -110, -96, 102, 81, 61, -74,
-125, -117, -112, 58, -47, 17, 78, -18, 111, -116, 26,
-91, 73, 100, 84, -99, 21, 87, 73, -106, 108, -51, -125,
-21, 119, -88, -78, 2, 82, -109, -64, -9, -86, -112,
-115, 66, -86, 46, 71, 107, -65, 96, -102, 47, 35, -45,
-126, 33, 34, 121, -25, -85, -121, -56, -42, 22, -1,
-95, -86, 81, 100, -70, 113, 104, -73, 22, -19, 79, -19,
52, 62, 42, 76, -112, 94, -34, 42, -57, -75, -90, -58,
118, 127, -106, -39, 108, -56, -79, 103, -33, 22, 3, 47,
103, -76, -81, 53, -22, -44, -26, -102, 63, -99, 39, 38,
-108, 75, 33, 10, 25, -110, -125, -115, 114, -69, 73,
-112, 36, 74, 77, -82, -44, 29, -123, -8, -117, 71,
-105, 15, -109, 51, 22, 4, 80, 1, 43, 118, 121, -113,
-70, 83, -56, 82, -110, 4, -63, 16, -57, 126, -70, 81,
73, 61, 2, -61, 24, -14, -10, 4, -21, 90, 24, 66, 41,
-57, -60, -113, -18, -54, -1, 103, -75, 32, -64, 67,
103, 109, -79, -12, -113, -27, 114, 89, 116, 115, -13,
-123, -70, 61, -41, -46, -118, 29, -105, -97, -75, 39,
-51, 60, 88, 125, 55, -46, -95, 52, 57, 52, -115, 80,
44, 109, 119, -116, -62, -77, -74, -88, 41, 57, -65,
-71, -115, -67, 23, 66, -21, 56, 51, -91, 109}};
}
}
......@@ -31,13 +31,12 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
public static final String KEY_LOCK = "pref_key_lock";
public static final String KEY_PANIC_APP = "pref_key_panic_app";
public static final String KEY_PURGE = "pref_key_purge";
public static final String KEY_UNINSTALL = "pref_key_uninstall";
private static final Logger LOG =
Logger.getLogger(PanicPreferencesFragment.class.getName());
private PackageManager pm;
private SwitchPreference lockPref, purgePref, uninstallPref;
private SwitchPreference lockPref, purgePref;
private ListPreference panicAppPref;
@Override
......@@ -49,7 +48,6 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
lockPref = (SwitchPreference) findPreference(KEY_LOCK);
panicAppPref = (ListPreference) findPreference(KEY_PANIC_APP);
purgePref = (SwitchPreference) findPreference(KEY_PURGE);
uninstallPref = (SwitchPreference) findPreference(KEY_UNINSTALL);
// check for connect/disconnect intents from panic trigger apps
if (PanicResponder.checkForDisconnectIntent(getActivity())) {
......@@ -97,16 +95,11 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
showPanicApp(packageName);
if (packageName.equals(Panic.PACKAGE_NAME_NONE)) {
lockPref.setEnabled(false);
purgePref.setChecked(false);
purgePref.setEnabled(false);
uninstallPref.setChecked(false);
uninstallPref.setEnabled(false);
getActivity().setResult(Activity.RESULT_CANCELED);
} else {
lockPref.setEnabled(true);
purgePref.setEnabled(true);
uninstallPref.setEnabled(true);
}
return true;
......@@ -145,27 +138,15 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
if (key.equals(KEY_PURGE)) {
// enable locking if purging gets enabled
if (sharedPreferences.getBoolean(KEY_PURGE, false)) {
lockPref.setChecked(true);
}
// disable uninstall if purging gets disabled
else {
uninstallPref.setChecked(false);
}
}
// enable purging and locking if uninstall gets enabled
if (key.equals(KEY_UNINSTALL) &&
sharedPreferences.getBoolean(KEY_UNINSTALL, false)) {
// enable locking if purging gets enabled
if (key.equals(KEY_PURGE) &&
sharedPreferences.getBoolean(KEY_PURGE, false)) {
lockPref.setChecked(true);
purgePref.setChecked(true);
}
// disable purging and uninstalling if locking gets disabled
// disable purging if locking gets disabled
if (key.equals(KEY_LOCK) &&
!sharedPreferences.getBoolean(KEY_LOCK, true)) {
purgePref.setChecked(false);
uninstallPref.setChecked(false);
}
}
......@@ -179,10 +160,8 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
panicAppPref.setIcon(
android.R.drawable.ic_menu_close_clear_cancel);
// disable panic actions
lockPref.setEnabled(false);
// disable destructive panic actions
purgePref.setEnabled(false);
uninstallPref.setEnabled(false);
} else {
// display connected panic app
try {
......@@ -192,10 +171,8 @@ public class PanicPreferencesFragment extends PreferenceFragmentCompat
panicAppPref.setIcon(
pm.getApplicationIcon(triggerPackageName));
// enable panic actions
lockPref.setEnabled(true);
// enable destructive panic actions
purgePref.setEnabled(true);
uninstallPref.setEnabled(true);
} catch (PackageManager.NameNotFoundException e) {
// revert back to no app, just to be safe
PanicResponder.setTriggerPackageName(getActivity(),
......
......@@ -2,7 +2,6 @@ package org.briarproject.briar.android.panic;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.preference.PreferenceManager;
......@@ -11,7 +10,6 @@ import org.briarproject.bramble.api.account.AccountManager;
import org.briarproject.bramble.api.system.AndroidExecutor;
import org.briarproject.briar.android.activity.ActivityComponent;
import org.briarproject.briar.android.activity.BriarActivity;
import org.iilab.IilabEngineeringRSA2048Pin;
import java.util.logging.Logger;
......@@ -22,10 +20,8 @@ import info.guardianproject.panic.Panic;
import info.guardianproject.panic.PanicResponder;
import info.guardianproject.trustedintents.TrustedIntents;
import static android.content.Intent.ACTION_DELETE;
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_UNINSTALL;
public class PanicResponderActivity extends BriarActivity {
......@@ -44,8 +40,8 @@ public class PanicResponderActivity extends BriarActivity {
TrustedIntents trustedIntents = TrustedIntents.get(this);
// Guardian Project Ripple
trustedIntents.addTrustedSigner(GuardianProjectRSA4096.class);
// Amnesty International's Panic Button, made by iilab.org
trustedIntents.addTrustedSigner(IilabEngineeringRSA2048Pin.class);
// F-Droid
trustedIntents.addTrustedSigner(FDroidSignaturePin.class);
Intent intent = trustedIntents.getIntentFromTrustedSender(this);
if (intent != null) {
......@@ -60,23 +56,16 @@ public class PanicResponderActivity extends BriarActivity {
LOG.info("Panic Trigger came from connected app");
// Performing panic responses
if (sharedPref.getBoolean(KEY_UNINSTALL, false)) {
if (sharedPref.getBoolean(KEY_PURGE, false)) {
LOG.info("Purging all data...");
deleteAllData();
LOG.info("Uninstalling...");
Intent uninstall = new Intent(ACTION_DELETE);
uninstall.setData(
Uri.parse("package:" + getPackageName()));
startActivity(uninstall);
} else if (sharedPref.getBoolean(KEY_PURGE, false)) {
LOG.info("Purging all data...");
deleteAllData();
} else if (sharedPref.getBoolean(KEY_LOCK, true)) {
LOG.info("Signing out...");
signOut(true);
}
}
// non-destructive actions are allowed by non-connected trusted apps
if (sharedPref.getBoolean(KEY_LOCK, true)) {
LOG.info("Signing out...");
signOut(true);
}
}
}
......
......@@ -398,6 +398,7 @@
<string name="panic_app_setting_none">None</string>
<string name="dialog_title_connect_panic_app">Confirm Panic App</string>
<string name="dialog_message_connect_panic_app">Are you sure that you want to allow %1$s to trigger destructive panic button actions?</string>
<string name="panic_setting_destructive_action">Destructive Actions</string>
<string name="panic_setting_signout_title">Sign Out</string>
<string name="panic_setting_signout_summary">Sign out of Briar if a panic button is pressed</string>
<string name="purge_setting_title">Delete Account</string>
......
......@@ -2,31 +2,29 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:key="pref_key_panic_app"
android:summary="@string/panic_app_setting_summary"
android:title="@string/panic_app_setting_title"/>
<SwitchPreference
android:defaultValue="true"
android:enabled="false"
android:key="pref_key_lock"
android:summary="@string/panic_setting_signout_summary"
android:title="@string/panic_setting_signout_title"/>
<SwitchPreference
android:defaultValue="false"
android:enabled="false"
android:key="pref_key_purge"
android:summary="@string/purge_setting_summary"
android:title="@string/purge_setting_title"/>
<PreferenceCategory
android:layout="@layout/preferences_category"
android:title="@string/panic_setting_destructive_action">
<SwitchPreference
android:defaultValue="false"
android:enabled="false"
android:key="pref_key_uninstall"
android:summary="@string/uninstall_setting_summary"
android:title="@string/uninstall_setting_title"/>
<ListPreference
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:key="pref_key_panic_app"
android:summary="@string/panic_app_setting_summary"
android:title="@string/panic_app_setting_title"/>
<SwitchPreference
android:defaultValue="false"
android:enabled="false"
android:key="pref_key_purge"
android:summary="@string/purge_setting_summary"
android:title="@string/purge_setting_title"/>
</PreferenceCategory>
</PreferenceScreen>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment