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

Commit 5b68f436 authored by Jason Zhang's avatar Jason Zhang Committed by Android (Google) Code Review
Browse files

Merge "Hide the settings button on the connected WiFi entry at login screen" into main

parents 7ebedc3f f1723d29
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -377,6 +377,33 @@
                </FrameLayout>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/login_screen_change_connected_wifi_notify_layout"
                style="@style/InternetDialog.Network"
                android:layout_height="wrap_content"
                android:clickable="false"
                android:focusable="false"
                android:orientation="horizontal"
                android:paddingBottom="4dp"
                android:paddingTop="8dp"
                android:gravity="start|center_vertical"
                android:visibility="gone">

                <ImageView
                    android:contentDescription="@string/change_connected_wifi_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_info_outline"
                    android:tint="?android:attr/textColorTertiary" />

                <TextView
                    android:text="@string/change_connected_wifi_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingStart="4dp"
                    android:textAppearance="@style/TextAppearance.TileDetailsEntrySubTitle" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/wifi_scan_notify_layout"
                style="@style/InternetDialog.Network"
+3 −0
Original line number Diff line number Diff line
@@ -189,6 +189,9 @@
    <!-- Message of notification shown when trying to enable wireless debugging but a secondary user is the current foreground user. [CHAR LIMIT=NONE] -->
    <string name="wifi_debugging_secondary_user_message">The user currently signed in to this device can\u2019t turn on wireless debugging. To use this feature, switch to an admin user.</string>

    <!-- Message of notification shown when trying to modify connected wifi settings at the login screen. [CHAR LIMIT=50] -->
    <string name="change_connected_wifi_text">You can change this setting once logged in</string>

    <!-- Title of USB contaminant presence dialog [CHAR LIMIT=NONE] -->
    <string name="usb_contaminant_title">USB port disabled</string>

+27 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ import com.android.systemui.qs.flags.QsWifiConfig
import com.android.systemui.res.R
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.user.domain.interactor.HeadlessSystemUserMode
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.wifitrackerlib.WifiEntry
import com.google.android.material.materialswitch.MaterialSwitch
import com.google.common.annotations.VisibleForTesting
@@ -75,8 +77,11 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import java.util.concurrent.Executor
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

/**
 * View content for the Internet tile details that handles all UI interactions and state management.
@@ -91,6 +96,9 @@ constructor(
    @Main private val handler: Handler,
    @Background private val backgroundExecutor: Executor,
    private val keyguard: KeyguardStateController,
    @Main private val mainDispatcher: CoroutineDispatcher,
    private val selectedUserInteractor: SelectedUserInteractor,
    private val hsum: HeadlessSystemUserMode,
) {
    // Lifecycle
    private lateinit var lifecycleRegistry: LifecycleRegistry
@@ -109,6 +117,7 @@ constructor(
    private lateinit var wifiToggleTitleTextView: TextView
    private lateinit var wifiScanNotifyLayout: LinearLayout
    private lateinit var wifiScanNotifyTextView: TextView
    private lateinit var loginScreenConnectedWifiNotifyLayout: LinearLayout
    private lateinit var connectedWifiListLayout: LinearLayout
    private lateinit var connectedWifiIcon: ImageView
    private lateinit var connectedWifiTitleTextView: TextView
@@ -273,6 +282,8 @@ constructor(
        wifiToggleTitleTextView = contentView.requireViewById(R.id.wifi_toggle_title)
        wifiScanNotifyLayout = contentView.requireViewById(R.id.wifi_scan_notify_layout)
        wifiScanNotifyTextView = contentView.requireViewById(R.id.wifi_scan_notify_text)
        loginScreenConnectedWifiNotifyLayout =
            contentView.requireViewById(R.id.login_screen_change_connected_wifi_notify_layout)
        connectedWifiListLayout = contentView.requireViewById(R.id.wifi_connected_layout)
        connectedWifiIcon = contentView.requireViewById(R.id.wifi_connected_icon)
        connectedWifiTitleTextView = contentView.requireViewById(R.id.wifi_connected_title)
@@ -732,6 +743,7 @@ constructor(
        ) {
            connectedWifiListLayout.visibility = View.GONE
            shareWifiButton.visibility = View.GONE
            loginScreenConnectedWifiNotifyLayout.visibility = View.GONE
            return
        }
        connectedWifiListLayout.visibility = View.VISIBLE
@@ -740,6 +752,21 @@ constructor(
        connectedWifiIcon.setImageDrawable(
            internetDetailsContentController.getInternetWifiDrawable(connectedWifiEntry!!)
        )

        coroutineScope.launch {
            val isHsu = hsum.isHeadlessSystemUser(selectedUserInteractor.getSelectedUserId())
            withContext(mainDispatcher) {
                if (QsWifiConfig.isEnabled && isHsu) {
                    wifiSettingsIcon.visibility = View.GONE
                    loginScreenConnectedWifiNotifyLayout.visibility = View.VISIBLE
                    connectedWifiListLayout.setClickable(false)
                } else {
                    wifiSettingsIcon.visibility = View.VISIBLE
                    loginScreenConnectedWifiNotifyLayout.visibility = View.GONE
                    connectedWifiListLayout.setClickable(true)
                }
            }
        }
        wifiSettingsIcon.setColorFilter(context.getColor(R.color.connected_network_primary_color))

        val canShareWifi =
+22 −3
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.telephony.telephonyManager
import android.testing.TestableLooper.RunWithLooper
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
@@ -39,15 +40,18 @@ import com.android.settingslib.wifi.WifiEnterpriseRestrictionUtils
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.testKosmos
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.user.domain.interactor.fakeHeadlessSystemUserMode
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.time.FakeSystemClock
import com.android.wifitrackerlib.WifiEntry
import com.google.android.material.materialswitch.MaterialSwitch
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CoroutineScope
import org.junit.After
import org.junit.Before
import org.junit.Test
@@ -68,13 +72,15 @@ import org.mockito.kotlin.whenever
class InternetDetailsContentManagerTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val handler: Handler = kosmos.fakeExecutorHandler
    private val scope: CoroutineScope = mock<CoroutineScope>()
    private val testDispatcher = kosmos.testDispatcher
    private val testScope = kosmos.testScope
    private val telephonyManager: TelephonyManager = kosmos.telephonyManager
    private val internetWifiEntry: WifiEntry = mock<WifiEntry>()
    private val wifiEntries: List<WifiEntry> = mock<List<WifiEntry>>()
    private val internetAdapter = mock<InternetAdapter>()
    private val internetDetailsContentController: InternetDetailsContentController =
        mock<InternetDetailsContentController>()
    private val selectedUserInteractor = mock<SelectedUserInteractor>()
    private val keyguard: KeyguardStateController = mock<KeyguardStateController>()
    private val bgExecutor = FakeExecutor(FakeSystemClock())
    private lateinit var internetDetailsContentManager: InternetDetailsContentManager
@@ -85,6 +91,7 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
    private var wifiToggleSwitch: MaterialSwitch? = null
    private var wifiToggleSummary: TextView? = null
    private var connectedWifi: LinearLayout? = null
    private var wifiSettingsIcon: ImageView? = null
    private var wifiList: RecyclerView? = null
    private var seeAll: LinearLayout? = null
    private var wifiScanNotify: LinearLayout? = null
@@ -135,9 +142,12 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
                handler = handler,
                backgroundExecutor = bgExecutor,
                keyguard = keyguard,
                mainDispatcher = testDispatcher,
                selectedUserInteractor = selectedUserInteractor,
                hsum = kosmos.fakeHeadlessSystemUserMode,
            )

        internetDetailsContentManager.bind(contentView, scope)
        internetDetailsContentManager.bind(contentView, testScope)
        internetDetailsContentManager.adapter = internetAdapter
        internetDetailsContentManager.connectedWifiEntry = internetWifiEntry
        internetDetailsContentManager.wifiEntriesCount = wifiEntries.size
@@ -149,6 +159,7 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
        wifiToggleSwitch = contentView.requireViewById(R.id.wifi_toggle)
        wifiToggleSummary = contentView.requireViewById(R.id.wifi_toggle_summary)
        connectedWifi = contentView.requireViewById(R.id.wifi_connected_layout)
        wifiSettingsIcon = contentView.requireViewById(R.id.wifi_settings_icon)
        wifiList = contentView.requireViewById(R.id.wifi_list_layout)
        seeAll = contentView.requireViewById(R.id.see_all_layout)
        wifiScanNotify = contentView.requireViewById(R.id.wifi_scan_notify_layout)
@@ -392,6 +403,7 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_QS_WIFI_CONFIG)
    fun updateContent_wifiOnAndHasInternetWifi_showConnectedWifi() {
        whenever(internetDetailsContentController.activeAutoSwitchNonDdsSubId).thenReturn(1)
        whenever(internetDetailsContentController.hasActiveSubIdOnDds()).thenReturn(true)
@@ -414,6 +426,7 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_QS_WIFI_CONFIG)
    fun updateContent_wifiOnAndNoConnectedWifi_hideConnectedWifi() {
        // The precondition WiFi ON is already in setUp()
        internetDetailsContentManager.connectedWifiEntry = null
@@ -431,6 +444,7 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_QS_WIFI_CONFIG)
    fun updateContent_wifiOnAndNoWifiEntry_showWifiListAndSeeAllArea() {
        // The precondition WiFi ON is already in setUp()
        internetDetailsContentManager.connectedWifiEntry = null
@@ -451,6 +465,7 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_QS_WIFI_CONFIG)
    fun updateContent_wifiOnAndOneWifiEntry_showWifiListAndSeeAllArea() {
        // The precondition WiFi ON is already in setUp()
        internetDetailsContentManager.connectedWifiEntry = null
@@ -471,6 +486,7 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_QS_WIFI_CONFIG)
    fun updateContent_wifiOnAndHasConnectedWifi_showAllWifiAndSeeAllArea() {
        // The preconditions WiFi ON and WiFi entries are already in setUp()
        internetDetailsContentManager.wifiEntriesCount = 0
@@ -490,6 +506,7 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_QS_WIFI_CONFIG)
    fun updateContent_wifiOnAndHasMaxWifiList_showWifiListAndSeeAll() {
        // The preconditions WiFi ON and WiFi entries are already in setUp()
        internetDetailsContentManager.connectedWifiEntry = null
@@ -511,6 +528,7 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_QS_WIFI_CONFIG)
    fun updateContent_wifiOnAndHasBothWifiEntry_showBothWifiEntryAndSeeAll() {
        // The preconditions WiFi ON and WiFi entries are already in setUp()
        internetDetailsContentManager.wifiEntriesCount =
@@ -761,6 +779,7 @@ class InternetDetailsContentManagerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_QS_WIFI_CONFIG)
    fun onClickSeeMoreButton_clickSeeAll_verifyLaunchNetworkSetting() {
        seeAll!!.performClick()