Skip to content

Commit

Permalink
respond to generic panic trigger Intent by locking
Browse files Browse the repository at this point in the history
PanicKit provides a common framework for creating "panic button" apps that
can trigger actions in "panic responder" apps.  In this case, the response
is to lock the app, if it has been configured to do so

https://dev.guardianproject.info/projects/panic/wiki
  • Loading branch information
eighthave committed Jun 24, 2016
1 parent d2e2ff5 commit 25c3f8f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity>
<activity android:name="com.keepassdroid.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>
<activity android:name="com.keepassdroid.settings.AppSettingsActivity"
android:theme="@style/NoTitleBar"></activity>
<activity android:name="com.keepassdroid.GeneratePasswordActivity"
Expand Down
34 changes: 34 additions & 0 deletions app/src/main/java/com/keepassdroid/PanicResponderActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

package com.keepassdroid;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;

import com.android.keepass.KeePass;
import com.keepassdroid.app.App;

public class PanicResponderActivity extends Activity {

public static final String PANIC_TRIGGER_ACTION = "info.guardianproject.panic.action.TRIGGER";

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Intent intent = getIntent();
if (intent != null && PANIC_TRIGGER_ACTION.equals(intent.getAction())) {
App.setShutdown();
setResult(KeePass.EXIT_LOCK);
}

if (Build.VERSION.SDK_INT >= 21) {
finishAndRemoveTask();
} else {
finish();
}
}
}

0 comments on commit 25c3f8f

Please sign in to comment.