Merge "Wifi: Replace dual_band with 5GHz band support"
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index 91c333a..4f20a01 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -28,4 +28,5 @@
             "settings_wifi_details_datausage_header";
     public static final String PERSONAL_WORK_PROFILE = "settings_work_profile";
     public static final String CONTROLLER_ENHANCEMENT = "settings_controller_loading_enhancement";
+    public static final String CONDITIONAL_CARDS = "settings_conditionals";
 }
diff --git a/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceController.java
new file mode 100644
index 0000000..9e4b99e
--- /dev/null
+++ b/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceController.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2019 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.development.bluetooth;
+
+import android.bluetooth.BluetoothCodecConfig;
+import android.content.Context;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.development.BluetoothA2dpConfigStore;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Dialog preference controller to set the Bluetooth A2DP config of sample rate
+ */
+public class BluetoothSampleRateDialogPreferenceController extends
+        AbstractBluetoothDialogPreferenceController {
+
+    private static final String KEY = "bluetooth_sample_rate_settings";
+    private static final String TAG = "BtSampleRateCtr";
+
+    public BluetoothSampleRateDialogPreferenceController(Context context, Lifecycle lifecycle,
+                                                         BluetoothA2dpConfigStore store) {
+        super(context, lifecycle, store);
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        ((BaseBluetoothDialogPreference) mPreference).setCallback(this);
+    }
+
+    @Override
+    protected void writeConfigurationValues(final int index) {
+        int sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_NONE; // default
+        switch (index) {
+            case 0:
+                final BluetoothCodecConfig currentConfig = getCurrentCodecConfig();
+                if (currentConfig != null) {
+                    sampleRateValue = getHighestSampleRate(getSelectableByCodecType(
+                            currentConfig.getCodecType()));
+                }
+                break;
+            case 1:
+                sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_44100;
+                break;
+            case 2:
+                sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_48000;
+                break;
+            case 3:
+                sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_88200;
+                break;
+            case 4:
+                sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_96000;
+                break;
+            default:
+                break;
+        }
+        mBluetoothA2dpConfigStore.setSampleRate(sampleRateValue);
+    }
+
+    @Override
+    protected int getCurrentIndexByConfig(BluetoothCodecConfig config) {
+        if (config == null) {
+            Log.e(TAG, "Unable to get current config index. Config is null.");
+        }
+        return convertCfgToBtnIndex(config.getSampleRate());
+    }
+
+    @Override
+    public List<Integer> getSelectableIndex() {
+        List<Integer> selectableIndex = new ArrayList<>();
+        selectableIndex.add(getDefaultIndex());
+        final BluetoothCodecConfig currentConfig = getCurrentCodecConfig();
+        if (currentConfig != null) {
+            final int configs =
+                    getSelectableByCodecType(currentConfig.getCodecType()).getSampleRate();
+            for (int sampleRate : SAMPLE_RATES) {
+                if ((configs & sampleRate) != 0) {
+                    selectableIndex.add(convertCfgToBtnIndex(sampleRate));
+                }
+            }
+        }
+        return selectableIndex;
+    }
+
+    @VisibleForTesting
+    int convertCfgToBtnIndex(int config) {
+        int index = getDefaultIndex();
+        switch (config) {
+            case BluetoothCodecConfig.SAMPLE_RATE_44100:
+                index = 1;
+                break;
+            case BluetoothCodecConfig.SAMPLE_RATE_48000:
+                index = 2;
+                break;
+            case BluetoothCodecConfig.SAMPLE_RATE_88200:
+                index = 3;
+                break;
+            case BluetoothCodecConfig.SAMPLE_RATE_96000:
+                index = 4;
+                break;
+            default:
+                Log.e(TAG, "Unsupported config:" + config);
+                break;
+        }
+        return index;
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/BatteryWifiParser.java b/src/com/android/settings/fuelgauge/BatteryWifiParser.java
index 014c069..2aa6749 100644
--- a/src/com/android/settings/fuelgauge/BatteryWifiParser.java
+++ b/src/com/android/settings/fuelgauge/BatteryWifiParser.java
@@ -14,8 +14,8 @@
 
 package com.android.settings.fuelgauge;
 
-import android.os.BatteryStats;
 import android.os.BatteryStats.HistoryItem;
+import android.os.BatteryStatsManager;
 
 public class BatteryWifiParser extends BatteryFlagParser {
 
@@ -27,12 +27,12 @@
     protected boolean isSet(HistoryItem record) {
         switch ((record.states2 & HistoryItem.STATE2_WIFI_SUPPL_STATE_MASK)
                 >> HistoryItem.STATE2_WIFI_SUPPL_STATE_SHIFT) {
-            case BatteryStats.WIFI_SUPPL_STATE_DISCONNECTED:
-            case BatteryStats.WIFI_SUPPL_STATE_DORMANT:
-            case BatteryStats.WIFI_SUPPL_STATE_INACTIVE:
-            case BatteryStats.WIFI_SUPPL_STATE_INTERFACE_DISABLED:
-            case BatteryStats.WIFI_SUPPL_STATE_INVALID:
-            case BatteryStats.WIFI_SUPPL_STATE_UNINITIALIZED:
+            case BatteryStatsManager.WIFI_SUPPL_STATE_DISCONNECTED:
+            case BatteryStatsManager.WIFI_SUPPL_STATE_DORMANT:
+            case BatteryStatsManager.WIFI_SUPPL_STATE_INACTIVE:
+            case BatteryStatsManager.WIFI_SUPPL_STATE_INTERFACE_DISABLED:
+            case BatteryStatsManager.WIFI_SUPPL_STATE_INVALID:
+            case BatteryStatsManager.WIFI_SUPPL_STATE_UNINITIALIZED:
                 return false;
         }
         return true;
diff --git a/src/com/android/settings/network/ActiveSubsciptionsListener.java b/src/com/android/settings/network/ActiveSubsciptionsListener.java
index cb3e061..d9d0bb5 100644
--- a/src/com/android/settings/network/ActiveSubsciptionsListener.java
+++ b/src/com/android/settings/network/ActiveSubsciptionsListener.java
@@ -20,6 +20,8 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.os.Handler;
+import android.os.Looper;
 import android.telephony.CarrierConfigManager;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
@@ -31,6 +33,7 @@
 import com.android.internal.telephony.TelephonyIntents;
 
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * A listener for active subscription change
@@ -43,18 +46,26 @@
     /**
      * Constructor
      *
-     * @param context of this listener
+     * @param looper {@code Looper} of this listener
+     * @param context {@code Context} of this listener
      */
-    public ActiveSubsciptionsListener(Context context) {
+    public ActiveSubsciptionsListener(Looper looper, Context context) {
+        mLooper = looper;
         mContext = context;
 
+        mCacheState = new AtomicInteger(STATE_NOT_LISTENING);
+        mMaxActiveSubscriptionInfos = new AtomicInteger(MAX_SUBSCRIPTION_UNKNOWN);
+
         mSubscriptionChangeIntentFilter = new IntentFilter();
         mSubscriptionChangeIntentFilter.addAction(
                 CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
         mSubscriptionChangeIntentFilter.addAction(
                 TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
+    }
 
-        mSubscriptionChangeReceiver = new BroadcastReceiver() {
+    @VisibleForTesting
+    BroadcastReceiver getSubscriptionChangeReceiver() {
+        return new BroadcastReceiver() {
             @Override
             public void onReceive(Context context, Intent intent) {
                 if (isInitialStickyBroadcast()) {
@@ -77,18 +88,24 @@
         };
     }
 
+    private Looper mLooper;
     private Context mContext;
 
-    private boolean mIsMonitoringDataChange;
-    private boolean mIsCachedDataAvailable;
+    private static final int STATE_NOT_LISTENING = 0;
+    private static final int STATE_STOPPING      = 1;
+    private static final int STATE_PREPARING     = 2;
+    private static final int STATE_LISTENING     = 3;
+    private static final int STATE_DATA_CACHED   = 4;
+
+    private AtomicInteger mCacheState;
     private SubscriptionManager mSubscriptionManager;
 
     private IntentFilter mSubscriptionChangeIntentFilter;
+    private BroadcastReceiver mSubscriptionChangeReceiver;
 
-    @VisibleForTesting
-    BroadcastReceiver mSubscriptionChangeReceiver;
+    private static final int MAX_SUBSCRIPTION_UNKNOWN = -1;
 
-    private Integer mMaxActiveSubscriptionInfos;
+    private AtomicInteger mMaxActiveSubscriptionInfos;
     private List<SubscriptionInfo> mCachedActiveSubscriptionInfo;
 
     /**
@@ -135,16 +152,14 @@
      * @return max. number of active subscription info(s)
      */
     public int getActiveSubscriptionInfoCountMax() {
-        int count = 0;
-        if (mMaxActiveSubscriptionInfos == null) {
-            count = getSubscriptionManager().getActiveSubscriptionInfoCountMax();
-            if (mIsMonitoringDataChange) {
-                mMaxActiveSubscriptionInfos = count;
-            }
-        } else {
-            count = mMaxActiveSubscriptionInfos.intValue();
+        int cacheState = mCacheState.get();
+        if (cacheState < STATE_LISTENING) {
+            return getSubscriptionManager().getActiveSubscriptionInfoCountMax();
         }
-        return count;
+
+        mMaxActiveSubscriptionInfos.compareAndSet(MAX_SUBSCRIPTION_UNKNOWN,
+                getSubscriptionManager().getActiveSubscriptionInfoCountMax());
+        return mMaxActiveSubscriptionInfos.get();
     }
 
     /**
@@ -153,11 +168,11 @@
      * @return A list of active subscription info
      */
     public List<SubscriptionInfo> getActiveSubscriptionsInfo() {
-        if (mIsCachedDataAvailable) {
+        if (mCacheState.get() >= STATE_DATA_CACHED) {
             return mCachedActiveSubscriptionInfo;
         }
-        mIsCachedDataAvailable = mIsMonitoringDataChange;
         mCachedActiveSubscriptionInfo = getSubscriptionManager().getActiveSubscriptionInfoList();
+        mCacheState.compareAndSet(STATE_LISTENING, STATE_DATA_CACHED);
 
         if ((mCachedActiveSubscriptionInfo == null)
                 || (mCachedActiveSubscriptionInfo.size() <= 0)) {
@@ -208,7 +223,7 @@
      * @return A subscription info which is accessible list
      */
     public SubscriptionInfo getAccessibleSubscriptionInfo(int subId) {
-        if (mIsCachedDataAvailable) {
+        if (mCacheState.get() >= STATE_DATA_CACHED) {
             final SubscriptionInfo activeSubInfo = getActiveSubscriptionInfo(subId);
             if (activeSubInfo != null) {
                 return activeSubInfo;
@@ -231,37 +246,49 @@
      * Clear data cached within listener
      */
     public void clearCache() {
-        mIsCachedDataAvailable = false;
-        mMaxActiveSubscriptionInfos = null;
+        mMaxActiveSubscriptionInfos.set(MAX_SUBSCRIPTION_UNKNOWN);
+        mCacheState.compareAndSet(STATE_DATA_CACHED, STATE_LISTENING);
         mCachedActiveSubscriptionInfo = null;
     }
 
     private void monitorSubscriptionsChange(boolean on) {
-        if (mIsMonitoringDataChange == on) {
+        if (on) {
+            if (!mCacheState.compareAndSet(STATE_NOT_LISTENING, STATE_PREPARING)) {
+                return;
+            }
+
+            if (mSubscriptionChangeReceiver == null) {
+                mSubscriptionChangeReceiver = getSubscriptionChangeReceiver();
+            }
+            mContext.registerReceiver(mSubscriptionChangeReceiver,
+                    mSubscriptionChangeIntentFilter, null, new Handler(mLooper));
+            getSubscriptionManager().addOnSubscriptionsChangedListener(this);
+            mCacheState.compareAndSet(STATE_PREPARING, STATE_LISTENING);
             return;
         }
-        mIsMonitoringDataChange = on;
-        if (on) {
-            mContext.registerReceiver(mSubscriptionChangeReceiver,
-                    mSubscriptionChangeIntentFilter);
-            getSubscriptionManager().addOnSubscriptionsChangedListener(this);
-            listenerNotify();
-        } else {
-            mContext.unregisterReceiver(mSubscriptionChangeReceiver);
-            getSubscriptionManager().removeOnSubscriptionsChangedListener(this);
-            clearCache();
+
+        final int currentState = mCacheState.getAndSet(STATE_STOPPING);
+        if (currentState <= STATE_STOPPING) {
+            mCacheState.compareAndSet(STATE_STOPPING, currentState);
+            return;
         }
+        if (mSubscriptionChangeReceiver != null) {
+            mContext.unregisterReceiver(mSubscriptionChangeReceiver);
+        }
+        getSubscriptionManager().removeOnSubscriptionsChangedListener(this);
+        clearCache();
+        mCacheState.compareAndSet(STATE_STOPPING, STATE_NOT_LISTENING);
     }
 
     private void listenerNotify() {
-        if (!mIsMonitoringDataChange) {
+        if (mCacheState.get() < STATE_LISTENING) {
             return;
         }
         onChanged();
     }
 
     private boolean clearCachedSubId(int subId) {
-        if (!mIsCachedDataAvailable) {
+        if (mCacheState.get() < STATE_DATA_CACHED) {
             return false;
         }
         if (mCachedActiveSubscriptionInfo == null) {
diff --git a/src/com/android/settings/network/GlobalSettingsChangeListener.java b/src/com/android/settings/network/GlobalSettingsChangeListener.java
index 89d374b..4c58c60 100644
--- a/src/com/android/settings/network/GlobalSettingsChangeListener.java
+++ b/src/com/android/settings/network/GlobalSettingsChangeListener.java
@@ -24,12 +24,15 @@
 import android.database.ContentObserver;
 import android.net.Uri;
 import android.os.Handler;
+import android.os.Looper;
 import android.provider.Settings;
 
 import androidx.lifecycle.Lifecycle;
 import androidx.lifecycle.LifecycleObserver;
 import androidx.lifecycle.OnLifecycleEvent;
 
+import java.util.concurrent.atomic.AtomicBoolean;
+
 /**
  * A listener for Settings.Global configuration change, with support of Lifecycle
  */
@@ -39,19 +42,33 @@
     /**
      * Constructor
      *
-     * @param context of this listener
+     * @param context {@code Context} of this listener
      * @param field field of Global Settings
      */
     public GlobalSettingsChangeListener(Context context, String field) {
-        super(new Handler());
+        this(Looper.getMainLooper(), context, field);
+    }
+
+    /**
+     * Constructor
+     *
+     * @param looper {@code Looper} for processing callback
+     * @param context {@code Context} of this listener
+     * @param field field of Global Settings
+     */
+    public GlobalSettingsChangeListener(Looper looper, Context context, String field) {
+        super(new Handler(looper));
         mContext = context;
         mField = field;
+        mUri = Settings.Global.getUriFor(field);
+        mListening = new AtomicBoolean(false);
         monitorUri(true);
     }
 
     private Context mContext;
     private String mField;
     private Uri mUri;
+    private AtomicBoolean mListening;
     private Lifecycle mLifecycle;
 
     /**
@@ -75,7 +92,7 @@
     }
 
     public void onChange(boolean selfChange) {
-        if (!isMonitoring()) {
+        if (!mListening.get()) {
             return;
         }
         onChanged(mField);
@@ -104,20 +121,16 @@
         notifyChangeBasedOn(null);
     }
 
-    private boolean isMonitoring() {
-        return (mUri != null);
-    }
-
     private void monitorUri(boolean on) {
-        if (isMonitoring() == on) {
+        if (!mListening.compareAndSet(!on, on)) {
             return;
         }
-        if (mUri == null) {
-            mUri = Settings.Global.getUriFor(mField);
+
+        if (on) {
             mContext.getContentResolver().registerContentObserver(mUri, false, this);
             return;
         }
-        mUri = null;
+
         mContext.getContentResolver().unregisterContentObserver(this);
     }
 }
diff --git a/src/com/android/settings/network/ProxySubscriptionManager.java b/src/com/android/settings/network/ProxySubscriptionManager.java
index 18b4ac9..8f3f385 100644
--- a/src/com/android/settings/network/ProxySubscriptionManager.java
+++ b/src/com/android/settings/network/ProxySubscriptionManager.java
@@ -21,6 +21,7 @@
 import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
 
 import android.content.Context;
+import android.os.Looper;
 import android.provider.Settings;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
@@ -71,18 +72,18 @@
     private static ProxySubscriptionManager sSingleton;
 
     private ProxySubscriptionManager(Context context) {
-        mContext = context;
+        final Looper looper = Looper.getMainLooper();
 
         mActiveSubscriptionsListeners =
                 new ArrayList<OnActiveSubscriptionChangedListener>();
 
-        mSubsciptionsMonitor = new ActiveSubsciptionsListener(context) {
+        mSubsciptionsMonitor = new ActiveSubsciptionsListener(looper, context) {
             public void onChanged() {
                 notifyAllListeners();
             }
         };
-        mAirplaneModeMonitor = new GlobalSettingsChangeListener(context,
-                Settings.Global.AIRPLANE_MODE_ON) {
+        mAirplaneModeMonitor = new GlobalSettingsChangeListener(looper,
+                context, Settings.Global.AIRPLANE_MODE_ON) {
             public void onChanged(String field) {
                 mSubsciptionsMonitor.clearCache();
                 notifyAllListeners();
@@ -93,7 +94,6 @@
     }
 
     private Lifecycle mLifecycle;
-    private Context mContext;
     private ActiveSubsciptionsListener mSubsciptionsMonitor;
     private GlobalSettingsChangeListener mAirplaneModeMonitor;
 
@@ -140,7 +140,7 @@
 
     @OnLifecycleEvent(ON_DESTROY)
     void onDestroy() {
-        mSubsciptionsMonitor.stop();
+        mAirplaneModeMonitor.close();
 
         if (mLifecycle != null) {
             mLifecycle.removeObserver(this);
diff --git a/src/com/android/settings/network/telephony/MobileDataSlice.java b/src/com/android/settings/network/telephony/MobileDataSlice.java
index 65eaf87..152028c 100644
--- a/src/com/android/settings/network/telephony/MobileDataSlice.java
+++ b/src/com/android/settings/network/telephony/MobileDataSlice.java
@@ -38,11 +38,11 @@
 
 import com.android.settings.R;
 import com.android.settings.Utils;
-import com.android.settings.network.AirplaneModePreferenceController;
 import com.android.settings.network.MobileDataContentObserver;
 import com.android.settings.slices.CustomSliceRegistry;
 import com.android.settings.slices.CustomSliceable;
 import com.android.settings.slices.SliceBackgroundWorker;
+import com.android.settingslib.WirelessUtils;
 
 import com.google.common.annotations.VisibleForTesting;
 
@@ -184,10 +184,7 @@
 
     @VisibleForTesting
     boolean isAirplaneModeEnabled() {
-        // Generic key since we only want the method check - no UI.
-        AirplaneModePreferenceController controller = new AirplaneModePreferenceController(mContext,
-                "key" /* Key */);
-        return controller.isChecked();
+        return WirelessUtils.isAirplaneModeOn(mContext);
     }
 
     @VisibleForTesting
diff --git a/src/com/android/settings/notification/AlarmVolumePreferenceController.java b/src/com/android/settings/notification/AlarmVolumePreferenceController.java
index d6a4110..15657f1 100644
--- a/src/com/android/settings/notification/AlarmVolumePreferenceController.java
+++ b/src/com/android/settings/notification/AlarmVolumePreferenceController.java
@@ -42,6 +42,11 @@
     }
 
     @Override
+    public boolean isPublicSlice() {
+        return true;
+    }
+
+    @Override
     public boolean useDynamicSliceSummary() {
         return true;
     }
diff --git a/src/com/android/settings/notification/CallVolumePreferenceController.java b/src/com/android/settings/notification/CallVolumePreferenceController.java
index ded57b3..d505227 100644
--- a/src/com/android/settings/notification/CallVolumePreferenceController.java
+++ b/src/com/android/settings/notification/CallVolumePreferenceController.java
@@ -44,6 +44,11 @@
     }
 
     @Override
+    public boolean isPublicSlice() {
+        return true;
+    }
+
+    @Override
     public boolean useDynamicSliceSummary() {
         return true;
     }
diff --git a/src/com/android/settings/notification/MediaVolumePreferenceController.java b/src/com/android/settings/notification/MediaVolumePreferenceController.java
index ae3146c..e18d2e5 100644
--- a/src/com/android/settings/notification/MediaVolumePreferenceController.java
+++ b/src/com/android/settings/notification/MediaVolumePreferenceController.java
@@ -43,6 +43,11 @@
     }
 
     @Override
+    public boolean isPublicSlice() {
+        return true;
+    }
+
+    @Override
     public boolean useDynamicSliceSummary() {
         return true;
     }
diff --git a/src/com/android/settings/notification/NotificationVolumePreferenceController.java b/src/com/android/settings/notification/NotificationVolumePreferenceController.java
index c82d04b..0fe0d62 100644
--- a/src/com/android/settings/notification/NotificationVolumePreferenceController.java
+++ b/src/com/android/settings/notification/NotificationVolumePreferenceController.java
@@ -45,6 +45,11 @@
     }
 
     @Override
+    public boolean isPublicSlice() {
+        return true;
+    }
+
+    @Override
     public String getPreferenceKey() {
         return KEY_NOTIFICATION_VOLUME;
     }
diff --git a/src/com/android/settings/notification/RemoteVolumePreferenceController.java b/src/com/android/settings/notification/RemoteVolumePreferenceController.java
index 802d75f..bb41975 100644
--- a/src/com/android/settings/notification/RemoteVolumePreferenceController.java
+++ b/src/com/android/settings/notification/RemoteVolumePreferenceController.java
@@ -197,6 +197,11 @@
     }
 
     @Override
+    public boolean isPublicSlice() {
+        return true;
+    }
+
+    @Override
     public boolean useDynamicSliceSummary() {
         return true;
     }
diff --git a/src/com/android/settings/notification/RingVolumePreferenceController.java b/src/com/android/settings/notification/RingVolumePreferenceController.java
index 08efc93..5e7d067 100644
--- a/src/com/android/settings/notification/RingVolumePreferenceController.java
+++ b/src/com/android/settings/notification/RingVolumePreferenceController.java
@@ -96,6 +96,11 @@
     }
 
     @Override
+    public boolean isPublicSlice() {
+        return true;
+    }
+
+    @Override
     public boolean useDynamicSliceSummary() {
         return true;
     }
diff --git a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
index b043cb1..503b5bc 100644
--- a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
+++ b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
@@ -78,6 +78,11 @@
     }
 
     @Override
+    public boolean isPublicSlice() {
+        return true;
+    }
+
+    @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         Preference preference = screen.findPreference(KEY_VIBRATE_WHEN_RINGING);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
new file mode 100644
index 0000000..d274a57
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2019 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.development.bluetooth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.bluetooth.BluetoothA2dp;
+import android.bluetooth.BluetoothCodecConfig;
+import android.bluetooth.BluetoothCodecStatus;
+import android.content.Context;
+
+import androidx.lifecycle.LifecycleOwner;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.development.BluetoothA2dpConfigStore;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class BluetoothSampleRateDialogPreferenceControllerTest {
+
+    @Mock
+    private BluetoothA2dp mBluetoothA2dp;
+    @Mock
+    private PreferenceScreen mScreen;
+
+    private BluetoothSampleRateDialogPreferenceController mController;
+    private BluetoothSampleRateDialogPreference mPreference;
+    private BluetoothA2dpConfigStore mBluetoothA2dpConfigStore;
+    private BluetoothCodecStatus mCodecStatus;
+    private BluetoothCodecConfig mCodecConfigAAC;
+    private BluetoothCodecConfig mCodecConfigSBC;
+    private Context mContext;
+    private LifecycleOwner mLifecycleOwner;
+    private Lifecycle mLifecycle;
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mLifecycleOwner = () -> mLifecycle;
+        mLifecycle = new Lifecycle(mLifecycleOwner);
+        mBluetoothA2dpConfigStore = spy(new BluetoothA2dpConfigStore());
+        mController = spy(new BluetoothSampleRateDialogPreferenceController(mContext, mLifecycle,
+                mBluetoothA2dpConfigStore));
+        mPreference = new BluetoothSampleRateDialogPreference(mContext);
+        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+        mController.displayPreference(mScreen);
+        mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
+                BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+                BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200,
+                BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
+                BluetoothCodecConfig.CHANNEL_MODE_NONE,
+                0, 0, 0, 0);
+        mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
+                BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+                BluetoothCodecConfig.SAMPLE_RATE_96000,
+                BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
+                BluetoothCodecConfig.CHANNEL_MODE_NONE,
+                0, 0, 0, 0);
+    }
+
+    @Test
+    public void writeConfigurationValues_selectDefault_setHighest() {
+        mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
+        BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
+        mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+        mController.onBluetoothServiceConnected(mBluetoothA2dp);
+
+        mController.writeConfigurationValues(0);
+        verify(mBluetoothA2dpConfigStore).setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_88200);
+    }
+
+    @Test
+    public void writeConfigurationValues_checkSampleRate() {
+        mController.writeConfigurationValues(1);
+        verify(mBluetoothA2dpConfigStore).setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_44100);
+
+        mController.writeConfigurationValues(2);
+        verify(mBluetoothA2dpConfigStore).setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000);
+
+        mController.writeConfigurationValues(3);
+        verify(mBluetoothA2dpConfigStore).setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_88200);
+
+        mController.writeConfigurationValues(4);
+        verify(mBluetoothA2dpConfigStore).setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000);
+    }
+
+    @Test
+    public void getCurrentIndexByConfig_verifyIndex() {
+        assertThat(mController.getCurrentIndexByConfig(mCodecConfigSBC)).isEqualTo(
+                mController.convertCfgToBtnIndex(BluetoothCodecConfig.SAMPLE_RATE_96000));
+    }
+
+    @Test
+    public void getSelectableIndex_verifyList() {
+        BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
+        mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+        mController.onBluetoothServiceConnected(mBluetoothA2dp);
+        List<Integer> indexList = new ArrayList<>();
+        indexList.add(mController.getDefaultIndex());
+        indexList.add(mController.convertCfgToBtnIndex(BluetoothCodecConfig.SAMPLE_RATE_48000));
+        indexList.add(mController.convertCfgToBtnIndex(BluetoothCodecConfig.SAMPLE_RATE_88200));
+
+        assertThat(mController.getSelectableIndex().containsAll(indexList)).isTrue();
+        assertThat(indexList.containsAll(mController.getSelectableIndex())).isTrue();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/network/ActiveSubsciptionsListenerTest.java b/tests/robotests/src/com/android/settings/network/ActiveSubsciptionsListenerTest.java
index e124eb7..7f23699 100644
--- a/tests/robotests/src/com/android/settings/network/ActiveSubsciptionsListenerTest.java
+++ b/tests/robotests/src/com/android/settings/network/ActiveSubsciptionsListenerTest.java
@@ -16,111 +16,157 @@
 
 package com.android.settings.network;
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
 
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
+import android.os.Looper;
 import android.telephony.CarrierConfigManager;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
 
 import com.android.internal.telephony.TelephonyIntents;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowBroadcastReceiver;
+import org.robolectric.shadows.ShadowContextImpl;
+import org.robolectric.shadows.ShadowSubscriptionManager;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
 
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
 public class ActiveSubsciptionsListenerTest {
+    private static final int SUB_ID1 = 3;
+    private static final int SUB_ID2 = 7;
 
-    @Mock
-    private SubscriptionManager mSubscriptionManager;
-    @Mock
-    private SubscriptionInfo mSubscriptionInfo1;
-    @Mock
-    private SubscriptionInfo mSubscriptionInfo2;
+    private static final Intent INTENT_RADIO_TECHNOLOGY_CHANGED =
+            new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
+
+    private static final Intent INTENT_MULTI_SIM_CONFIG_CHANGED =
+            new Intent(TelephonyManager.ACTION_MULTI_SIM_CONFIG_CHANGED);
+
+    private static final Intent INTENT_CARRIER_CONFIG_CHANGED =
+            new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
 
     private Context mContext;
-    private ActiveSubsciptionsListener mListener;
+    private ShadowContextImpl mShadowContextImpl;
+    private SubscriptionManager mSubscriptionManager;
+    private ShadowSubscriptionManager mShadowSubscriptionManager;
     private List<SubscriptionInfo> mActiveSubscriptions;
-    private BroadcastReceiver mSubscriptionChangeReceiver;
+
+    private ActiveSubsciptionsListenerImpl mListener;
+    private BroadcastReceiver mReceiver;
+    private ShadowBroadcastReceiver mShadowReceiver;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
-        when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
+
+        mContext = RuntimeEnvironment.application.getBaseContext();
+        mShadowContextImpl = Shadow.extract(mContext);
+
+        mSubscriptionManager = spy(mContext.getSystemService(SubscriptionManager.class));
+        mShadowSubscriptionManager = shadowOf(mSubscriptionManager);
+
         mActiveSubscriptions = new ArrayList<SubscriptionInfo>();
+        mActiveSubscriptions.add(ShadowSubscriptionManager.SubscriptionInfoBuilder
+                .newBuilder().setId(SUB_ID1).buildSubscriptionInfo());
+        mActiveSubscriptions.add(ShadowSubscriptionManager.SubscriptionInfoBuilder
+                .newBuilder().setId(SUB_ID2).buildSubscriptionInfo());
+        mShadowSubscriptionManager.setActiveSubscriptionInfoList(mActiveSubscriptions);
+
+        mListener = spy(new ActiveSubsciptionsListenerImpl(Looper.getMainLooper(), mContext));
+        doReturn(mSubscriptionManager).when(mListener).getSubscriptionManager();
+        mReceiver = mListener.getSubscriptionChangeReceiver();
+        mShadowReceiver = shadowOf(mReceiver);
+        doReturn(mReceiver).when(mListener).getSubscriptionChangeReceiver();
+    }
+
+    @After
+    public void cleanUp() {
+        mListener.stop();
+    }
+
+    private class ActiveSubsciptionsListenerImpl extends ActiveSubsciptionsListener {
+        private ActiveSubsciptionsListenerImpl(Looper looper, Context context) {
+            super(looper, context);
+        }
+        public void onChanged() {}
+    }
+
+    private void sendIntentToReceiver(Intent intent) {
+        mShadowReceiver.onReceive(mContext, intent, new AtomicBoolean(false));
     }
 
     @Test
     public void constructor_noListeningWasSetup() {
-        mListener = spy(new ActiveSubsciptionsListener(mContext) {
-            public void onChanged() {}
-        });
-        verify(mSubscriptionManager, never()).addOnSubscriptionsChangedListener(any());
-        verify(mContext, never()).registerReceiver(any(), any());
         verify(mListener, never()).onChanged();
     }
 
     @Test
-    public void start_onChangedShouldAlwaysBeCalled() {
-        mListener = spy(new ActiveSubsciptionsListener(mContext) {
-            public void onChanged() {}
-        });
-        mSubscriptionChangeReceiver = spy(mListener.mSubscriptionChangeReceiver);
-        when(mSubscriptionChangeReceiver.isInitialStickyBroadcast()).thenReturn(false);
-
-        mActiveSubscriptions.add(mSubscriptionInfo1);
-        mActiveSubscriptions.add(mSubscriptionInfo2);
-        when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(mActiveSubscriptions);
-
-        final Intent intentSubscription =
-                new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
-        final Intent intentRadioTech =
-                new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
-
-        mSubscriptionChangeReceiver.onReceive(mContext, intentSubscription);
-        mSubscriptionChangeReceiver.onReceive(mContext, intentRadioTech);
+    public void start_configChangedIntent_onChangedShouldBeCalled() {
+        sendIntentToReceiver(INTENT_RADIO_TECHNOLOGY_CHANGED);
+        sendIntentToReceiver(INTENT_MULTI_SIM_CONFIG_CHANGED);
         verify(mListener, never()).onChanged();
 
         mListener.start();
 
-        mSubscriptionChangeReceiver.onReceive(mContext, intentSubscription);
-        verify(mListener, atLeastOnce()).onChanged();
+        sendIntentToReceiver(INTENT_RADIO_TECHNOLOGY_CHANGED);
+        verify(mListener, times(1)).onChanged();
 
-        mSubscriptionChangeReceiver.onReceive(mContext, intentRadioTech);
+        sendIntentToReceiver(INTENT_MULTI_SIM_CONFIG_CHANGED);
+        verify(mListener, times(2)).onChanged();
+
+        mListener.stop();
+
+        sendIntentToReceiver(INTENT_RADIO_TECHNOLOGY_CHANGED);
+        sendIntentToReceiver(INTENT_MULTI_SIM_CONFIG_CHANGED);
+        verify(mListener, times(2)).onChanged();
+    }
+
+    @Test
+    public void start_carrierConfigChangedIntent_onChangedWhenSubIdBeenCached() {
+        sendIntentToReceiver(INTENT_CARRIER_CONFIG_CHANGED);
+        verify(mListener, never()).onChanged();
+
+        mListener.start();
+
+        mListener.getActiveSubscriptionsInfo();
+
+        sendIntentToReceiver(INTENT_CARRIER_CONFIG_CHANGED);
+        verify(mListener, never()).onChanged();
+
+        INTENT_CARRIER_CONFIG_CHANGED.putExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX,
+                SUB_ID2);
+        sendIntentToReceiver(INTENT_CARRIER_CONFIG_CHANGED);
         verify(mListener, times(1)).onChanged();
 
         mListener.stop();
 
-        mContext.sendStickyBroadcast(intentSubscription);
-        mContext.sendStickyBroadcast(intentRadioTech);
+        sendIntentToReceiver(INTENT_CARRIER_CONFIG_CHANGED);
         verify(mListener, times(1)).onChanged();
     }
 
+
     @Test
     public void start_alwaysFetchAndCacheResult() {
-        mListener = spy(new ActiveSubsciptionsListener(mContext) {
-            public void onChanged() {}
-        });
-        mActiveSubscriptions.add(mSubscriptionInfo1);
-        mActiveSubscriptions.add(mSubscriptionInfo2);
-
         mListener.start();
 
         List<SubscriptionInfo> subInfoList = null;
@@ -130,8 +176,7 @@
             if (mActiveSubscriptions.size() > numberOfSubInfo) {
                 mActiveSubscriptions.remove(numberOfSubInfo);
             }
-            when(mSubscriptionManager.getActiveSubscriptionInfoList())
-                    .thenReturn(mActiveSubscriptions);
+            mShadowSubscriptionManager.setActiveSubscriptionInfoList(mActiveSubscriptions);
 
             // fetch twice and test if they generated access to SubscriptionManager only once
             subInfoList = mListener.getActiveSubscriptionsInfo();
@@ -143,7 +188,7 @@
             mListener.clearCache();
         }
 
-        when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(null);
+        mShadowSubscriptionManager.setActiveSubscriptionInfoList(null);
 
         // fetch twice and test if they generated access to SubscriptionManager only once
         subInfoList = mListener.getActiveSubscriptionsInfo();
diff --git a/tests/robotests/src/com/android/settings/network/GlobalSettingsChangeListenerTest.java b/tests/robotests/src/com/android/settings/network/GlobalSettingsChangeListenerTest.java
index 8f41b4a..e419071 100644
--- a/tests/robotests/src/com/android/settings/network/GlobalSettingsChangeListenerTest.java
+++ b/tests/robotests/src/com/android/settings/network/GlobalSettingsChangeListenerTest.java
@@ -22,6 +22,7 @@
 import static org.mockito.Mockito.verify;
 
 import android.content.Context;
+import android.os.Looper;
 import android.provider.Settings;
 
 import androidx.lifecycle.Lifecycle;
@@ -49,7 +50,8 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
-        mListener = spy(new GlobalSettingsChangeListener(mContext, SETTINGS_FIELD) {
+        mListener = spy(new GlobalSettingsChangeListener(Looper.getMainLooper(),
+                mContext, SETTINGS_FIELD) {
             public void onChanged(String field) {}
         });
 
diff --git a/tests/robotests/src/com/android/settings/notification/AlarmVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AlarmVolumePreferenceControllerTest.java
index 2120cd9..5253372 100644
--- a/tests/robotests/src/com/android/settings/notification/AlarmVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AlarmVolumePreferenceControllerTest.java
@@ -78,4 +78,9 @@
     public void isSliceableCorrectKey_returnsTrue() {
         assertThat(mController.isSliceable()).isTrue();
     }
+
+    @Test
+    public void isPublicSlice_returnTrue() {
+        assertThat(mController.isPublicSlice()).isTrue();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java
index 966d4e1..ed65d5b 100644
--- a/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java
@@ -102,4 +102,9 @@
         new CallVolumePreferenceController(mContext, "bad_key");
         assertThat(controller.isSliceable()).isFalse();
     }
+
+    @Test
+    public void isPublicSlice_returnTrue() {
+        assertThat(mController.isPublicSlice()).isTrue();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
index 657b352..7cfcaff 100644
--- a/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
@@ -63,4 +63,9 @@
                 mContext);
         assertThat(controller.isSliceable()).isTrue();
     }
+
+    @Test
+    public void isPublicSlice_returnTrue() {
+        assertThat(mController.isPublicSlice()).isTrue();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
index 8e1b015..fe4744f 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
@@ -102,4 +102,9 @@
                 new NotificationVolumePreferenceController(mContext);
         assertThat(controller.isSliceable()).isTrue();
     }
+
+    @Test
+    public void isPublicSlice_returnTrue() {
+        assertThat(mController.isPublicSlice()).isTrue();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/RemoteVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RemoteVolumePreferenceControllerTest.java
index 175599a..44fc04f 100644
--- a/tests/robotests/src/com/android/settings/notification/RemoteVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/RemoteVolumePreferenceControllerTest.java
@@ -218,4 +218,9 @@
 
         assertThat(mController.mPreference.getProgress()).isEqualTo(CURRENT_POS);
     }
+
+    @Test
+    public void isPublicSlice_returnTrue() {
+        assertThat(mController.isPublicSlice()).isTrue();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
index e89edb4..5e484a3 100644
--- a/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
@@ -104,4 +104,9 @@
                 new RingVolumePreferenceController(mContext);
         assertThat(controller.isSliceable()).isTrue();
     }
+
+    @Test
+    public void isPublicSlice_returnTrue() {
+        assertThat(mController.isPublicSlice()).isTrue();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
index a1b65c5..ec275c1 100644
--- a/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
@@ -44,9 +44,9 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
 import org.robolectric.shadow.api.Shadow;
 import org.robolectric.shadows.ShadowContentResolver;
 
@@ -225,4 +225,8 @@
         assertThat(controller.isSliceable()).isFalse();
     }
 
+    @Test
+    public void isPublicSlice_returnTrue() {
+        assertThat(mController.isPublicSlice()).isTrue();
+    }
 }