diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java index 787fbfa6329..bab1d167df9 100644 --- a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java +++ b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java @@ -23,22 +23,22 @@ import android.provider.Settings; import android.text.TextUtils; import android.view.autofill.AutofillManager; -import com.android.settings.wrapper.AutofillManagerWrapper; import com.android.settingslib.applications.DefaultAppInfo; public class DefaultAutofillPreferenceController extends DefaultAppPreferenceController { - private AutofillManagerWrapper mAutofillManager; + + private final AutofillManager mAutofillManager; public DefaultAutofillPreferenceController(Context context) { super(context); - mAutofillManager = new AutofillManagerWrapper( - mContext.getSystemService(AutofillManager.class)); + mAutofillManager = mContext.getSystemService(AutofillManager.class); } @Override public boolean isAvailable() { - return mAutofillManager.hasAutofillFeature() + return mAutofillManager != null + && mAutofillManager.hasAutofillFeature() && mAutofillManager.isAutofillSupported(); } diff --git a/src/com/android/settings/wrapper/AutofillManagerWrapper.java b/src/com/android/settings/wrapper/AutofillManagerWrapper.java deleted file mode 100644 index 57c9375ec2d..00000000000 --- a/src/com/android/settings/wrapper/AutofillManagerWrapper.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.wrapper; - -import android.view.autofill.AutofillManager; - -/** - * This class replicates a subset of the android.view.autofill.AutofillManager (AFM). The - * class exists so that we can use a thin wrapper around the AFM in production code and a mock - * in tests. We cannot directly mock or shadow the AFM, because some of the methods we rely on are - * newer than the API version supported by Robolectric. - */ -public class AutofillManagerWrapper { - private final AutofillManager mAfm; - - public AutofillManagerWrapper(AutofillManager afm) { - mAfm = afm; - } - - /** - * Calls {@code AutofillManager.hasAutofillFeature()}. - * - * @see AutofillManager#hasAutofillFeature - */ - public boolean hasAutofillFeature() { - if (mAfm == null) { - return false; - } - - return mAfm.hasAutofillFeature(); - } - - /** - * Calls {@code AutofillManager.isAutofillSupported()}. - * - * @see AutofillManager#isAutofillSupported - */ - public boolean isAutofillSupported() { - if (mAfm == null) { - return false; - } - - return mAfm.isAutofillSupported(); - } -} 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 24c7418aecd..289fc469f21 100644 --- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceControllerTest.java @@ -30,8 +30,6 @@ import android.view.autofill.AutofillManager; import com.android.settings.R; import com.android.settings.testutils.SettingsRobolectricTestRunner; -import com.android.settings.wrapper.AutofillManagerWrapper; -import com.android.settingslib.applications.DefaultAppInfo; import com.android.settingslib.wrapper.PackageManagerWrapper; import org.junit.Before; @@ -53,7 +51,7 @@ public class DefaultAutofillPreferenceControllerTest { @Mock(answer = Answers.RETURNS_DEEP_STUBS) private PackageManagerWrapper mPackageManager; @Mock - private AutofillManagerWrapper mAutofillManager; + private AutofillManager mAutofillManager; private DefaultAutofillPreferenceController mController;