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

Commit 2b72e413 authored by Kangping Dong's avatar Kangping Dong Committed by Android (Google) Code Review
Browse files

Merge "[Thread] support customizing Thread UI visibility" into main

parents ee4691f1 04e621d6
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.threadnetwork

/** Feature provider for the Thread network settings UI. */
interface ThreadNetworkFeatureProvider {
    /**
     * Returns the default / fallback Thread UI visibility state when DeviceConfig value is not
     * available.
     *
     * OEMs may set a different value to hide the Thread UI
     */
    fun isThreadVisible(): Boolean
}
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.threadnetwork

/** Feature provider for the Thread network settings UI. */
class ThreadNetworkFeatureProviderImpl : ThreadNetworkFeatureProvider {
override fun isThreadVisible() = true
}
+5 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import androidx.preference.PreferenceScreen
import com.android.settings.R
import com.android.settings.core.BasePreferenceController
import com.android.settings.flags.Flags
import com.android.settings.overlay.FeatureFactory
import java.util.concurrent.Executor

/**
@@ -57,7 +58,9 @@ class ThreadNetworkFragmentController @VisibleForTesting constructor(
    }

    override fun getAvailabilityStatus(): Int {
        return if (!Flags.threadSettingsEnabled()) {
        val featureProvider = FeatureFactory.featureFactory.threadNetworkFeatureProvider

        return if (!Flags.threadSettingsEnabled() || !featureProvider.isThreadVisible()) {
            CONDITIONALLY_UNAVAILABLE
        } else if (threadController == null) {
            UNSUPPORTED_ON_DEVICE
@@ -80,7 +83,7 @@ class ThreadNetworkFragmentController @VisibleForTesting constructor(
    }

    override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
        if (threadController == null) {
        if (threadController == null || availabilityStatus != AVAILABLE) {
            return
        }

+6 −3
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import androidx.preference.PreferenceScreen
import com.android.settings.R
import com.android.settings.core.TogglePreferenceController
import com.android.settings.flags.Flags
import com.android.settings.overlay.FeatureFactory
import java.util.concurrent.Executor

/**
@@ -72,7 +73,9 @@ class ThreadNetworkToggleController @VisibleForTesting constructor(
    }

    override fun getAvailabilityStatus(): Int {
        return if (!Flags.threadSettingsEnabled()) {
        val featureProvider = FeatureFactory.featureFactory.threadNetworkFeatureProvider

        return if (!Flags.threadSettingsEnabled() || !featureProvider.isThreadVisible()) {
            CONDITIONALLY_UNAVAILABLE
        } else if (!isThreadSupportedOnDevice) {
            UNSUPPORTED_ON_DEVICE
@@ -91,7 +94,7 @@ class ThreadNetworkToggleController @VisibleForTesting constructor(
    }

    override fun setChecked(isChecked: Boolean): Boolean {
        if (threadController == null) {
        if (threadController == null || availabilityStatus != AVAILABLE) {
            return false
        }

@@ -119,7 +122,7 @@ class ThreadNetworkToggleController @VisibleForTesting constructor(
    }

    override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
        if (threadController == null) {
        if (threadController == null || availabilityStatus != AVAILABLE) {
            return
        }

+6 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.settings.bluetooth.BluetoothFeatureProvider
import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProvider
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider
import com.android.settings.connecteddevice.threadnetwork.ThreadNetworkFeatureProvider
import com.android.settings.dashboard.DashboardFeatureProvider
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProvider
@@ -170,6 +171,11 @@ abstract class FeatureFactory {
     */
    abstract val stylusFeatureProvider: StylusFeatureProvider

    /**
     * Retrieves implementation for Thread network feature.
     */
    abstract val threadNetworkFeatureProvider: ThreadNetworkFeatureProvider

    /**
     * Retrieves implementation for Onboarding related feature.
     */
Loading