Add FeatureProvider for FastPair Settings integration.
Bug: 296507968 Test: FakeFeatureFactory Change-Id: Ie2e238cb61ca56a1d19e1a13b0234e28e28a785e
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.connecteddevice.fastpair;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Updates the Fast Pair devices. It notifies the upper level whether to add/remove the
|
||||
* preference through {@link DevicePreferenceCallback}
|
||||
*/
|
||||
public interface FastPairDeviceUpdater {
|
||||
|
||||
/**
|
||||
* Registers the Fast Pair event callback and update the list
|
||||
*/
|
||||
default void registerCallback() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters the Fast Pair event callback
|
||||
*/
|
||||
default void unregisterCallback() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces to update the list of Fast Pair devices
|
||||
*/
|
||||
default void forceUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context to generate the {@link Preference}, so it could get the correct theme.
|
||||
*/
|
||||
default void setPreferenceContext(@NonNull Context preferenceContext) {
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.connecteddevice.fastpair;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||
|
||||
/**
|
||||
* Feature provider for the Fast Pair device updater.
|
||||
*/
|
||||
public interface FastPairFeatureProvider {
|
||||
/**
|
||||
* Returns the FastPairDeviceUpdater of the account associated Fast Pair device
|
||||
*/
|
||||
FastPairDeviceUpdater getFastPairDeviceUpdater(
|
||||
Context context, DevicePreferenceCallback devicePreferenceCallback);
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.connecteddevice.fastpair;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||
|
||||
/**
|
||||
* Default implementation for {@link FastPairFeatureProvider}
|
||||
*/
|
||||
public class FastPairFeatureProviderImpl implements FastPairFeatureProvider {
|
||||
@Override
|
||||
public FastPairDeviceUpdater getFastPairDeviceUpdater(
|
||||
Context context, DevicePreferenceCallback devicePreferenceCallback) {
|
||||
return new FastPairDeviceUpdater() {
|
||||
};
|
||||
}
|
||||
}
|
@@ -23,8 +23,8 @@ import com.android.settings.applications.ApplicationFeatureProvider
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider
|
||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider
|
||||
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
|
||||
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider
|
||||
import com.android.settings.onboarding.OnboardingFeatureProvider
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider
|
||||
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProvider
|
||||
@@ -35,6 +35,7 @@ import com.android.settings.fuelgauge.PowerUsageFeatureProvider
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider
|
||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider
|
||||
import com.android.settings.localepicker.LocaleFeatureProvider
|
||||
import com.android.settings.onboarding.OnboardingFeatureProvider
|
||||
import com.android.settings.overlay.FeatureFactory.Companion.setFactory
|
||||
import com.android.settings.panel.PanelFeatureProvider
|
||||
import com.android.settings.search.SearchFeatureProvider
|
||||
@@ -155,6 +156,11 @@ abstract class FeatureFactory {
|
||||
*/
|
||||
open val onboardingFeatureProvider: OnboardingFeatureProvider? = null
|
||||
|
||||
/**
|
||||
* Gets implementation for Fast Pair device updater provider.
|
||||
*/
|
||||
abstract val fastPairFeatureProvider: FastPairFeatureProvider
|
||||
|
||||
companion object {
|
||||
private var _factory: FeatureFactory? = null
|
||||
|
||||
|
@@ -33,6 +33,8 @@ import com.android.settings.biometrics2.factory.BiometricsRepositoryProviderImpl
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProviderImpl
|
||||
import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl
|
||||
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
|
||||
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProviderImpl
|
||||
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider
|
||||
import com.android.settings.connecteddevice.stylus.StylusFeatureProviderImpl
|
||||
import com.android.settings.core.instrumentation.SettingsMetricsFeatureProvider
|
||||
@@ -172,4 +174,8 @@ open class FeatureFactoryImpl : FeatureFactory() {
|
||||
override val stylusFeatureProvider: StylusFeatureProvider by lazy {
|
||||
StylusFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val fastPairFeatureProvider: FastPairFeatureProvider by lazy {
|
||||
FastPairFeatureProviderImpl()
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider;
|
||||
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||
@@ -95,6 +96,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public KeyboardSettingsFeatureProvider mKeyboardSettingsFeatureProvider;
|
||||
public StylusFeatureProvider mStylusFeatureProvider;
|
||||
public OnboardingFeatureProvider mOnboardingFeatureProvider;
|
||||
public FastPairFeatureProvider mFastPairFeatureProvider;
|
||||
|
||||
/**
|
||||
* Call this in {@code @Before} method of the test class to use fake factory.
|
||||
@@ -140,6 +142,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
mKeyboardSettingsFeatureProvider = mock(KeyboardSettingsFeatureProvider.class);
|
||||
mStylusFeatureProvider = mock(StylusFeatureProvider.class);
|
||||
mOnboardingFeatureProvider = mock(OnboardingFeatureProvider.class);
|
||||
mFastPairFeatureProvider = mock(FastPairFeatureProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -307,4 +310,10 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public OnboardingFeatureProvider getOnboardingFeatureProvider() {
|
||||
return mOnboardingFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FastPairFeatureProvider getFastPairFeatureProvider() {
|
||||
return mFastPairFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ import com.android.settings.applications.ApplicationFeatureProvider
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider
|
||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider
|
||||
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
|
||||
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider
|
||||
@@ -137,4 +138,6 @@ class FakeFeatureFactory : FeatureFactory() {
|
||||
get() = TODO("Not yet implemented")
|
||||
override val stylusFeatureProvider: StylusFeatureProvider
|
||||
get() = TODO("Not yet implemented")
|
||||
override val fastPairFeatureProvider: FastPairFeatureProvider
|
||||
get() = TODO("Not yet implemented")
|
||||
}
|
||||
|
@@ -23,10 +23,10 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider;
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.onboarding.OnboardingFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider;
|
||||
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||
@@ -39,6 +39,7 @@ import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
|
||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider;
|
||||
import com.android.settings.localepicker.LocaleFeatureProvider;
|
||||
import com.android.settings.onboarding.OnboardingFeatureProvider;
|
||||
import com.android.settings.overlay.DockUpdaterFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.overlay.SupportFeatureProvider;
|
||||
@@ -94,6 +95,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public KeyboardSettingsFeatureProvider mKeyboardSettingsFeatureProvider;
|
||||
public StylusFeatureProvider mStylusFeatureProvider;
|
||||
public OnboardingFeatureProvider mOnboardingFeatureProvider;
|
||||
public FastPairFeatureProvider mFastPairFeatureProvider;
|
||||
|
||||
/**
|
||||
* Call this in {@code @Before} method of the test class to use fake factory.
|
||||
@@ -104,9 +106,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* FeatureFactory constructor.
|
||||
*/
|
||||
/**
|
||||
* FeatureFactory constructor.
|
||||
*/
|
||||
public FakeFeatureFactory() {
|
||||
supportFeatureProvider = mock(SupportFeatureProvider.class);
|
||||
metricsFeatureProvider = mock(MetricsFeatureProvider.class);
|
||||
@@ -139,6 +141,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
mKeyboardSettingsFeatureProvider = mock(KeyboardSettingsFeatureProvider.class);
|
||||
mStylusFeatureProvider = mock(StylusFeatureProvider.class);
|
||||
mOnboardingFeatureProvider = mock(OnboardingFeatureProvider.class);
|
||||
mFastPairFeatureProvider = mock(FastPairFeatureProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -306,4 +309,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public OnboardingFeatureProvider getOnboardingFeatureProvider() {
|
||||
return mOnboardingFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FastPairFeatureProvider getFastPairFeatureProvider() {
|
||||
return mFastPairFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user