Add auto on toggle UI.

Test: atest -c com.android.systemui.qs.tiles.dialog.bluetooth
Bug: b/316822488 b/316985153
Flag: ACONFIG com.android.settingslib.flags.bluetooth_qs_tile_dialog_auto_on_toggle DISABLED
Change-Id: I34141bb31a2d1fc51a2162064555645cff6c1db6
diff --git a/packages/SystemUI/res/layout/bluetooth_tile_dialog.xml b/packages/SystemUI/res/layout/bluetooth_tile_dialog.xml
index a0f916c..ac781ec 100644
--- a/packages/SystemUI/res/layout/bluetooth_tile_dialog.xml
+++ b/packages/SystemUI/res/layout/bluetooth_tile_dialog.xml
@@ -81,7 +81,7 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="21dp"
-        android:minHeight="145dp"
+        android:minHeight="@dimen/bluetooth_dialog_scroll_view_min_height"
         android:fillViewport="true"
         app:layout_constrainedHeight="true"
         app:layout_constraintStart_toStartOf="parent"
@@ -97,11 +97,11 @@
             <TextView
                 android:id="@+id/bluetooth_toggle_title"
                 android:layout_width="0dp"
-                android:layout_height="64dp"
-                android:maxLines="1"
+                android:layout_height="68dp"
+                android:maxLines="2"
                 android:ellipsize="end"
                 android:gravity="start|center_vertical"
-                android:paddingEnd="0dp"
+                android:paddingEnd="15dp"
                 android:paddingStart="36dp"
                 android:text="@string/turn_on_bluetooth"
                 android:clickable="false"
@@ -114,7 +114,7 @@
             <Switch
                 android:id="@+id/bluetooth_toggle"
                 android:layout_width="wrap_content"
-                android:layout_height="64dp"
+                android:layout_height="68dp"
                 android:gravity="start|center_vertical"
                 android:paddingEnd="40dp"
                 android:contentDescription="@string/turn_on_bluetooth"
@@ -126,14 +126,79 @@
                 app:layout_constraintStart_toEndOf="@+id/bluetooth_toggle_title"
                 app:layout_constraintTop_toTopOf="parent" />
 
+            <androidx.constraintlayout.widget.Group
+                android:id="@+id/bluetooth_auto_on_toggle_layout"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:visibility="gone"
+                app:constraint_referenced_ids="bluetooth_auto_on_toggle_title,bluetooth_auto_on_toggle,bluetooth_auto_on_toggle_info_icon,bluetooth_auto_on_toggle_info_text" />
+
+            <TextView
+                android:id="@+id/bluetooth_auto_on_toggle_title"
+                android:layout_width="0dp"
+                android:layout_height="68dp"
+                android:layout_marginBottom="20dp"
+                android:maxLines="2"
+                android:ellipsize="end"
+                android:text="@string/turn_on_bluetooth_auto_tomorrow"
+                android:gravity="start|center_vertical"
+                android:paddingEnd="15dp"
+                android:paddingStart="36dp"
+                android:clickable="false"
+                android:textAppearance="@style/TextAppearance.Dialog.Title"
+                android:textSize="16sp"
+                app:layout_constraintEnd_toStartOf="@+id/bluetooth_auto_on_toggle"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@+id/bluetooth_toggle_title" />
+
+            <Switch
+                android:id="@+id/bluetooth_auto_on_toggle"
+                android:layout_width="wrap_content"
+                android:layout_height="68dp"
+                android:layout_marginBottom="20dp"
+                android:gravity="start|center_vertical"
+                android:paddingEnd="40dp"
+                android:contentDescription="@string/turn_on_bluetooth_auto_tomorrow"
+                android:switchMinWidth="@dimen/settingslib_switch_track_width"
+                android:theme="@style/MainSwitch.Settingslib"
+                android:thumb="@drawable/settingslib_thumb_selector"
+                android:track="@drawable/settingslib_track_selector"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toEndOf="@+id/bluetooth_auto_on_toggle_title"
+                app:layout_constraintTop_toBottomOf="@+id/bluetooth_toggle" />
+
+            <ImageView
+                android:id="@+id/bluetooth_auto_on_toggle_info_icon"
+                android:src="@drawable/ic_info_outline"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:tint="?android:attr/textColorTertiary"
+                android:paddingStart="36dp"
+                android:layout_marginTop="20dp"
+                android:layout_marginBottom="@dimen/bluetooth_dialog_layout_margin"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@+id/bluetooth_auto_on_toggle" />
+
+            <TextView
+                android:id="@+id/bluetooth_auto_on_toggle_info_text"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="20dp"
+                android:paddingStart="36dp"
+                android:paddingEnd="40dp"
+                android:text="@string/turn_on_bluetooth_auto_info"
+                android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/bluetooth_auto_on_toggle_info_icon" />
+
             <androidx.recyclerview.widget.RecyclerView
                 android:id="@+id/device_list"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintTop_toBottomOf="@+id/bluetooth_toggle"
-                app:layout_constraintBottom_toTopOf="@+id/see_all_button" />
+                app:layout_constraintTop_toBottomOf="@+id/bluetooth_toggle" />
 
             <Button
                 android:id="@+id/see_all_button"
@@ -168,12 +233,10 @@
                 android:background="@drawable/bluetooth_tile_dialog_bg_off"
                 android:layout_width="0dp"
                 android:layout_height="64dp"
-                android:layout_marginBottom="9dp"
                 android:contentDescription="@string/accessibility_bluetooth_device_settings_pair_new_device"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintTop_toBottomOf="@+id/see_all_button"
-                app:layout_constraintBottom_toTopOf="@+id/done_button"
                 android:drawableStart="@drawable/ic_add"
                 android:drawablePadding="20dp"
                 android:drawableTint="?android:attr/textColorPrimary"
@@ -186,11 +249,19 @@
                 android:ellipsize="end"
                 android:visibility="gone" />
 
+            <androidx.constraintlayout.widget.Barrier
+                android:id="@+id/barrier"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                app:barrierDirection="bottom"
+                app:constraint_referenced_ids="pair_new_device_button,bluetooth_auto_on_toggle_info_text" />
+
             <Button
                 android:id="@+id/done_button"
                 style="@style/Widget.Dialog.Button"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:layout_marginTop="9dp"
                 android:layout_marginBottom="@dimen/dialog_bottom_padding"
                 android:layout_marginEnd="@dimen/dialog_side_padding"
                 android:layout_marginStart="@dimen/dialog_side_padding"
@@ -200,7 +271,9 @@
                 android:maxLines="1"
                 android:text="@string/inline_done_button"
                 app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintBottom_toBottomOf="parent" />
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintTop_toBottomOf="@+id/barrier"
+                app:layout_constraintVertical_bias="1" />
         </androidx.constraintlayout.widget.ConstraintLayout>
     </androidx.core.widget.NestedScrollView>
 </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index cc31754..7537a00 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -1717,6 +1717,10 @@
     <dimen name="bluetooth_dialog_layout_margin">16dp</dimen>
     <!-- The height of the bluetooth device in bluetooth dialog. -->
     <dimen name="bluetooth_dialog_device_height">72dp</dimen>
+    <!-- The height of the main scroll view in bluetooth dialog. -->
+    <dimen name="bluetooth_dialog_scroll_view_min_height">145dp</dimen>
+    <!-- The height of the main scroll view in bluetooth dialog with auto on toggle. -->
+    <dimen name="bluetooth_dialog_scroll_view_min_height_with_auto_on">350dp</dimen>
 
     <!-- Height percentage of the parent container occupied by the communal view -->
     <item name="communal_source_height_percentage" format="float" type="dimen">0.80</item>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index b30e4a2..8711772 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -669,6 +669,10 @@
     <string name="accessibility_quick_settings_bluetooth_device_tap_to_disconnect">disconnect</string>
     <!-- QuickSettings: Accessibility label to activate a device [CHAR LIMIT=NONE]-->
     <string name="accessibility_quick_settings_bluetooth_device_tap_to_activate">activate</string>
+    <!-- QuickSettings: Bluetooth auto on tomorrow [CHAR LIMIT=NONE]-->
+    <string name="turn_on_bluetooth_auto_tomorrow">Automatically turn on again tomorrow</string>
+    <!-- QuickSettings: Bluetooth auto on info text [CHAR LIMIT=NONE]-->
+    <string name="turn_on_bluetooth_auto_info">Features like Quick Share, Find My Device, and device location use Bluetooth</string>
 
     <!-- QuickSettings: Bluetooth secondary label for the battery level of a connected device [CHAR LIMIT=20]-->
     <string name="quick_settings_bluetooth_secondary_label_battery_level"><xliff:g id="battery_level_as_percentage">%s</xliff:g> battery</string>
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialog.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialog.kt
index 1a06c38..0cedba33 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialog.kt
@@ -56,7 +56,7 @@
 internal class BluetoothTileDialog
 constructor(
     private val bluetoothToggleInitialValue: Boolean,
-    private val subtitleResIdInitialValue: Int,
+    private val initialUiProperties: BluetoothTileDialogViewModel.UiProperties,
     private val cachedContentHeight: Int,
     private val bluetoothTileDialogCallback: BluetoothTileDialogCallback,
     @Main private val mainDispatcher: CoroutineDispatcher,
@@ -89,6 +89,7 @@
 
     private lateinit var toggleView: Switch
     private lateinit var subtitleTextView: TextView
+    private lateinit var autoOnToggleView: View
     private lateinit var doneButton: View
     private lateinit var seeAllButton: View
     private lateinit var pairNewDeviceButton: View
@@ -108,6 +109,7 @@
 
         toggleView = requireViewById(R.id.bluetooth_toggle)
         subtitleTextView = requireViewById(R.id.bluetooth_tile_dialog_subtitle) as TextView
+        autoOnToggleView = requireViewById(R.id.bluetooth_auto_on_toggle_layout)
         doneButton = requireViewById(R.id.done_button)
         seeAllButton = requireViewById(R.id.see_all_button)
         pairNewDeviceButton = requireViewById(R.id.pair_new_device_button)
@@ -116,7 +118,7 @@
         setupToggle()
         setupRecyclerView()
 
-        subtitleTextView.text = context.getString(subtitleResIdInitialValue)
+        subtitleTextView.text = context.getString(initialUiProperties.subTitleResId)
         doneButton.setOnClickListener { dismiss() }
         seeAllButton.setOnClickListener { bluetoothTileDialogCallback.onSeeAllClicked(it) }
         pairNewDeviceButton.setOnClickListener {
@@ -124,7 +126,9 @@
         }
         requireViewById<View>(R.id.scroll_view).apply {
             scrollViewContent = this
-            layoutParams.height = cachedContentHeight
+            minimumHeight =
+                resources.getDimensionPixelSize(initialUiProperties.scrollViewMinHeightResId)
+            layoutParams.height = maxOf(cachedContentHeight, minimumHeight)
         }
         progressBarAnimation = requireViewById(R.id.bluetooth_tile_dialog_progress_animation)
         progressBarBackground = requireViewById(R.id.bluetooth_tile_dialog_progress_background)
@@ -178,13 +182,17 @@
         }
     }
 
-    internal fun onBluetoothStateUpdated(isEnabled: Boolean, subtitleResId: Int) {
+    internal fun onBluetoothStateUpdated(
+        isEnabled: Boolean,
+        uiProperties: BluetoothTileDialogViewModel.UiProperties
+    ) {
         toggleView.apply {
             isChecked = isEnabled
             setEnabled(true)
             alpha = ENABLED_ALPHA
         }
-        subtitleTextView.text = context.getString(subtitleResId)
+        subtitleTextView.text = context.getString(uiProperties.subTitleResId)
+        autoOnToggleView.visibility = uiProperties.autoOnToggleVisibility
     }
 
     private fun setupToggle() {
@@ -198,6 +206,8 @@
             logger.logBluetoothState(BluetoothStateStage.USER_TOGGLED, isChecked.toString())
             uiEventLogger.log(BluetoothTileDialogUiEvent.BLUETOOTH_TOGGLE_CLICKED)
         }
+
+        autoOnToggleView.visibility = initialUiProperties.autoOnToggleVisibility
     }
 
     private fun setupRecyclerView() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogViewModel.kt
index 54bb95c..573ac5e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogViewModel.kt
@@ -21,9 +21,14 @@
 import android.content.SharedPreferences
 import android.os.Bundle
 import android.view.View
+import android.view.View.GONE
+import android.view.View.VISIBLE
 import android.view.ViewGroup
+import androidx.annotation.DimenRes
+import androidx.annotation.StringRes
 import com.android.internal.jank.InteractionJankMonitor
 import com.android.internal.logging.UiEventLogger
+import com.android.settingslib.flags.Flags.bluetoothQsTileDialogAutoOnToggle
 import com.android.systemui.Prefs
 import com.android.systemui.animation.DialogCuj
 import com.android.systemui.animation.DialogTransitionAnimator
@@ -143,7 +148,7 @@
                 bluetoothStateInteractor.bluetoothStateUpdate
                     .filterNotNull()
                     .onEach {
-                        dialog.onBluetoothStateUpdated(it, getSubtitleResId(it))
+                        dialog.onBluetoothStateUpdated(it, UiProperties.build(it))
                         updateDeviceItemJob?.cancel()
                         updateDeviceItemJob = launch {
                             deviceItemInteractor.updateDeviceItems(
@@ -192,7 +197,7 @@
 
         return BluetoothTileDialog(
                 bluetoothStateInteractor.isBluetoothEnabled,
-                getSubtitleResId(bluetoothStateInteractor.isBluetoothEnabled),
+                UiProperties.build(bluetoothStateInteractor.isBluetoothEnabled),
                 cachedContentHeight,
                 this@BluetoothTileDialogViewModel,
                 mainDispatcher,
@@ -251,6 +256,26 @@
             if (isBluetoothEnabled) R.string.quick_settings_bluetooth_tile_subtitle
             else R.string.bt_is_off
     }
+
+    internal data class UiProperties(
+        @StringRes val subTitleResId: Int,
+        val autoOnToggleVisibility: Int,
+        @DimenRes val scrollViewMinHeightResId: Int,
+    ) {
+        companion object {
+            internal fun build(isBluetoothEnabled: Boolean) =
+                UiProperties(
+                    subTitleResId = getSubtitleResId(isBluetoothEnabled),
+                    autoOnToggleVisibility =
+                        if (bluetoothQsTileDialogAutoOnToggle() && !isBluetoothEnabled) VISIBLE
+                        else GONE,
+                    scrollViewMinHeightResId =
+                        if (bluetoothQsTileDialogAutoOnToggle())
+                            R.dimen.bluetooth_dialog_scroll_view_min_height_with_auto_on
+                        else R.dimen.bluetooth_dialog_scroll_view_min_height
+                )
+        }
+    }
 }
 
 internal interface BluetoothTileDialogCallback {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogTest.kt
index 154aa1c..b6ddb62 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogTest.kt
@@ -71,7 +71,7 @@
 
     @Mock private lateinit var logger: BluetoothTileDialogLogger
 
-    private val subtitleResId = R.string.quick_settings_bluetooth_tile_subtitle
+    private val uiProperties = BluetoothTileDialogViewModel.UiProperties.build(ENABLED)
 
     private val fakeSystemClock = FakeSystemClock()
 
@@ -90,7 +90,7 @@
         bluetoothTileDialog =
             BluetoothTileDialog(
                 ENABLED,
-                subtitleResId,
+                uiProperties,
                 CONTENT_HEIGHT,
                 bluetoothTileDialogCallback,
                 dispatcher,
@@ -131,7 +131,7 @@
             bluetoothTileDialog =
                 BluetoothTileDialog(
                     ENABLED,
-                    subtitleResId,
+                    uiProperties,
                     CONTENT_HEIGHT,
                     bluetoothTileDialogCallback,
                     dispatcher,
@@ -166,7 +166,7 @@
         val viewHolder =
             BluetoothTileDialog(
                     ENABLED,
-                    subtitleResId,
+                    uiProperties,
                     CONTENT_HEIGHT,
                     bluetoothTileDialogCallback,
                     dispatcher,
@@ -194,7 +194,7 @@
         val viewHolder =
             BluetoothTileDialog(
                     ENABLED,
-                    subtitleResId,
+                    uiProperties,
                     CONTENT_HEIGHT,
                     bluetoothTileDialogCallback,
                     dispatcher,
@@ -219,7 +219,7 @@
             bluetoothTileDialog =
                 BluetoothTileDialog(
                     ENABLED,
-                    subtitleResId,
+                    uiProperties,
                     CONTENT_HEIGHT,
                     bluetoothTileDialogCallback,
                     dispatcher,
@@ -253,12 +253,36 @@
     }
 
     @Test
-    fun testShowDialog_displayFromCachedHeight() {
+    fun testShowDialog_cachedHeightLargerThanMinHeight_displayFromCachedHeight() {
+        testScope.runTest {
+            val cachedHeight = Int.MAX_VALUE
+            bluetoothTileDialog =
+                BluetoothTileDialog(
+                    ENABLED,
+                    uiProperties,
+                    cachedHeight,
+                    bluetoothTileDialogCallback,
+                    dispatcher,
+                    fakeSystemClock,
+                    uiEventLogger,
+                    logger,
+                    mContext
+                )
+            bluetoothTileDialog.show()
+            assertThat(
+                    bluetoothTileDialog.requireViewById<View>(R.id.scroll_view).layoutParams.height
+                )
+                .isEqualTo(cachedHeight)
+        }
+    }
+
+    @Test
+    fun testShowDialog_cachedHeightLessThanMinHeight_displayFromUiProperties() {
         testScope.runTest {
             bluetoothTileDialog =
                 BluetoothTileDialog(
                     ENABLED,
-                    subtitleResId,
+                    uiProperties,
                     MATCH_PARENT,
                     bluetoothTileDialogCallback,
                     dispatcher,
@@ -271,7 +295,32 @@
             assertThat(
                     bluetoothTileDialog.requireViewById<View>(R.id.scroll_view).layoutParams.height
                 )
-                .isEqualTo(MATCH_PARENT)
+                .isGreaterThan(MATCH_PARENT)
+        }
+    }
+
+    @Test
+    fun testShowDialog_bluetoothEnabled_autoOnToggleGone() {
+        testScope.runTest {
+            bluetoothTileDialog =
+                BluetoothTileDialog(
+                    ENABLED,
+                    BluetoothTileDialogViewModel.UiProperties.build(ENABLED),
+                    MATCH_PARENT,
+                    bluetoothTileDialogCallback,
+                    dispatcher,
+                    fakeSystemClock,
+                    uiEventLogger,
+                    logger,
+                    mContext
+                )
+            bluetoothTileDialog.show()
+            assertThat(
+                    bluetoothTileDialog
+                        .requireViewById<View>(R.id.bluetooth_auto_on_toggle_layout)
+                        .visibility
+                )
+                .isEqualTo(GONE)
         }
     }
 }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogViewModelTest.kt
index 98ac17b..a5576e0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialogViewModelTest.kt
@@ -20,10 +20,13 @@
 import android.testing.AndroidTestingRunner
 import android.testing.TestableLooper
 import android.view.View
+import android.view.View.GONE
+import android.view.View.VISIBLE
 import android.widget.LinearLayout
 import androidx.test.filters.SmallTest
 import com.android.internal.logging.UiEventLogger
 import com.android.settingslib.bluetooth.CachedBluetoothDevice
+import com.android.settingslib.flags.Flags
 import com.android.systemui.SysuiTestCase
 import com.android.systemui.animation.DialogTransitionAnimator
 import com.android.systemui.plugins.ActivityStarter
@@ -31,6 +34,7 @@
 import com.android.systemui.util.mockito.any
 import com.android.systemui.util.mockito.nullable
 import com.android.systemui.util.time.FakeSystemClock
+import com.google.common.truth.Truth.assertThat
 import kotlinx.coroutines.CoroutineDispatcher
 import kotlinx.coroutines.flow.MutableSharedFlow
 import kotlinx.coroutines.flow.MutableStateFlow
@@ -87,6 +91,7 @@
 
     @Before
     fun setUp() {
+        mSetFlagsRule.enableFlags(Flags.FLAG_BLUETOOTH_QS_TILE_DIALOG_AUTO_ON_TOGGLE)
         scheduler = TestCoroutineScheduler()
         dispatcher = UnconfinedTestDispatcher(scheduler)
         testScope = TestScope(dispatcher)
@@ -174,4 +179,38 @@
             verify(activityStarter).postStartActivityDismissingKeyguard(any(), anyInt(), nullable())
         }
     }
+
+    @Test
+    fun testBuildUiProperties_bluetoothOn_shouldHideAutoOn() {
+        testScope.runTest {
+            val actual = BluetoothTileDialogViewModel.UiProperties.build(true)
+            assertThat(actual.autoOnToggleVisibility).isEqualTo(GONE)
+        }
+    }
+
+    @Test
+    fun testBuildUiProperties_bluetoothOff_shouldShowAutoOn() {
+        testScope.runTest {
+            val actual = BluetoothTileDialogViewModel.UiProperties.build(false)
+            assertThat(actual.autoOnToggleVisibility).isEqualTo(VISIBLE)
+        }
+    }
+
+    @Test
+    fun testBuildUiProperties_flagOff_bluetoothOff_shouldHideAutoOn() {
+        testScope.runTest {
+            mSetFlagsRule.disableFlags(Flags.FLAG_BLUETOOTH_QS_TILE_DIALOG_AUTO_ON_TOGGLE)
+            val actual = BluetoothTileDialogViewModel.UiProperties.build(false)
+            assertThat(actual.autoOnToggleVisibility).isEqualTo(GONE)
+        }
+    }
+
+    @Test
+    fun testBuildUiProperties_flagOff_bluetoothOn_shouldHideAutoOn() {
+        testScope.runTest {
+            mSetFlagsRule.disableFlags(Flags.FLAG_BLUETOOTH_QS_TILE_DIALOG_AUTO_ON_TOGGLE)
+            val actual = BluetoothTileDialogViewModel.UiProperties.build(true)
+            assertThat(actual.autoOnToggleVisibility).isEqualTo(GONE)
+        }
+    }
 }