From 3db59a8430ad73e7d6bf1b3d4305409327f6cab4 Mon Sep 17 00:00:00 2001 From: jackqdyulei Date: Mon, 8 May 2017 15:29:14 -0700 Subject: [PATCH] Add feature provider for Bluetooth Also add method to check whether pairing page is enabled. Bug: 38134564 Test: RunSettingsGoogleRoboTests Change-Id: Ib74ece46f9624242895a366eac889957924f84c6 --- .../bluetooth/BluetoothFeatureProvider.java | 27 +++++++++++++++++++ .../BluetoothFeatureProviderImpl.java | 12 +++++++++ .../settings/overlay/FeatureFactory.java | 3 +++ .../settings/overlay/FeatureFactoryImpl.java | 11 ++++++++ .../testutils/FakeFeatureFactory.java | 9 +++++++ 5 files changed, 62 insertions(+) create mode 100644 src/com/android/settings/bluetooth/BluetoothFeatureProvider.java create mode 100644 src/com/android/settings/bluetooth/BluetoothFeatureProviderImpl.java diff --git a/src/com/android/settings/bluetooth/BluetoothFeatureProvider.java b/src/com/android/settings/bluetooth/BluetoothFeatureProvider.java new file mode 100644 index 00000000000..358223d55d8 --- /dev/null +++ b/src/com/android/settings/bluetooth/BluetoothFeatureProvider.java @@ -0,0 +1,27 @@ +/* + * 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.bluetooth; + +/** + * Feature provider for bluetooth feature + */ +public interface BluetoothFeatureProvider { + /** + * Check whether additional pairing page is enabled + */ + boolean isPairingPageEnabled(); +} diff --git a/src/com/android/settings/bluetooth/BluetoothFeatureProviderImpl.java b/src/com/android/settings/bluetooth/BluetoothFeatureProviderImpl.java new file mode 100644 index 00000000000..f5b65b767cf --- /dev/null +++ b/src/com/android/settings/bluetooth/BluetoothFeatureProviderImpl.java @@ -0,0 +1,12 @@ +package com.android.settings.bluetooth; + +/** + * Impl for bluetooth feature provider + */ +public class BluetoothFeatureProviderImpl implements BluetoothFeatureProvider { + + @Override + public boolean isPairingPageEnabled() { + return false; + } +} diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java index e7d50883803..6f1d35051d6 100644 --- a/src/com/android/settings/overlay/FeatureFactory.java +++ b/src/com/android/settings/overlay/FeatureFactory.java @@ -22,6 +22,7 @@ import android.util.Log; import com.android.settings.R; import com.android.settings.applications.ApplicationFeatureProvider; +import com.android.settings.bluetooth.BluetoothFeatureProvider; import com.android.settings.core.instrumentation.MetricsFeatureProvider; import com.android.settings.dashboard.DashboardFeatureProvider; import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider; @@ -97,6 +98,8 @@ public abstract class FeatureFactory { public abstract UserFeatureProvider getUserFeatureProvider(Context context); + public abstract BluetoothFeatureProvider getBluetoothFeatureProvider(Context context); + public static final class FactoryNotFoundException extends RuntimeException { public FactoryNotFoundException(Throwable throwable) { super("Unable to create factory. Did you misconfigure Proguard?", throwable); diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java index b39a2a096df..21b33c947d7 100644 --- a/src/com/android/settings/overlay/FeatureFactoryImpl.java +++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java @@ -27,6 +27,8 @@ import com.android.settings.applications.ApplicationFeatureProvider; import com.android.settings.applications.ApplicationFeatureProviderImpl; import com.android.settings.applications.IPackageManagerWrapperImpl; import com.android.settings.applications.PackageManagerWrapperImpl; +import com.android.settings.bluetooth.BluetoothFeatureProvider; +import com.android.settings.bluetooth.BluetoothFeatureProviderImpl; import com.android.settings.core.instrumentation.MetricsFeatureProvider; import com.android.settings.dashboard.DashboardFeatureProvider; import com.android.settings.dashboard.DashboardFeatureProviderImpl; @@ -66,6 +68,7 @@ public class FeatureFactoryImpl extends FeatureFactory { private PowerUsageFeatureProvider mPowerUsageFeatureProvider; private AssistGestureFeatureProvider mAssistGestureFeatureProvider; private UserFeatureProvider mUserFeatureProvider; + private BluetoothFeatureProvider mBluetoothFeatureProvider; @Override public SupportFeatureProvider getSupportFeatureProvider(Context context) { @@ -168,6 +171,14 @@ public class FeatureFactoryImpl extends FeatureFactory { return mUserFeatureProvider; } + @Override + public BluetoothFeatureProvider getBluetoothFeatureProvider(Context context) { + if (mBluetoothFeatureProvider == null) { + mBluetoothFeatureProvider = new BluetoothFeatureProviderImpl(); + } + return mBluetoothFeatureProvider; + } + @Override public AssistGestureFeatureProvider getAssistGestureFeatureProvider() { if (mAssistGestureFeatureProvider == null) { diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java index 68333e7f834..65bb3898073 100644 --- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java +++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java @@ -18,6 +18,7 @@ package com.android.settings.testutils; import android.content.Context; import com.android.settings.applications.ApplicationFeatureProvider; +import com.android.settings.bluetooth.BluetoothFeatureProvider; import com.android.settings.core.instrumentation.MetricsFeatureProvider; import com.android.settings.dashboard.DashboardFeatureProvider; import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider; @@ -34,6 +35,7 @@ import com.android.settings.users.UserFeatureProvider; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockingDetails; import static org.mockito.Mockito.when; /** @@ -55,6 +57,7 @@ public class FakeFeatureFactory extends FeatureFactory { public final SuggestionFeatureProvider suggestionsFeatureProvider; public final UserFeatureProvider userFeatureProvider; public final AssistGestureFeatureProvider assistGestureFeatureProvider; + public final BluetoothFeatureProvider bluetoothFeatureProvider; /** * Call this in {@code @Before} method of the test class to use fake factory. @@ -90,6 +93,7 @@ public class FakeFeatureFactory extends FeatureFactory { suggestionsFeatureProvider = mock(SuggestionFeatureProvider.class); userFeatureProvider = mock(UserFeatureProvider.class); assistGestureFeatureProvider = mock(AssistGestureFeatureProvider.class); + bluetoothFeatureProvider = mock(BluetoothFeatureProvider.class); } @Override @@ -152,6 +156,11 @@ public class FakeFeatureFactory extends FeatureFactory { return userFeatureProvider; } + @Override + public BluetoothFeatureProvider getBluetoothFeatureProvider(Context context) { + return bluetoothFeatureProvider; + } + @Override public AssistGestureFeatureProvider getAssistGestureFeatureProvider() { return assistGestureFeatureProvider;