-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
respond to generic panic trigger Intent by locking
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
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |