Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de231200 authored by Yiyi Shen's avatar Yiyi Shen
Browse files

Add FeatureProvider for FastPair Settings integration.

Bug: 296507968
Test: FakeFeatureFactory
Change-Id: Ie2e238cb61ca56a1d19e1a13b0234e28e28a785e
parent d32f590f
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
/*
 * 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) {
    }
}
+32 −0
Original line number Diff line number Diff line
/*
 * 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);
}
+33 −0
Original line number Diff line number Diff line
/*
 * 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() {
        };
    }
}
+7 −1
Original line number Diff line number Diff line
@@ -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

+6 −0
Original line number Diff line number Diff line
@@ -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()
    }
}
Loading