From c21cfe9ea21d72a658c68954b3ddc99d7fff9cab Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Sun, 4 Feb 2018 21:22:00 -0800 Subject: [PATCH] Autofill compat - Settings Test: manully can change autofill serivces Update settings due to API signature change. Change-Id: Idaf00fdbe7cb07cb174f3bbd8edcfa95ac734764 --- .../defaultapps/DefaultAutofillPicker.java | 10 +++++----- .../DefaultAutofillPreferenceController.java | 2 +- .../DefaultAutofillPreferenceControllerTest.java | 5 ----- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java b/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java index 97f6d4bec5e..d116f91d601 100644 --- a/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java +++ b/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java @@ -251,16 +251,16 @@ public class DefaultAutofillPicker extends DefaultAppPickerFragment { static final class AutofillSettingIntentProvider implements SettingIntentProvider { private final String mSelectedKey; - private final PackageManager mPackageManager; + private final Context mContext; - public AutofillSettingIntentProvider(PackageManager packageManager, String key) { + public AutofillSettingIntentProvider(Context context, String key) { mSelectedKey = key; - mPackageManager = packageManager; + mContext = context; } @Override public Intent getIntent() { - final List resolveInfos = mPackageManager.queryIntentServices( + final List resolveInfos = mContext.getPackageManager().queryIntentServices( AUTOFILL_PROBE, PackageManager.GET_META_DATA); for (ResolveInfo resolveInfo : resolveInfos) { @@ -270,7 +270,7 @@ public class DefaultAutofillPicker extends DefaultAppPickerFragment { if (TextUtils.equals(mSelectedKey, flattenKey)) { final String settingsActivity; try { - settingsActivity = new AutofillServiceInfo(mPackageManager, serviceInfo) + settingsActivity = new AutofillServiceInfo(mContext, serviceInfo) .getSettingsActivity(); } catch (SecurityException e) { // Service does not declare the proper permission, ignore it. diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java index 508cc63cfc3..b159d1dbd8c 100644 --- a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java +++ b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java @@ -53,7 +53,7 @@ public class DefaultAutofillPreferenceController extends DefaultAppPreferenceCon } final DefaultAutofillPicker.AutofillSettingIntentProvider intentProvider = new DefaultAutofillPicker.AutofillSettingIntentProvider( - mPackageManager.getPackageManager(), info.getKey()); + mContext, info.getKey()); return intentProvider.getIntent(); } diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java index bc72ee4ee3f..4e8a79efa9e 100644 --- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java @@ -104,10 +104,5 @@ public class DefaultAutofillPreferenceControllerTest { final DefaultAppInfo info = mController.getDefaultAppInfo(); assertThat(info).isNotNull(); - - mController.getSettingIntent(info); - - verify(mPackageManager.getPackageManager()).queryIntentServices( - DefaultAutofillPicker.AUTOFILL_PROBE, PackageManager.GET_META_DATA); } }