aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
diff options
context:
space:
mode:
authorMatthew Wong <wongma@protonmail.ch>2015-08-09 16:04:09 -0400
committerMatthew Wong <wongma@protonmail.ch>2015-08-14 17:36:48 -0400
commitad173d9d05c29790d6f647df641e5de28e32fd58 (patch)
tree4cbf4579d39392c2d647459eec10ff7f95466a7e /app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
parent51a05087e5a349afa3f4e0febdc3a339179e9bbd (diff)
downloadHardenedPass-ad173d9d05c29790d6f647df641e5de28e32fd58.tar.gz
HardenedPass-ad173d9d05c29790d6f647df641e5de28e32fd58.zip
Autofill per-app settings dialog opens on click on suggestion or on existing app
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java15
1 files changed, 13 insertions, 2 deletions
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 f3108733..dbd018b6 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java
@@ -68,9 +68,13 @@ public class AutofillService extends AccessibilityService {
&& event.getPackageName().equals(packageName) && unlockOK) {
decryptAndVerify();
}
+
+ // nothing to do if not password field focus, android version, or field is keychain app
if (!event.isPassword()
|| Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2
|| event.getPackageName().equals("org.sufficientlysecure.keychain")) {
+ // dismiss dialog if WINDOW_STATE_CHANGED unless the keyboard caused it
+ // there may be other exceptions...
if (!(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
&& event.getPackageName().toString().contains("com.android.inputmethod"))
&& dialog != null && dialog.isShowing()) {
@@ -78,14 +82,19 @@ public class AutofillService extends AccessibilityService {
}
return;
}
+
+ // if past this point, a new dialog will be created, so dismiss the existing
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
+
// ignore the ACTION_FOCUS from decryptAndVerify
if (ignoreActionFocus) {
ignoreActionFocus = false;
return;
}
+
+ // get the app name and find a corresponding password
info = event.getSource();
PackageManager packageManager = getPackageManager();
ApplicationInfo applicationInfo;
@@ -109,7 +118,7 @@ public class AutofillService extends AccessibilityService {
decryptAndVerify();
}
});
- builder.setNeutralButton("Match", new DialogInterface.OnClickListener() {
+ builder.setNeutralButton("Settings", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@@ -121,7 +130,7 @@ public class AutofillService extends AccessibilityService {
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
}
- dialog.setTitle(items.get(0).getName());
+ dialog.setTitle(items.get(0).toString());
dialog.show();
dialog.getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
}
@@ -202,6 +211,7 @@ public class AutofillService extends AccessibilityService {
case OpenPgpApi.RESULT_CODE_SUCCESS: {
try {
String[] passContent = os.toString("UTF-8").split("\n");
+
// if the user focused on something else, take focus back
// but this will open another dialog...hack to ignore this
ignoreActionFocus = info.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
@@ -215,6 +225,7 @@ public class AutofillService extends AccessibilityService {
ClipData clip = ClipData.newPlainText("autofill_pm", passContent[0]);
clipboard.setPrimaryClip(clip);
info.performAction(AccessibilityNodeInfo.ACTION_PASTE);
+
clip = ClipData.newPlainText("autofill_pm", "MyPasswordIsDaBest!");
clipboard.setPrimaryClip(clip);
if (settings.getBoolean("clear_clipboard_20x", false)) {