diff options
author | Matthew Wong <wongma@protonmail.ch> | 2015-09-03 15:00:01 -0400 |
---|---|---|
committer | Matthew Wong <wongma@protonmail.ch> | 2015-09-03 15:00:01 -0400 |
commit | 68e1495ef26645750e111cb7a7299c2b9efd2be3 (patch) | |
tree | 4714747eefc984403bdfa10719b83b595e8ec55d /app/src/main/java/com/zeapo | |
parent | c534cfe49875c6fc84050cc02c653eb5a57bcddc (diff) |
Use openpgpapi correctly to address #128
Diffstat (limited to 'app/src/main/java/com/zeapo')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java | 2 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java index d8e50ebd..6d11936b 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.java @@ -34,7 +34,7 @@ public class AutofillActivity extends AppCompatActivity { protected void onActivityResult(int requestCode, int resultCode, Intent data) { finish(); // go back to the password field app if (resultCode == RESULT_OK) { - AutofillService.setUnlockOK(); // report the result to service + AutofillService.setResultData(data); // report the result to service } } } diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java index ea09c863..8a4a80bf 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java @@ -44,7 +44,7 @@ public class AutofillService extends AccessibilityService { private ArrayList<PasswordItem> items; // password choices private AlertDialog dialog; private AccessibilityWindowInfo window; - private static boolean unlockOK = false; // if openkeychain user interaction was successful + private static Intent resultData = null; // need the intent which contains results from user interaction private CharSequence packageName; private boolean ignoreActionFocus = false; @@ -52,7 +52,7 @@ public class AutofillService extends AccessibilityService { public static final String TAG = "Keychain"; } - public static void setUnlockOK() { unlockOK = true; } + public static void setResultData(Intent data) { resultData = data; } @Override protected void onServiceConnected() { @@ -66,7 +66,7 @@ public class AutofillService extends AccessibilityService { public void onAccessibilityEvent(AccessibilityEvent event) { // if returning to the source app from a successful AutofillActivity if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED - && event.getPackageName().equals(packageName) && unlockOK) { + && event.getPackageName().equals(packageName) && resultData != null) { decryptAndVerify(); } @@ -203,10 +203,15 @@ public class AutofillService extends AccessibilityService { } public void decryptAndVerify() { - unlockOK = false; packageName = info.getPackageName(); - Intent data = new Intent(); - data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); + Intent data; + if (resultData == null) { + data = new Intent(); + data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); + } else { + data = resultData; + resultData = null; + } InputStream is = null; try { is = FileUtils.openInputStream(items.get(0).getFile()); |