Merge "Schematize ADB system properties"
diff --git a/res/layout-land/fingerprint_enroll_enrolling.xml b/res/layout-land/fingerprint_enroll_enrolling.xml
index f96bdde..ba2c420 100644
--- a/res/layout-land/fingerprint_enroll_enrolling.xml
+++ b/res/layout-land/fingerprint_enroll_enrolling.xml
@@ -92,13 +92,6 @@
                     android:layout_height="0dp"
                     android:layout_weight="1" />
 
-                <Button
-                    android:id="@+id/skip_button"
-                    style="@style/SudGlifButton.Secondary"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="@string/security_settings_fingerprint_enroll_enrolling_skip" />
-
             </LinearLayout>
 
             <LinearLayout
diff --git a/res/layout-land/fingerprint_enroll_find_sensor.xml b/res/layout-land/fingerprint_enroll_find_sensor.xml
index f4c97a3..28d982e 100644
--- a/res/layout-land/fingerprint_enroll_find_sensor.xml
+++ b/res/layout-land/fingerprint_enroll_find_sensor.xml
@@ -83,14 +83,6 @@
                         android:layout_height="0dp"
                         android:layout_weight="1" />
 
-                    <Button
-                        style="@style/SetupWizardButton.Negative"
-                        android:id="@+id/skip_button"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_marginTop="8dp"
-                        android:text="@string/skip_label" />
-
                 </LinearLayout>
 
             </ScrollView>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c6aded3..9f5b562 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -927,10 +927,12 @@
     <string name="security_settings_face_settings_require_attention">Eyes open to unlock</string>
     <!-- Text shown on the details of a toggle which disables/enables face authentication, depending if the user's eyes are open. [CHAR LIMIT=70] -->
     <string name="security_settings_face_settings_require_attention_details">When using face authentication, your eyes must be open</string>
+    <!-- When authenticating in apps, always require confirmation (e.g. confirm button) after a face is authenticated. [CHAR LIMIT=50] -->
+    <string name="security_settings_face_settings_require_confirmation">Always require confirmation</string>
+    <!-- When authenticating in apps, always require confirmation (e.g. confirm button) after a face is authenticated. [CHAR LIMIT=70] -->
+    <string name="security_settings_face_settings_require_confirmation_details">When authenticating in apps, always require confirmation</string>
     <!-- Button text in face settings which removes the user's faces from the device [CHAR LIMIT=20] -->
     <string name="security_settings_face_settings_remove_face_data">Remove face data</string>
-    <!-- Text shown in face settings allowing the user to update/improve the enrolled face. This brings the user back to the enrollment flow. [CHAR LIMIT=30] -->
-    <string name="security_settings_face_settings_improve_face">Improve your face data</string>
     <!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
     <string name="security_settings_face_settings_footer">Your face can be used to unlock your device and access apps.
         <annotation id="url">Learn more</annotation></string>
@@ -4689,7 +4691,9 @@
     <!-- Title for accessibility preference screen for configuring vibrations. -->
     <string name="accessibility_vibration_settings_title">Vibration</string>
     <!-- Title for accessibility preference for configuring notification vibrations. -->
-    <string name="accessibility_notification_vibration_title">Ring &amp; notification vibration</string>
+    <string name="accessibility_notification_vibration_title">Notification vibration</string>
+    <!-- Title for accessibility preference for configuring ring vibrations. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_ring_vibration_title">Ring vibration</string>
     <!-- Title for accessibility preference for configuring touch feedback vibrations. -->
     <string name="accessibility_touch_vibration_title">Touch vibration</string>
     <!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
@@ -4759,8 +4763,8 @@
         <item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
     </plurals>
 
-    <!-- Summary for vibration settings preference when notification vibration and haptic feedback intensity are set. [CHAR LIMIT=32] -->
-    <string name="accessibility_vibration_summary">Ring <xliff:g id="summary_ring" example="Medium">%1$s</xliff:g>, touch <xliff:g id="summary_touch" example="High">%2$s</xliff:g></string>
+    <!-- Summary for vibration settings preference when notification vibration and haptic feedback intensity are set. [CHAR LIMIT=50] -->
+    <string name="accessibility_vibration_summary">Ring <xliff:g id="summary_ring" example="Medium">%1$s</xliff:g>, notification <xliff:g id="summary_notification" example="Low">%2$s</xliff:g>, touch <xliff:g id="summary_touch" example="High">%3$s</xliff:g></string>
 
     <!-- Summary for vibration settings preference when ring & notification are set to off-->
     <string name="accessibility_vibration_summary_off">Ring &amp; notification set to off</string>
@@ -7054,8 +7058,10 @@
     <!-- List of synonyms for touch vibration setting (where you get a haptic response for touching things on the screen), used to match in settings search [CHAR LIMIT=NONE] -->
     <string name="keywords_touch_vibration">haptics, vibrate, screen, sensitivity</string>
 
-    <!-- List of synonyms for ring and notification vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
-    <string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity</string>
+    <!-- List of synonyms for ring vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
+    <string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity, ring</string>
+    <!-- List of synonyms for notification vibration setting (changes whether your phone vibrates when it shows a notification), used to match in settings search [CHAR LIMIT=NONE] -->
+    <string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
 
     <!-- NFC Wi-Fi pairing/setup strings-->
 
diff --git a/res/xml/accessibility_ring_vibration_settings.xml b/res/xml/accessibility_ring_vibration_settings.xml
new file mode 100644
index 0000000..078f76c
--- /dev/null
+++ b/res/xml/accessibility_ring_vibration_settings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2018 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.
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:title="@string/accessibility_ring_vibration_title" />
diff --git a/res/xml/accessibility_vibration_settings.xml b/res/xml/accessibility_vibration_settings.xml
index b2b3596..dc2b16a 100644
--- a/res/xml/accessibility_vibration_settings.xml
+++ b/res/xml/accessibility_vibration_settings.xml
@@ -22,10 +22,17 @@
     android:title="@string/accessibility_vibration_settings_title">
 
     <Preference
+        android:fragment="com.android.settings.accessibility.RingVibrationPreferenceFragment"
+        android:key="ring_vibration_preference_screen"
+        android:title="@string/accessibility_ring_vibration_title"
+        settings:keywords="@string/keywords_ring_vibration"
+        app:controller="com.android.settings.accessibility.RingVibrationIntensityPreferenceController" />
+
+    <Preference
         android:fragment="com.android.settings.accessibility.NotificationVibrationPreferenceFragment"
         android:key="notification_vibration_preference_screen"
         android:title="@string/accessibility_notification_vibration_title"
-        settings:keywords="@string/keywords_ring_vibration"
+        settings:keywords="@string/keywords_notification_vibration"
         app:controller="com.android.settings.accessibility.NotificationVibrationIntensityPreferenceController" />
 
     <Preference
diff --git a/res/xml/bluetooth_device_details_fragment.xml b/res/xml/bluetooth_device_details_fragment.xml
index 90895f2..cf9fbf9 100644
--- a/res/xml/bluetooth_device_details_fragment.xml
+++ b/res/xml/bluetooth_device_details_fragment.xml
@@ -31,7 +31,7 @@
 
     <com.android.settings.slices.SlicePreference
         android:key="bt_device_slice"
-        settings:controller="com.android.settings.slices.SlicePreferenceController"
+        settings:controller="com.android.settings.slices.BlockingSlicePrefController"
         settings:allowDividerBelow="true"
         settings:allowDividerAbove="true"/>
 
diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml
index c202a6c..f5dde8b 100644
--- a/res/xml/security_settings_face.xml
+++ b/res/xml/security_settings_face.xml
@@ -47,13 +47,16 @@
         <SwitchPreference
             android:key="security_settings_face_require_attention"
             android:title="@string/security_settings_face_settings_require_attention"
+            android:summary="@string/security_settings_face_settings_require_attention_details"
             app:keywords="@string/keywords_face_unlock"
             app:controller="com.android.settings.biometrics.face.FaceSettingsAttentionPreferenceController"/>
 
-        <Preference
-            android:key="security_settings_face_improve"
-            android:title="@string/security_settings_face_settings_improve_face">
-        </Preference>
+        <SwitchPreference
+            android:key="security_settings_face_require_confirmation"
+            android:title="@string/security_settings_face_settings_require_confirmation"
+            android:summary="@string/security_settings_face_settings_require_confirmation_details"
+            app:keywords="@string/keywords_face_unlock"
+            app:controller="com.android.settings.biometrics.face.FaceSettingsConfirmPreferenceController"/>
 
         <com.android.settingslib.widget.LayoutPreference
             android:key="security_settings_face_delete_faces_container"
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 76be66d..402fa61 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -810,15 +810,30 @@
         final Context context = getContext();
         final Vibrator vibrator = context.getSystemService(Vibrator.class);
 
-        final int ringIntensity = Settings.System.getInt(context.getContentResolver(),
-                Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
-                vibrator.getDefaultNotificationVibrationIntensity());
+        int ringIntensity = Settings.System.getInt(context.getContentResolver(),
+                Settings.System.RING_VIBRATION_INTENSITY,
+                vibrator.getDefaultRingVibrationIntensity());
+        if (Settings.System.getInt(context.getContentResolver(),
+                Settings.System.VIBRATE_WHEN_RINGING, 0) == 0) {
+            ringIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
+        }
         CharSequence ringIntensityString =
                 VibrationIntensityPreferenceController.getIntensityString(context, ringIntensity);
 
-        final int touchIntensity = Settings.System.getInt(context.getContentResolver(),
+        int notificationIntensity = Settings.System.getInt(context.getContentResolver(),
+                Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
+                vibrator.getDefaultNotificationVibrationIntensity());
+        CharSequence notificationIntensityString =
+                VibrationIntensityPreferenceController.getIntensityString(context,
+                        notificationIntensity);
+
+        int touchIntensity = Settings.System.getInt(context.getContentResolver(),
                 Settings.System.HAPTIC_FEEDBACK_INTENSITY,
                 vibrator.getDefaultHapticFeedbackIntensity());
+        if (Settings.System.getInt(context.getContentResolver(),
+                Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) == 0) {
+            touchIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
+        }
         CharSequence touchIntensityString =
                 VibrationIntensityPreferenceController.getIntensityString(context, touchIntensity);
 
@@ -826,12 +841,14 @@
             mVibrationPreferenceScreen = findPreference(VIBRATION_PREFERENCE_SCREEN);
         }
 
-        if (ringIntensity == touchIntensity) {
+        if (ringIntensity == touchIntensity && ringIntensity == notificationIntensity) {
             mVibrationPreferenceScreen.setSummary(ringIntensityString);
         } else {
             mVibrationPreferenceScreen.setSummary(
                     getString(R.string.accessibility_vibration_summary,
-                            ringIntensityString, touchIntensityString));
+                            ringIntensityString,
+                            notificationIntensityString,
+                            touchIntensityString));
         }
     }
 
diff --git a/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java b/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
index 343ebb1..a2142a2 100644
--- a/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
@@ -28,7 +28,8 @@
     static final String PREF_KEY = "touch_vibration_preference_screen";
 
     public HapticFeedbackIntensityPreferenceController(Context context) {
-        super(context, PREF_KEY, Settings.System.HAPTIC_FEEDBACK_INTENSITY);
+        super(context, PREF_KEY, Settings.System.HAPTIC_FEEDBACK_INTENSITY,
+                Settings.System.HAPTIC_FEEDBACK_ENABLED);
     }
 
     @Override
diff --git a/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
index 4aff513..4ace4c6 100644
--- a/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
@@ -28,7 +28,7 @@
     static final String PREF_KEY = "notification_vibration_preference_screen";
 
     public NotificationVibrationIntensityPreferenceController(Context context) {
-        super(context, PREF_KEY, Settings.System.NOTIFICATION_VIBRATION_INTENSITY);
+        super(context, PREF_KEY, Settings.System.NOTIFICATION_VIBRATION_INTENSITY, "");
     }
 
     @Override
diff --git a/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java
index 6804abc..ba7d51d 100644
--- a/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java
@@ -45,6 +45,11 @@
     }
 
     @Override
+    protected String getVibrationEnabledSetting() {
+        return "";
+    }
+
+    @Override
     protected int getPreviewVibrationAudioAttributesUsage() {
         return AudioAttributes.USAGE_NOTIFICATION;
     }
diff --git a/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
new file mode 100644
index 0000000..818c414
--- /dev/null
+++ b/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2018 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.accessibility;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+
+public class RingVibrationIntensityPreferenceController
+        extends VibrationIntensityPreferenceController {
+
+    @VisibleForTesting
+    static final String PREF_KEY = "ring_vibration_preference_screen";
+
+    public RingVibrationIntensityPreferenceController(Context context) {
+        super(context, PREF_KEY, Settings.System.RING_VIBRATION_INTENSITY,
+                Settings.System.VIBRATE_WHEN_RINGING);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    protected int getDefaultIntensity() {
+        return mVibrator.getDefaultRingVibrationIntensity();
+    }
+}
diff --git a/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
new file mode 100644
index 0000000..df05231
--- /dev/null
+++ b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2018 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.accessibility;
+
+import android.media.AudioAttributes;
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+
+/**
+ * Fragment for picking accessibility shortcut service
+ */
+public class RingVibrationPreferenceFragment extends VibrationPreferenceFragment {
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.ACCESSIBILITY_VIBRATION_RING;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.accessibility_ring_vibration_settings;
+    }
+
+    /**
+     * Get the setting string of the vibration intensity setting this preference is dealing with.
+     */
+    @Override
+    protected String getVibrationIntensitySetting() {
+        return Settings.System.RING_VIBRATION_INTENSITY;
+    }
+
+    @Override
+    protected String getVibrationEnabledSetting() {
+        return Settings.System.VIBRATE_WHEN_RINGING;
+    }
+
+    @Override
+    protected int getPreviewVibrationAudioAttributesUsage() {
+        return AudioAttributes.USAGE_NOTIFICATION;
+    }
+
+    @Override
+    protected int getDefaultVibrationIntensity() {
+        Vibrator vibrator = getContext().getSystemService(Vibrator.class);
+        return vibrator.getDefaultRingVibrationIntensity();
+    }
+}
diff --git a/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java
index ba08a43..52fd069 100644
--- a/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java
@@ -45,6 +45,11 @@
     }
 
     @Override
+    protected String getVibrationEnabledSetting() {
+        return Settings.System.HAPTIC_FEEDBACK_ENABLED;
+    }
+
+    @Override
     protected int getDefaultVibrationIntensity() {
         Vibrator vibrator = getContext().getSystemService(Vibrator.class);
         return vibrator.getDefaultHapticFeedbackIntensity();
@@ -54,13 +59,4 @@
     protected int getPreviewVibrationAudioAttributesUsage() {
         return AudioAttributes.USAGE_ASSISTANCE_SONIFICATION;
     }
-
-    @Override
-    public void onVibrationIntensitySelected(int intensity) {
-        // We want to keep HAPTIC_FEEDBACK_ENABLED consistent with this setting since some
-        // applications check it directly before triggering their own haptic feedback.
-        final boolean hapticFeedbackEnabled = !(intensity == Vibrator.VIBRATION_INTENSITY_OFF);
-        Settings.System.putInt(getContext().getContentResolver(),
-                Settings.System.HAPTIC_FEEDBACK_ENABLED, hapticFeedbackEnabled ? 1 : 0);
-    }
 }
diff --git a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
index d9b1d79..e52f92d 100644
--- a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
@@ -39,14 +39,16 @@
     protected final Vibrator mVibrator;
     private final SettingObserver mSettingsContentObserver;
     private final String mSettingKey;
+    private final String mEnabledKey;
 
     private Preference mPreference;
 
     public VibrationIntensityPreferenceController(Context context, String prefkey,
-            String settingKey) {
+            String settingKey, String enabledKey) {
         super(context, prefkey);
         mVibrator = mContext.getSystemService(Vibrator.class);
         mSettingKey = settingKey;
+        mEnabledKey = enabledKey;
         mSettingsContentObserver = new SettingObserver(settingKey) {
             @Override
             public void onChange(boolean selfChange, Uri uri) {
@@ -78,7 +80,9 @@
     public CharSequence getSummary() {
         final int intensity = Settings.System.getInt(mContext.getContentResolver(),
                 mSettingKey, getDefaultIntensity());
-        return getIntensityString(mContext, intensity);
+        final boolean enabled = Settings.System.getInt(mContext.getContentResolver(),
+                mEnabledKey, 1) == 1;
+        return getIntensityString(mContext, enabled ? intensity : Vibrator.VIBRATION_INTENSITY_OFF);
    }
 
     public static CharSequence getIntensityString(Context context, int intensity) {
diff --git a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
index 1101611..648acad 100644
--- a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
@@ -26,6 +26,7 @@
 import android.os.VibrationEffect;
 import android.os.Vibrator;
 import android.provider.Settings;
+import android.text.TextUtils;
 import android.util.ArrayMap;
 import android.util.Log;
 
@@ -117,6 +118,11 @@
     protected abstract String getVibrationIntensitySetting();
 
     /**
+     * Get the setting string of the vibration enabledness setting this preference is dealing with.
+     */
+    protected abstract String getVibrationEnabledSetting();
+
+    /**
      * Get the default intensity for the desired setting.
      */
     protected abstract int getDefaultVibrationIntensity();
@@ -154,8 +160,13 @@
 
     @Override
     protected String getDefaultKey() {
-        final int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
+        int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
                 getVibrationIntensitySetting(), getDefaultVibrationIntensity());
+        final boolean vibrationEnabled = Settings.System.getInt(getContext().getContentResolver(),
+                getVibrationEnabledSetting(), 1) == 1;
+        if (!vibrationEnabled) {
+            vibrationIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
+        }
         for (VibrationIntensityCandidateInfo candidate : mCandidates.values()) {
             final boolean matchesIntensity = candidate.getIntensity() == vibrationIntensity;
             final boolean matchesOn = candidate.getKey().equals(KEY_INTENSITY_ON)
@@ -174,8 +185,11 @@
             Log.e(TAG, "Tried to set unknown intensity (key=" + key + ")!");
             return false;
         }
-        Settings.System.putInt(getContext().getContentResolver(),
-                getVibrationIntensitySetting(), candidate.getIntensity());
+        if (candidate.getIntensity() != Vibrator.VIBRATION_INTENSITY_OFF ||
+                TextUtils.isEmpty(getVibrationEnabledSetting())) {
+            Settings.System.putInt(getContext().getContentResolver(),
+                    getVibrationIntensitySetting(), candidate.getIntensity());
+        }
         onVibrationIntensitySelected(candidate.getIntensity());
         return true;
     }
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index eb5e02b..84745d2 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -179,6 +179,7 @@
         controllers.add(new FaceSettingsAttentionPreferenceController(context));
         controllers.add(new FaceSettingsRemoveButtonPreferenceController(context));
         controllers.add(new FaceSettingsFooterPreferenceController(context));
+        controllers.add(new FaceSettingsConfirmPreferenceController(context));
         return controllers;
     }
 
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsConfirmPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsConfirmPreferenceController.java
new file mode 100644
index 0000000..08740cf
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceSettingsConfirmPreferenceController.java
@@ -0,0 +1,62 @@
+/*
+ * 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.biometrics.face;
+
+import static android.provider.Settings.Secure.FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.core.TogglePreferenceController;
+
+/**
+ * Preference controller giving the user an option to always require confirmation.
+ */
+public class FaceSettingsConfirmPreferenceController extends TogglePreferenceController {
+
+    private static final String KEY = "security_settings_face_require_confirmation";
+
+    private static final int ON = 1;
+    private static final int OFF = 0;
+    private static final int DEFAULT = OFF;
+
+    public FaceSettingsConfirmPreferenceController(Context context) {
+        this(context, KEY);
+    }
+
+    public FaceSettingsConfirmPreferenceController(Context context,
+            String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public boolean isChecked() {
+        return Settings.Secure.getInt(mContext.getContentResolver(),
+                FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION, DEFAULT) == ON;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(),
+                FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION, isChecked ? ON : OFF);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
index 6ec419b..43de5a4 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
@@ -30,7 +30,7 @@
 import com.android.settings.core.FeatureFlags;
 import com.android.settings.dashboard.RestrictedDashboardFragment;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.slices.SlicePreferenceController;
+import com.android.settings.slices.BlockingSlicePrefController;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.core.AbstractPreferenceController;
@@ -106,7 +106,7 @@
         if (FeatureFlagUtils.isEnabled(context, FeatureFlags.SLICE_INJECTION)) {
             final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(context)
                     .getBluetoothFeatureProvider(context);
-            use(SlicePreferenceController.class).setSliceUri(
+            use(BlockingSlicePrefController.class).setSliceUri(
                     featureProvider.getBluetoothDeviceSettingsUri(mDeviceAddress));
         }
     }
diff --git a/src/com/android/settings/core/BasePreferenceController.java b/src/com/android/settings/core/BasePreferenceController.java
index facec4a..1c85009 100644
--- a/src/com/android/settings/core/BasePreferenceController.java
+++ b/src/com/android/settings/core/BasePreferenceController.java
@@ -106,6 +106,7 @@
 
 
     protected final String mPreferenceKey;
+    protected UiBlockListener mUiBlockListener;
 
     /**
      * Instantiate a controller as specified controller type and user-defined key.
@@ -289,4 +290,36 @@
      */
     public void updateRawDataToIndex(List<SearchIndexableRaw> rawData) {
     }
+
+    /**
+     * Set {@link UiBlockListener}
+     * @param uiBlockListener listener to set
+     */
+    public void setUiBlockListener(UiBlockListener uiBlockListener) {
+        mUiBlockListener = uiBlockListener;
+    }
+
+    /**
+     * Listener to invoke when background job is finished
+     */
+    public interface UiBlockListener {
+        /**
+         * To notify client that UI related background work is finished.
+         * (i.e. Slice is fully loaded.)
+         * @param controller Controller that contains background work
+         */
+        void onBlockerWorkFinished(BasePreferenceController controller);
+    }
+
+    /**
+     * Used for {@link BasePreferenceController} to decide whether it is ui blocker.
+     * If it is, entire UI will be invisible for a certain period until controller
+     * invokes {@link UiBlockListener}
+     *
+     * This won't block UI thread however has similar side effect. Please use it if you
+     * want to avoid janky animation(i.e. new preference is added in the middle of page).
+     *
+     * This music be used in {@link BasePreferenceController}
+     */
+    public interface UiBlocker {}
 }
\ No newline at end of file
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index 1916110..11858a7 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -56,7 +56,8 @@
  */
 public abstract class DashboardFragment extends SettingsPreferenceFragment
         implements SettingsBaseActivity.CategoryListener, Indexable,
-        SummaryLoader.SummaryConsumer, PreferenceGroup.OnExpandButtonClickListener {
+        SummaryLoader.SummaryConsumer, PreferenceGroup.OnExpandButtonClickListener,
+        BasePreferenceController.UiBlockListener {
     private static final String TAG = "DashboardFragment";
 
     private final Map<Class, List<AbstractPreferenceController>> mPreferenceControllers =
@@ -67,6 +68,7 @@
     private DashboardTilePlaceholderPreferenceController mPlaceholderPreferenceController;
     private boolean mListeningToCategoryChange;
     private SummaryLoader mSummaryLoader;
+    private UiBlockerController mBlockerController;
 
     @Override
     public void onAttach(Context context) {
@@ -105,6 +107,22 @@
         for (AbstractPreferenceController controller : controllers) {
             addPreferenceController(controller);
         }
+
+        checkUiBlocker(controllers);
+    }
+
+    private void checkUiBlocker(List<AbstractPreferenceController> controllers) {
+        final List<String> keys = new ArrayList<>();
+        controllers
+                .stream()
+                .filter(controller -> controller instanceof BasePreferenceController.UiBlocker)
+                .forEach(controller -> {
+                    ((BasePreferenceController) controller).setUiBlockListener(this);
+                    keys.add(controller.getPreferenceKey());
+                });
+
+        mBlockerController = new UiBlockerController(keys);
+        mBlockerController.start(()->updatePreferenceVisibility());
     }
 
     @Override
@@ -319,10 +337,11 @@
      * DashboardCategory.
      */
     private void refreshAllPreferences(final String TAG) {
+        final PreferenceScreen screen = getPreferenceScreen();
         // First remove old preferences.
-        if (getPreferenceScreen() != null) {
+        if (screen != null) {
             // Intentionally do not cache PreferenceScreen because it will be recreated later.
-            getPreferenceScreen().removeAll();
+            screen.removeAll();
         }
 
         // Add resource based tiles.
@@ -335,6 +354,27 @@
             Log.d(TAG, "All preferences added, reporting fully drawn");
             activity.reportFullyDrawn();
         }
+
+        updatePreferenceVisibility();
+    }
+
+    private void updatePreferenceVisibility() {
+        final PreferenceScreen screen = getPreferenceScreen();
+        if (screen == null) {
+            return;
+        }
+
+        final boolean visible = mBlockerController.isBlockerFinished();
+        for (List<AbstractPreferenceController> controllerList :
+                mPreferenceControllers.values()) {
+            for (AbstractPreferenceController controller : controllerList) {
+                final String key = controller.getPreferenceKey();
+                final Preference preference = screen.findPreference(key);
+                if (preference != null) {
+                    preference.setVisible(visible && controller.isAvailable());
+                }
+            }
+        }
     }
 
     /**
@@ -413,4 +453,9 @@
         }
         mSummaryLoader.setListening(true);
     }
+
+    @Override
+    public void onBlockerWorkFinished(BasePreferenceController controller) {
+        mBlockerController.countDown(controller.getPreferenceKey());
+    }
 }
diff --git a/src/com/android/settings/dashboard/UiBlockerController.java b/src/com/android/settings/dashboard/UiBlockerController.java
new file mode 100644
index 0000000..eeb56e6
--- /dev/null
+++ b/src/com/android/settings/dashboard/UiBlockerController.java
@@ -0,0 +1,101 @@
+/*
+ * 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.dashboard;
+
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.utils.ThreadUtils;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Control ui blocker data and check whether it is finished
+ *
+ * @see BasePreferenceController.UiBlocker
+ * @see BasePreferenceController.OnUiBlockListener
+ */
+public class UiBlockerController {
+    private static final String TAG = "UiBlockerController";
+    private static final int TIMEOUT_MILLIS = 500;
+
+    private CountDownLatch mCountDownLatch;
+    private boolean mBlockerFinished;
+    private Set<String> mKeys;
+    private long mTimeoutMillis;
+
+    public UiBlockerController(@NonNull List<String> keys) {
+        this(keys, TIMEOUT_MILLIS);
+    }
+
+    public UiBlockerController(@NonNull List<String> keys, long timeout) {
+        mCountDownLatch = new CountDownLatch(keys.size());
+        mBlockerFinished = keys.isEmpty();
+        mKeys = new HashSet<>(keys);
+        mTimeoutMillis = timeout;
+    }
+
+    /**
+     * Start background thread, it will invoke {@code finishRunnable} if any condition is met
+     *
+     * 1. Waiting time exceeds {@link #mTimeoutMillis}
+     * 2. All background work that associated with {@link #mCountDownLatch} is finished
+     */
+    public boolean start(Runnable finishRunnable) {
+        if (mKeys.isEmpty()) {
+            // Don't need to run finishRunnable because it doesn't start
+            return false;
+        }
+        ThreadUtils.postOnBackgroundThread(() -> {
+            try {
+                mCountDownLatch.await(mTimeoutMillis, TimeUnit.MILLISECONDS);
+            } catch (InterruptedException e) {
+                Log.w(TAG, "interrupted");
+            }
+            mBlockerFinished = true;
+            ThreadUtils.postOnMainThread(finishRunnable);
+        });
+
+        return true;
+    }
+
+    /**
+     * Return {@code true} if all work finished
+     */
+    public boolean isBlockerFinished() {
+        return mBlockerFinished;
+    }
+
+    /**
+     * Count down latch by {@code key}. It only count down 1 time if same key count down multiple
+     * times.
+     */
+    public boolean countDown(String key) {
+        if (mKeys.remove(key)) {
+            mCountDownLatch.countDown();
+            return true;
+        }
+
+        return false;
+    }
+}
diff --git a/src/com/android/settings/notification/NotificationStation.java b/src/com/android/settings/notification/NotificationStation.java
index 116980f..91ebc88 100644
--- a/src/com/android/settings/notification/NotificationStation.java
+++ b/src/com/android/settings/notification/NotificationStation.java
@@ -372,7 +372,7 @@
             sb.append("\n")
                     .append(bold(getString(R.string.notification_log_details_sound)))
                     .append(delim);
-            if (channel.getImportance() == IMPORTANCE_UNSPECIFIED) {
+            if (channel == null || channel.getImportance() == IMPORTANCE_UNSPECIFIED) {
 
                 if (0 != (n.defaults & Notification.DEFAULT_SOUND)) {
                     sb.append(getString(R.string.notification_log_details_default));
@@ -387,7 +387,7 @@
             sb.append("\n")
                     .append(bold(getString(R.string.notification_log_details_vibrate)))
                     .append(delim);
-            if (channel.getImportance() == IMPORTANCE_UNSPECIFIED) {
+            if (channel == null || channel.getImportance() == IMPORTANCE_UNSPECIFIED) {
                 if (0 != (n.defaults & Notification.DEFAULT_VIBRATE)) {
                     sb.append(getString(R.string.notification_log_details_default));
                 } else if (n.vibrate != null) {
diff --git a/src/com/android/settings/slices/BlockingSlicePrefController.java b/src/com/android/settings/slices/BlockingSlicePrefController.java
new file mode 100644
index 0000000..94810c5
--- /dev/null
+++ b/src/com/android/settings/slices/BlockingSlicePrefController.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2018 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.slices;
+
+import android.content.Context;
+
+import androidx.slice.Slice;
+
+import com.android.settings.core.BasePreferenceController;
+
+/**
+ * The blocking slice preference controller. It will make whole page invisible for a certain time
+ * until {@link Slice} is fully loaded.
+ */
+public class BlockingSlicePrefController extends SlicePreferenceController implements
+        BasePreferenceController.UiBlocker {
+
+    public BlockingSlicePrefController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public void onChanged(Slice slice) {
+        super.onChanged(slice);
+        if (mUiBlockListener != null) {
+            mUiBlockListener.onBlockerWorkFinished(this);
+        }
+    }
+}
diff --git a/src/com/android/settings/slices/SlicePreferenceController.java b/src/com/android/settings/slices/SlicePreferenceController.java
index 8c751c8..93ba652 100644
--- a/src/com/android/settings/slices/SlicePreferenceController.java
+++ b/src/com/android/settings/slices/SlicePreferenceController.java
@@ -51,8 +51,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
 
-        mSlicePreference = (SlicePreference) screen.findPreference(
-                getPreferenceKey());
+        mSlicePreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java
index 68d5e36..9f83f72 100644
--- a/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java
@@ -161,6 +161,11 @@
         }
 
         @Override
+        protected String getVibrationEnabledSetting() {
+            return "";
+        }
+
+        @Override
         protected int getDefaultVibrationIntensity() {
             return Vibrator.VIBRATION_INTENSITY_MEDIUM;
         }
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
index 21d62bc..be77283 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
@@ -26,6 +26,8 @@
 import android.content.Context;
 import android.os.Bundle;
 
+import androidx.preference.PreferenceScreen;
+
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -49,9 +51,10 @@
 
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private CachedBluetoothDevice mCachedDevice;
-
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private LocalBluetoothManager mLocalManager;
+    @Mock
+    private PreferenceScreen mPreferenceScreen;
 
     @Before
     public void setUp() {
@@ -62,6 +65,7 @@
         mFragment = spy(BluetoothDeviceDetailsFragment.newInstance(TEST_ADDRESS));
         doReturn(mLocalManager).when(mFragment).getLocalBluetoothManager(any());
         doReturn(mCachedDevice).when(mFragment).getCachedDevice(any());
+        doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
 
         when(mCachedDevice.getAddress()).thenReturn(TEST_ADDRESS);
         Bundle args = new Bundle();
diff --git a/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
index b0de024..73c0d8e 100644
--- a/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
@@ -74,7 +74,7 @@
         final AppOpsManager.PackageOps packageOps =
                 new AppOpsManager.PackageOps(appName, 0,
                         Collections.singletonList(createOpEntry(AppOpsManager.MODE_ALLOWED)));
-        when(mAppOpsManager.getPackagesForOps(any())).thenReturn(
+        when(mAppOpsManager.getPackagesForOps(any(int[].class))).thenReturn(
                 Collections.singletonList(packageOps));
 
         mController.updateState(mPreference);
@@ -84,7 +84,8 @@
 
     @Test
     public void updateState_noAppSelected_shouldSetSummaryToDefault() {
-        when(mAppOpsManager.getPackagesForOps(any())).thenReturn(Collections.emptyList());
+        when(mAppOpsManager.getPackagesForOps(any(int[].class)))
+                .thenReturn(Collections.emptyList());
 
         mController.updateState(mPreference);
 
@@ -101,7 +102,7 @@
         final AppOpsManager.PackageOps packageOps = new AppOpsManager.PackageOps(prevAppName, 0,
                 Collections.singletonList(createOpEntry(AppOpsManager.MODE_ALLOWED)));
 
-        when(mAppOpsManager.getPackagesForOps(any()))
+        when(mAppOpsManager.getPackagesForOps(any(int[].class)))
                 .thenReturn(Collections.singletonList(packageOps));
         when(mPackageManager.getApplicationInfo(anyString(),
                 eq(PackageManager.MATCH_DISABLED_COMPONENTS))).thenReturn(mApplicationInfo);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
index 3746d64..368a93a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
@@ -111,7 +111,7 @@
     @Test
     public void testUpdateState_oneApp_showCorrectSummary() {
         mPackageOpsList.add(mRestrictedPackageOps);
-        doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any());
+        doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any(int[].class));
 
         mRestrictAppPreferenceController.updateState(mPreference);
 
@@ -124,7 +124,7 @@
         mPackageOpsList.add(mRestrictedPackageOps);
         mPackageOpsList.add(mAllowedPackageOps);
         mPackageOpsList.add(mOtherUserPackageOps);
-        doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any());
+        doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any(int[].class));
 
         mRestrictAppPreferenceController.updateState(mPreference);
 
@@ -137,7 +137,7 @@
         // Two packageOps share same package name but different uid.
         mPackageOpsList.add(mRestrictedPackageOps);
         mPackageOpsList.add(mOtherUserPackageOps);
-        doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any());
+        doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any(int[].class));
 
         mRestrictAppPreferenceController.updateState(mPreference);
 
@@ -152,7 +152,7 @@
     @Test
     public void testUpdateState_zeroRestrictApp_inVisible() {
         mPackageOpsList.add(mAllowedPackageOps);
-        doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any());
+        doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any(int[].class));
 
         mRestrictAppPreferenceController.updateState(mPreference);
 
diff --git a/tests/unit/src/com/android/settings/dashboard/UiBlockerControllerTest.java b/tests/unit/src/com/android/settings/dashboard/UiBlockerControllerTest.java
new file mode 100644
index 0000000..c3a7a4e
--- /dev/null
+++ b/tests/unit/src/com/android/settings/dashboard/UiBlockerControllerTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2018 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.dashboard;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Instrumentation;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.MediumTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.Arrays;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(AndroidJUnit4.class)
+@MediumTest
+public class UiBlockerControllerTest {
+    private static final long TIMEOUT = 600;
+    private static final String KEY_1 = "key1";
+    private static final String KEY_2 = "key2";
+
+    private Instrumentation mInstrumentation;
+    private UiBlockerController mSyncableController;
+
+    @Before
+    public void setUp() throws Exception {
+        mInstrumentation = InstrumentationRegistry.getInstrumentation();
+
+        mSyncableController = new UiBlockerController(Arrays.asList(KEY_1, KEY_2));
+    }
+
+    @Test
+    public void start_isSyncedReturnFalseUntilAllWorkDone() throws InterruptedException {
+        final CountDownLatch latch = new CountDownLatch(1);
+        mSyncableController.start(() -> latch.countDown());
+
+        // Return false at first
+        assertThat(mSyncableController.isBlockerFinished()).isFalse();
+
+        // Return false if only one job is done
+        mSyncableController.countDown(KEY_1);
+        assertThat(mSyncableController.isBlockerFinished()).isFalse();
+
+        // Return true if all jobs done
+        mSyncableController.countDown(KEY_2);
+        assertThat(latch.await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue();
+        assertThat(mSyncableController.isBlockerFinished()).isTrue();
+    }
+}
diff --git a/tests/unit/src/com/android/settings/vpn2/AppSettingsTest.java b/tests/unit/src/com/android/settings/vpn2/AppSettingsTest.java
index 1a9701d..014d8ea 100644
--- a/tests/unit/src/com/android/settings/vpn2/AppSettingsTest.java
+++ b/tests/unit/src/com/android/settings/vpn2/AppSettingsTest.java
@@ -57,23 +57,24 @@
         };
 
         // List with one package op
-        when(mAppOps.getOpsForPackage(eq(mockApp.uid), eq(mockApp.packageName), any()))
-                .thenReturn(Arrays.asList(new AppOpsManager.PackageOps[] {blankOps[0]}));
+        when(mAppOps.getOpsForPackage(eq(mockApp.uid), eq(mockApp.packageName),
+                any(int[].class))).thenReturn(Arrays.asList(
+                        new AppOpsManager.PackageOps[] {blankOps[0]}));
         assertTrue(appHasVpnPermission(mContext, mockApp));
 
         // List with more than one package op
-        when(mAppOps.getOpsForPackage(eq(mockApp.uid), eq(mockApp.packageName), any()))
-                .thenReturn(Arrays.asList(blankOps));
+        when(mAppOps.getOpsForPackage(eq(mockApp.uid), eq(mockApp.packageName),
+                any(int[].class))).thenReturn(Arrays.asList(blankOps));
         assertTrue(appHasVpnPermission(mContext, mockApp));
 
         // Empty list
-        when(mAppOps.getOpsForPackage(eq(mockApp.uid), eq(mockApp.packageName), any()))
-                .thenReturn(Collections.emptyList());
+        when(mAppOps.getOpsForPackage(eq(mockApp.uid), eq(mockApp.packageName),
+                any(int[].class))).thenReturn(Collections.emptyList());
         assertFalse(appHasVpnPermission(mContext, mockApp));
 
         // Null list (may be returned in place of an empty list)
-        when(mAppOps.getOpsForPackage(eq(mockApp.uid), eq(mockApp.packageName), any()))
-                .thenReturn(null);
+        when(mAppOps.getOpsForPackage(eq(mockApp.uid), eq(mockApp.packageName),
+                any(int[].class))).thenReturn(null);
         assertFalse(appHasVpnPermission(mContext, mockApp));
     }