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 Dec 30, 2015
1 parent 19cbb19 commit 903fefb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
8 changes: 8 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@
android:theme="@style/NoTitleBar"></activity>
<activity android:name="com.keepassdroid.GeneratePasswordActivity"
android:theme="@style/NoTitleBar"></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>
<service android:name="com.keepassdroid.services.TimeoutService"></service>
<meta-data android:name="com.a0soft.gphone.aTrackDog.webURL" android:value="http://keepassdroid.com" />
</application>
Expand Down
39 changes: 39 additions & 0 deletions src/com/keepassdroid/PanicResponderActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

package com.keepassdroid;

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

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

public class PanicResponderActivity extends Activity {

private static final String TAG = PanicResponderActivity.class.getSimpleName();

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

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

Intent intent = getIntent();
if (intent != null && PANIC_TRIGGER_ACTION.equals(intent.getAction())) {
Log.i(TAG, "onCreate");
App.setShutdown();
setResult(KeePass.EXIT_LOCK);
}

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

0 comments on commit 903fefb

Please sign in to comment.