When the user triggers a Panic action the user preferences and secrets database are wiped.
The user will be able to restore from a secure backup when she's in a safe place.
This commit is contained in:
Carlos Melero 2017-08-12 14:09:36 +02:00
parent e6514bf646
commit 76011cd616
No known key found for this signature in database
GPG key ID: 490431E1398756EC
2 changed files with 50 additions and 1 deletions

View file

@ -39,6 +39,15 @@
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="fullSensor"
tools:replace="screenOrientation" />
<activity
android:name=".Activities.PanicResponderActivity"
android:launchMode="singleInstance"
android:noHistory="true"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="info.guardianproject.panic.action.TRIGGER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>

View file

@ -0,0 +1,40 @@
package org.shadowice.flocke.andotp.Activities;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import org.shadowice.flocke.andotp.Database.Entry;
import org.shadowice.flocke.andotp.R;
import java.util.ArrayList;
import static org.shadowice.flocke.andotp.Utilities.DatabaseHelper.saveDatabase;
public class PanicResponderActivity extends Activity {
public static final String PANIC_TRIGGER_ACTION = "info.guardianproject.panic.action.TRIGGER";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
if (intent != null && PANIC_TRIGGER_ACTION.equals(intent.getAction())) {
// Clean custom configuration.
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
sharedPref.edit().clear().commit();
PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
// Override secrets database
saveDatabase(this, new ArrayList<Entry>());
}
if (Build.VERSION.SDK_INT >= 21) {
finishAndRemoveTask();
} else {
finish();
}
}
}