Merge "Fix broken tests" into qt-dev
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 02b00e2..e0a0206 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -3357,4 +3357,20 @@
             column="5"/>
     </issue>
 
+    <issue
+        id="HardCodedColor"
+        severity="Error"
+        message="Avoid using hardcoded color"
+        category="Correctness"
+        priority="4"
+        summary="Using hardcoded color"
+        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+        errorLine1="    android:color=&quot;@color/notification_importance_button_unselected&quot;"
+        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/button_border_unselected.xml"
+            line="21"
+            column="10"/>
+    </issue>
+
 </issues>
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index 260297a..0e935c0 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -115,6 +115,8 @@
             for (CachedBluetoothDevice cachedBluetoothDevice : cachedDevices) {
                 update(cachedBluetoothDevice);
             }
+        } else {
+          removeAllDevicesFromPreference();
         }
     }
 
diff --git a/src/com/android/settings/notification/ZenModeCallsPreferenceController.java b/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
index 0a8b931..d931f6c 100644
--- a/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
@@ -16,7 +16,9 @@
 
 package com.android.settings.notification;
 
+import android.app.NotificationManager;
 import android.content.Context;
+import android.provider.Settings;
 
 import androidx.preference.Preference;
 
@@ -50,6 +52,16 @@
     public void updateState(Preference preference) {
         super.updateState(preference);
 
-        preference.setSummary(mSummaryBuilder.getCallsSettingSummary(getPolicy()));
+        switch (getZenMode()) {
+            case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+            case Settings.Global.ZEN_MODE_ALARMS:
+                preference.setEnabled(false);
+                preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+                        NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
+                break;
+            default:
+                preference.setEnabled(true);
+                preference.setSummary(mSummaryBuilder.getCallsSettingSummary(getPolicy()));
+        }
     }
 }
diff --git a/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java b/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
index 2e41f20..d51be27 100644
--- a/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
@@ -16,7 +16,9 @@
 
 package com.android.settings.notification;
 
+import android.app.NotificationManager;
 import android.content.Context;
+import android.provider.Settings;
 
 import androidx.preference.Preference;
 
@@ -49,6 +51,16 @@
     public void updateState(Preference preference) {
         super.updateState(preference);
 
-        preference.setSummary(mSummaryBuilder.getMessagesSettingSummary(getPolicy()));
+        switch (getZenMode()) {
+            case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+            case Settings.Global.ZEN_MODE_ALARMS:
+                preference.setEnabled(false);
+                preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+                        NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
+                break;
+            default:
+                preference.setEnabled(true);
+                preference.setSummary(mSummaryBuilder.getMessagesSettingSummary(getPolicy()));
+        }
     }
 }
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
index 24aae85..1066552 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
@@ -215,11 +215,14 @@
     }
 
     @Test
-    public void forceUpdate_bluetoothDisabled_doNothing() {
+    public void forceUpdate_bluetoothDisabled_removeAllDevicesFromPreference() {
         mShadowBluetoothAdapter.setEnabled(false);
+        mBluetoothDeviceUpdater.mPreferenceMap.put(mBluetoothDevice, mPreference);
+
         mBluetoothDeviceUpdater.forceUpdate();
 
-        verify(mDevicePreferenceCallback, never()).onDeviceAdded(any(Preference.class));
+        verify(mDevicePreferenceCallback).onDeviceRemoved(mPreference);
+        assertThat(mBluetoothDeviceUpdater.mPreferenceMap).isEmpty();
     }
 
     @Test