From f8f55e574dbf03688d5d9b28bed0dd3802167fe5 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Wed, 8 Feb 2017 16:16:14 -0800 Subject: [PATCH] Convert auto-fill default selector to full screen pattern. Bug: 34280137 Test: RunSettingsRoboTests Change-Id: Icde3bcaf11615010d481f39d8b32d28dfc120018 --- res/xml/app_default_settings.xml | 23 +-- .../AppListPreferenceWithSettings.java | 1 + .../applications/AdvancedAppSettings.java | 2 + .../DefaultAutoFillPreference.java | 135 ------------------ .../defaultapps/DefaultAppPickerFragment.java | 8 +- .../DefaultAppPreferenceController.java | 25 ++++ .../defaultapps/DefaultAutoFillPicker.java | 119 +++++++++++++++ .../DefaultAutoFillPreferenceController.java | 63 ++++++++ .../defaultapps/SettingIntentProvider.java | 28 ++++ .../settings/widget/GearPreference.java | 8 +- .../DefaultAppPreferenceControllerTest.java | 4 +- .../DefaultAutoFillPickerTest.java | 86 +++++++++++ ...faultAutoFillPreferenceControllerTest.java | 96 +++++++++++++ .../defaultapps/DefaultBrowserPickerTest.java | 3 - ...efaultBrowserPreferenceControllerTest.java | 3 +- 15 files changed, 446 insertions(+), 158 deletions(-) delete mode 100644 src/com/android/settings/applications/DefaultAutoFillPreference.java create mode 100644 src/com/android/settings/applications/defaultapps/DefaultAutoFillPicker.java create mode 100644 src/com/android/settings/applications/defaultapps/DefaultAutoFillPreferenceController.java create mode 100644 src/com/android/settings/applications/defaultapps/SettingIntentProvider.java create mode 100644 tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutoFillPickerTest.java create mode 100644 tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutoFillPreferenceControllerTest.java diff --git a/res/xml/app_default_settings.xml b/res/xml/app_default_settings.xml index b99051d187f..90621d7d331 100644 --- a/res/xml/app_default_settings.xml +++ b/res/xml/app_default_settings.xml @@ -26,19 +26,12 @@ android:fragment="com.android.settings.applications.ManageAssist" android:order="-20"/> - - + android:order="-19"> @@ -48,26 +41,34 @@ android:summary="@string/no_default_home" android:fragment="com.android.settings.applications.defaultapps.DefaultHomePicker" settings:keywords="@string/keywords_home" - android:order="-17"/> + android:order="-18"/> + android:order="-17"/> + android:order="-16"/> + + = entries.length) { - return null; - } - - CharSequence entry = entries[index]; - return getContext().getString(R.string.autofill_confirmation_message, entry); - } - - @Override - protected boolean persistString(String value) { - Settings.Secure.putString(getContext().getContentResolver(), SETTING, value); - refreshData(); - return true; - } - - private void refreshData() { - ComponentName selectedComponent = getSelectedComponentName(); - List infos = getInfos(); - - AutoFillServiceInfo selectedInfo = null; - int numberOfComponents = infos.size(); - ComponentName[] components = new ComponentName[numberOfComponents]; - for (int i = 0; i < numberOfComponents; ++i) { - AutoFillServiceInfo info = infos.get(i); - ServiceInfo serviceInfo = info.getServiceInfo(); - ComponentName component = - new ComponentName(serviceInfo.packageName, serviceInfo.name); - components[i] = component; - - if (component.equals(selectedComponent)) { - selectedInfo = info; - } - } - - ComponentName selectedComponentSettings = null; - if (selectedInfo != null) { - String settingsActivity = selectedInfo.getSettingsActivity(); - selectedComponentSettings = settingsActivity != null - ? new ComponentName(selectedComponent.getPackageName(), settingsActivity) - : null; - } else { // selected component not found - Log.w(TAG, "Selected AutoFillService not found " + selectedComponent); - selectedComponent = null; - selectedComponentSettings = null; - } - - setComponentNames(components, selectedComponent); - setSettingsComponent(selectedComponentSettings); - setSummary(getEntry()); - } - - @Nullable - private ComponentName getSelectedComponentName() { - String componentString = - Settings.Secure.getString(getContext().getContentResolver(), SETTING); - if (componentString == null) { - return null; - } - - return ComponentName.unflattenFromString(componentString); - } - - private List getInfos() { - PackageManager pm = getContext().getPackageManager(); - List resolveInfos = pm.queryIntentServices( - new Intent(AutoFillService.SERVICE_INTERFACE), - PackageManager.GET_META_DATA); - List infos = new ArrayList<>(resolveInfos.size()); - for (ResolveInfo resolveInfo : resolveInfos) { - ServiceInfo serviceInfo = resolveInfo.serviceInfo; - AutoFillServiceInfo info = new AutoFillServiceInfo(pm, serviceInfo); - infos.add(info); - } - return infos; - } -} diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java b/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java index 0588af89d7b..358b5f4d1c7 100644 --- a/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java +++ b/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java @@ -118,15 +118,17 @@ public abstract class DefaultAppPickerFragment extends InstrumentedPreferenceFra for (Map.Entry app : mCandidates.entrySet()) { final RadioButtonPreference pref = new RadioButtonPreference(getPrefContext()); final String appKey = app.getKey(); - - pref.setTitle(app.getValue().loadLabel(mPm.getPackageManager())); - pref.setIcon(app.getValue().loadIcon(mPm.getPackageManager())); + final DefaultAppInfo info = app.getValue(); + pref.setTitle(info.loadLabel(mPm.getPackageManager())); + pref.setIcon(info.loadIcon(mPm.getPackageManager())); pref.setKey(appKey); if (TextUtils.equals(defaultAppKey, appKey)) { pref.setChecked(true); } if (TextUtils.equals(systemDefaultAppKey, appKey)) { pref.setSummary(R.string.system_app); + } else if (!TextUtils.isEmpty(info.summary)) { + pref.setSummary(info.summary); } if (!TextUtils.isEmpty(app.getValue().disabledDescription)) { pref.setEnabled(false); diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java index a9433ac733a..d8fb2257753 100644 --- a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java +++ b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java @@ -17,6 +17,7 @@ package com.android.settings.applications.defaultapps; import android.content.Context; +import android.content.Intent; import android.os.UserHandle; import android.os.UserManager; import android.support.v7.preference.Preference; @@ -26,6 +27,7 @@ import android.util.Log; import com.android.settings.applications.PackageManagerWrapper; import com.android.settings.applications.PackageManagerWrapperImpl; import com.android.settings.core.PreferenceController; +import com.android.settings.widget.GearPreference; public abstract class DefaultAppPreferenceController extends PreferenceController { @@ -54,8 +56,31 @@ public abstract class DefaultAppPreferenceController extends PreferenceControlle preference.setSummary(defaultAppLabel); } else { Log.d(TAG, "No default app"); + preference.setSummary(null); + } + mayUpdateGearIcon(app, preference); + } + + private void mayUpdateGearIcon(DefaultAppInfo app, Preference preference) { + if (!(preference instanceof GearPreference)) { + return; + } + final Intent settingIntent = getSettingIntent(app); + if (settingIntent != null) { + ((GearPreference) preference).setOnGearClickListener( + p -> mContext.startActivity(settingIntent)); + } else { + ((GearPreference) preference).setOnGearClickListener(null); } } protected abstract DefaultAppInfo getDefaultAppInfo(); + + /** + * Returns an optional intent that will be launched when clicking "gear" icon. + */ + protected Intent getSettingIntent(DefaultAppInfo info) { + //By default return null. It's up to subclasses to provide logic. + return null; + } } diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutoFillPicker.java b/src/com/android/settings/applications/defaultapps/DefaultAutoFillPicker.java new file mode 100644 index 00000000000..5b9fed4ce57 --- /dev/null +++ b/src/com/android/settings/applications/defaultapps/DefaultAutoFillPicker.java @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.applications.defaultapps; + +import android.content.ComponentName; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.content.pm.ServiceInfo; +import android.provider.Settings; +import android.service.autofill.AutoFillService; +import android.service.autofill.AutoFillServiceInfo; +import android.text.TextUtils; + +import com.android.internal.logging.nano.MetricsProto; +import com.android.settings.R; + +import java.util.ArrayList; +import java.util.List; + +public class DefaultAutoFillPicker extends DefaultAppPickerFragment { + + static final String SETTING = Settings.Secure.AUTO_FILL_SERVICE; + static final Intent AUTO_FILL_PROBE = new Intent(AutoFillService.SERVICE_INTERFACE); + + @Override + public int getMetricsCategory() { + return MetricsProto.MetricsEvent.DEFAULT_AUTOFILL_PICKER; + } + + @Override + protected boolean shouldShowItemNone() { + return true; + } + + @Override + protected List getCandidates() { + final List candidates = new ArrayList<>(); + final List resolveInfos = mPm.getPackageManager() + .queryIntentServices(AUTO_FILL_PROBE, PackageManager.GET_META_DATA); + for (ResolveInfo info : resolveInfos) { + candidates.add(new DefaultAppInfo(mUserId, new ComponentName( + info.serviceInfo.packageName, info.serviceInfo.name), null /* summary */)); + } + return candidates; + } + + @Override + protected String getDefaultAppKey() { + return Settings.Secure.getString(getContext().getContentResolver(), SETTING); + } + + @Override + protected String getConfirmationMessage(DefaultAppInfo appInfo) { + if (appInfo == null) { + return null; + } + final CharSequence appName = appInfo.loadLabel(mPm.getPackageManager()); + return getContext().getString(R.string.autofill_confirmation_message, appName); + } + + @Override + protected boolean setDefaultAppKey(String key) { + Settings.Secure.putString(getContext().getContentResolver(), SETTING, key); + return true; + } + + /** + * Provides Intent to setting activity for the specified auto-fill service. + */ + static final class AutoFillSettingIntentProvider + implements SettingIntentProvider { + + private final String mSelectedKey; + private final PackageManager mPackageManager; + + public AutoFillSettingIntentProvider(PackageManager packageManager, String key) { + mSelectedKey = key; + mPackageManager = packageManager; + } + + @Override + public Intent getIntent() { + final List resolveInfos = mPackageManager.queryIntentServices( + AUTO_FILL_PROBE, PackageManager.GET_META_DATA); + + for (ResolveInfo resolveInfo : resolveInfos) { + final ServiceInfo serviceInfo = resolveInfo.serviceInfo; + final String flattenKey = new ComponentName( + serviceInfo.packageName, serviceInfo.name).flattenToString(); + if (TextUtils.equals(mSelectedKey, flattenKey)) { + final String settingsActivity = new AutoFillServiceInfo( + mPackageManager, serviceInfo) + .getSettingsActivity(); + if (TextUtils.isEmpty(settingsActivity)) { + return null; + } + return new Intent(Intent.ACTION_MAIN).setComponent( + new ComponentName(serviceInfo.packageName, settingsActivity)); + } + } + return null; + } + } +} diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutoFillPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAutoFillPreferenceController.java new file mode 100644 index 00000000000..35e4ade09c4 --- /dev/null +++ b/src/com/android/settings/applications/defaultapps/DefaultAutoFillPreferenceController.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.applications.defaultapps; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.provider.Settings; +import android.text.TextUtils; + +public class DefaultAutoFillPreferenceController extends DefaultAppPreferenceController { + + public DefaultAutoFillPreferenceController(Context context) { + super(context); + } + + @Override + public boolean isAvailable() { + return true; + } + + @Override + public String getPreferenceKey() { + return "default_autofill"; + } + + @Override + protected Intent getSettingIntent(DefaultAppInfo info) { + if (info == null) { + return null; + } + final DefaultAutoFillPicker.AutoFillSettingIntentProvider intentProvider = + new DefaultAutoFillPicker.AutoFillSettingIntentProvider( + mPackageManager.getPackageManager(), info.getKey()); + return intentProvider.getIntent(); + } + + @Override + protected DefaultAppInfo getDefaultAppInfo() { + final String flattenComponent = Settings.Secure.getString(mContext.getContentResolver(), + DefaultAutoFillPicker.SETTING); + if (!TextUtils.isEmpty(flattenComponent)) { + DefaultAppInfo appInfo = new DefaultAppInfo( + mUserId, ComponentName.unflattenFromString(flattenComponent), null /*summary*/); + return appInfo; + } + return null; + } +} diff --git a/src/com/android/settings/applications/defaultapps/SettingIntentProvider.java b/src/com/android/settings/applications/defaultapps/SettingIntentProvider.java new file mode 100644 index 00000000000..a6e3edf78e9 --- /dev/null +++ b/src/com/android/settings/applications/defaultapps/SettingIntentProvider.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.applications.defaultapps; + +import android.annotation.Nullable; +import android.content.Intent; + +/** + * Provides an "advanced setting" intent for this app info. + */ +interface SettingIntentProvider { + @Nullable + Intent getIntent(); +} diff --git a/src/com/android/settings/widget/GearPreference.java b/src/com/android/settings/widget/GearPreference.java index c46f4a355b5..7659f0ff5d9 100644 --- a/src/com/android/settings/widget/GearPreference.java +++ b/src/com/android/settings/widget/GearPreference.java @@ -45,7 +45,13 @@ public class GearPreference extends RestrictedPreference implements View.OnClick public void onBindViewHolder(PreferenceViewHolder holder) { super.onBindViewHolder(holder); final View gear = holder.findViewById(R.id.settings_button); - gear.setOnClickListener(this); + if (mOnGearClickListener != null) { + gear.setVisibility(View.VISIBLE); + gear.setOnClickListener(this); + } else { + gear.setVisibility(View.GONE); + gear.setOnClickListener(null); + } gear.setEnabled(true); // Make gear available even if the preference itself is disabled. } diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java index f8d4d12ce34..550addb68ca 100644 --- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java @@ -32,9 +32,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.annotation.Config; -import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -77,7 +75,7 @@ public class DefaultAppPreferenceControllerTest { mController.updateState(mPreference); - verify(mPreference, never()).setSummary(any(CharSequence.class)); + verify(mPreference).setSummary(null); } private static class TestPreferenceController extends DefaultAppPreferenceController { diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutoFillPickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutoFillPickerTest.java new file mode 100644 index 00000000000..f2cf729833f --- /dev/null +++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutoFillPickerTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.applications.defaultapps; + +import android.app.Activity; +import android.content.Context; +import android.content.pm.PackageManager; +import android.os.UserManager; + +import com.android.settings.SettingsRobolectricTestRunner; +import com.android.settings.TestConfig; +import com.android.settings.applications.PackageManagerWrapper; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Answers; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; +import org.robolectric.util.ReflectionHelpers; + +import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + + +@RunWith(SettingsRobolectricTestRunner.class) +@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) +public class DefaultAutoFillPickerTest { + + private static final String TEST_APP_KEY = "123"; + + @Mock(answer = Answers.RETURNS_DEEP_STUBS) + private Activity mActivity; + @Mock + private UserManager mUserManager; + @Mock + private PackageManagerWrapper mPackageManager; + private DefaultAutoFillPicker mPicker; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager); + mPicker = spy(new DefaultAutoFillPicker()); + mPicker.onAttach((Context) mActivity); + + ReflectionHelpers.setField(mPicker, "mPm", mPackageManager); + + doReturn(RuntimeEnvironment.application).when(mPicker).getContext(); + } + + @Test + public void setAndGetDefaultAppKey_shouldUpdateDefaultAutoFill() { + assertThat(mPicker.setDefaultAppKey(TEST_APP_KEY)).isTrue(); + assertThat(mPicker.getDefaultAppKey()).isEqualTo(TEST_APP_KEY); + } + + @Test + public void getConfirmationMessage_shouldNotBeNull() { + final DefaultAppInfo info = mock(DefaultAppInfo.class); + when(info.loadLabel(any(PackageManager.class))).thenReturn("test_app_name"); + assertThat(mPicker.getConfirmationMessage(info)).isNotNull(); + } + + +} diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutoFillPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutoFillPreferenceControllerTest.java new file mode 100644 index 00000000000..1c373682cf8 --- /dev/null +++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutoFillPreferenceControllerTest.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.applications.defaultapps; + + +import android.content.Context; +import android.content.pm.PackageManager; +import android.os.UserManager; +import android.provider.Settings; +import android.support.v7.preference.Preference; + +import com.android.settings.SettingsRobolectricTestRunner; +import com.android.settings.TestConfig; +import com.android.settings.applications.PackageManagerWrapper; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Answers; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; +import org.robolectric.util.ReflectionHelpers; + +import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@RunWith(SettingsRobolectricTestRunner.class) +@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) +public class DefaultAutoFillPreferenceControllerTest { + + @Mock + private Context mContext; + @Mock + private UserManager mUserManager; + @Mock(answer = Answers.RETURNS_DEEP_STUBS) + private PackageManagerWrapper mPackageManager; + + private DefaultAutoFillPreferenceController mController; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager); + + mController = spy(new DefaultAutoFillPreferenceController(mContext)); + ReflectionHelpers.setField(mController, "mPackageManager", mPackageManager); + } + + @Test + public void isAlwaysAvailable() { + assertThat(mController.isAvailable()).isTrue(); + } + + @Test + public void updateState_hasNoApp_shouldNotReturnLabel() { + final Preference pref = mock(Preference.class); + + mController.updateState(pref); + verify(pref).setSummary(null); + } + + @Test + public void getDefaultAppInfo_shouldHaveSettingsProvider() { + ReflectionHelpers.setField(mController, "mContext", RuntimeEnvironment.application); + Settings.Secure.putString(RuntimeEnvironment.application.getContentResolver(), + DefaultAutoFillPicker.SETTING, "com.android.settings/SettingsActivity.class"); + + final DefaultAppInfo info = mController.getDefaultAppInfo(); + + assertThat(info).isNotNull(); + + mController.getSettingIntent(info); + + verify(mPackageManager.getPackageManager()).queryIntentServices( + DefaultAutoFillPicker.AUTO_FILL_PROBE, PackageManager.GET_META_DATA); + } +} diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPickerTest.java index e7b11d96488..b0231f8fb31 100644 --- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPickerTest.java +++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPickerTest.java @@ -20,7 +20,6 @@ package com.android.settings.applications.defaultapps; import android.app.Activity; import android.content.Context; import android.os.UserManager; -import android.provider.Settings; import com.android.settings.SettingsRobolectricTestRunner; import com.android.settings.TestConfig; @@ -32,11 +31,9 @@ import org.junit.runner.RunWith; import org.mockito.Answers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.util.ReflectionHelpers; -import static com.google.common.truth.Truth.assertThat; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java index e06dfee8edc..2f5602fdbc1 100644 --- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceControllerTest.java @@ -39,7 +39,6 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -77,7 +76,7 @@ public class DefaultBrowserPreferenceControllerTest { final Preference pref = mock(Preference.class); mController.updateState(pref); - verify(pref, never()).setSummary(any(String.class)); + verify(pref).setSummary(null); } @Test