diff options
author | Douglas Sigelbaum <sigelbaum@google.com> | 2017-11-26 23:12:16 -0500 |
---|---|---|
committer | Douglas Sigelbaum <sigelbaum@google.com> | 2017-12-12 11:34:11 -0800 |
commit | 25c564de28bb0e50797e3dd1160394b209fdeea2 (patch) | |
tree | 676ebf362ec6c0a215ade6401329e14bbd05ea60 /input | |
parent | 98d5568efdc834b440a8b6400c1124e6a094f73f (diff) | |
download | android-25c564de28bb0e50797e3dd1160394b209fdeea2.tar.gz |
Autofill sample: use string resources for failure messages.
Bug: 69772848
Test: manual
Change-Id: I6d7b029fc47b8c9d49c17698da7e18d72f6a783f
Diffstat (limited to 'input')
2 files changed, 9 insertions, 6 deletions
diff --git a/input/autofill/AutofillFramework/afservice/src/main/java/com/example/android/autofill/service/MyAutofillService.java b/input/autofill/AutofillFramework/afservice/src/main/java/com/example/android/autofill/service/MyAutofillService.java index 96d307f8..9e887496 100644 --- a/input/autofill/AutofillFramework/afservice/src/main/java/com/example/android/autofill/service/MyAutofillService.java +++ b/input/autofill/AutofillFramework/afservice/src/main/java/com/example/android/autofill/service/MyAutofillService.java @@ -61,6 +61,7 @@ import static com.example.android.autofill.service.util.Util.dumpStructure; import static com.example.android.autofill.service.util.Util.findNodeByFilter; import static com.example.android.autofill.service.util.Util.logVerboseEnabled; import static com.example.android.autofill.service.util.Util.logd; +import static com.example.android.autofill.service.util.Util.loge; import static com.example.android.autofill.service.util.Util.logv; import static com.example.android.autofill.service.util.Util.logw; @@ -152,7 +153,7 @@ public class MyAutofillService extends AutofillService { mClientViewMetadata = new ClientViewMetadata(parser); String packageName = structure.getActivityComponent().getPackageName(); if (!mPackageVerificationRepository.putPackageSignatures(packageName)) { - callback.onFailure(getApplicationContext().getString(R.string.invalid_package_signature)); + callback.onFailure(getString(R.string.invalid_package_signature)); return; } Bundle clientState = request.getClientState(); @@ -205,7 +206,7 @@ public class MyAutofillService extends AutofillService { webDomain = mClientViewMetadata.buildWebDomain(); } catch (SecurityException e) { logw(e.getMessage()); - callback.onFailure(e.getMessage()); + callback.onFailure(getString(R.string.security_exception)); return; } if (webDomain != null && webDomain.length() > 0) { @@ -217,16 +218,16 @@ public class MyAutofillService extends AutofillService { logd("Domain %s is valid for %s", webDomain, packageName); buildAndSaveAutofillData(); } else { - callback.onFailure(String.format( - "Could not associate web domain %s with app %s", webDomain, - packageName)); + loge("Could not associate web domain %s with app %s", + webDomain, packageName); + callback.onFailure(getString(R.string.dal_exception)); } } @Override public void onDataNotAvailable(String msg, Object... params) { logw(msg, params); - callback.onFailure(String.format(msg, params)); + callback.onFailure(getString(R.string.dal_exception)); } }); } else { diff --git a/input/autofill/AutofillFramework/afservice/src/main/res/values/strings.xml b/input/autofill/AutofillFramework/afservice/src/main/res/values/strings.xml index 9d41f97f..c6c646d7 100644 --- a/input/autofill/AutofillFramework/afservice/src/main/res/values/strings.xml +++ b/input/autofill/AutofillFramework/afservice/src/main/res/values/strings.xml @@ -1,5 +1,7 @@ <resources> <string name="invalid_package_signature">Invalid package signature</string> + <string name="security_exception">Web domain security exception.</string> + <string name="dal_exception">DAL verification failure.</string> <string name="autofill_sign_in_prompt">Tap to sign in.</string> <string name="authentication_name">Autofill Authentication</string> <string name="settings_name">Autofill Settings</string> |