Merge "Remove viewFlipper used in contextual card dismissal." into qt-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 468eecd..7180a0f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1007,6 +1007,10 @@
     <string name="skip_anyway_button_label">Skip anyway</string>
     <!-- Button for going to the previous screen or step [CHAR LIMIT=20] -->
     <string name="go_back_button_label">Go back</string>
+    <!-- Button text to skip lock screen setup [CHAR LIMIT=20] -->
+    <string name="skip_lock_screen_dialog_button_label">Skip</string>
+    <!-- Button text to cancel lock screen skip dialog [CHAR LIMIT=20] -->
+    <string name="cancel_lock_screen_dialog_button_label">Cancel</string>
     <!-- Introduction title shown in fingerprint enrollment dialog to locate the sensor [CHAR LIMIT=29] -->
     <string name="security_settings_fingerprint_enroll_find_sensor_title">Touch the sensor</string>
     <!-- Message shown in fingerprint enrollment dialog to locate the sensor -->
@@ -1037,6 +1041,24 @@
     <string name="setup_fingerprint_enroll_enrolling_skip_title">Skip fingerprint setup?</string>
     <!-- Content of the dialog shown when the user tries to skip fingerprint setup, asking them to confirm the action [CHAR LIMIT=NONE] -->
     <string name="setup_fingerprint_enroll_enrolling_skip_message">You\u2019ve chosen to use your fingerprint as one way to unlock your phone. If you skip now, you\u2019ll need to set this up later. Setup takes only a minute or so.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (tablet) [CHAR LIMIT=NONE] -->
+    <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (device) [CHAR LIMIT=NONE] -->
+    <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (default) [CHAR LIMIT=NONE] -->
+    <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (tablet) [CHAR LIMIT=NONE] -->
+    <string name="face_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (device) [CHAR LIMIT=NONE] -->
+    <string name="face_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (default) [CHAR LIMIT=NONE] -->
+    <string name="face_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Title of dialog shown when the user tries to skip setting up a PIN, warning them of potential consequences of not doing so [CHAR LIMIT=30]-->
+    <string name="lock_screen_pin_skip_title">Skip PIN Setup?</string>
+    <!-- Title of dialog shown when the user tries to skip setting up a password, warning them of potential consequences of not doing so [CHAR LIMIT=30]-->
+    <string name="lock_screen_password_skip_title">Skip Password Setup?</string>
+    <!-- Title of dialog shown when the user tries to skip setting up a pattern, warning them of potential consequences of not doing so [CHAR LIMIT=30]-->
+    <string name="lock_screen_pattern_skip_title">Skip Pattern Setup?</string>
 
     <!-- Button text to setup screen lock in onboard dialog [CHAR LIMIT=34] -->
     <string name="security_settings_fingerprint_enroll_setup_screen_lock">Set up screen lock</string>
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index 97a4182..cf25a15 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -19,13 +19,6 @@
                   android:title="@string/configure_notification_settings"
                   android:key="configure_notification_settings">
 
-    <com.android.settingslib.widget.apppreference.AppPreference
-        android:key="notification_assistant"
-        android:title="@string/notification_assistant_title"
-        android:summary="@string/summary_placeholder"
-        settings:fragment="com.android.settings.notification.NotificationAssistantPicker"
-        settings:controller="com.android.settings.notification.NotificationAssistantPreferenceController"/>
-
     <SwitchPreference
         android:key="asst_capability_prioritizer"
         android:title="@string/asst_capability_prioritizer_title"
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index cb97fee..e8265b2 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -65,6 +65,13 @@
             android:value="com.android.settings.Settings$WriteSettingsActivity" />
     </Preference>
 
+    <com.android.settingslib.widget.apppreference.AppPreference
+        android:key="notification_assistant"
+        android:title="@string/notification_assistant_title"
+        android:summary="@string/summary_placeholder"
+        settings:fragment="com.android.settings.notification.NotificationAssistantPicker"
+        settings:controller="com.android.settings.notification.NotificationAssistantPreferenceController"/>
+
     <Preference
         android:key="notification_access"
         android:title="@string/manage_notification_access_title"
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java
index eb062e8..07e23de 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.content.Intent;
+import android.os.Build;
 import android.text.TextUtils;
 
 import androidx.annotation.VisibleForTesting;
@@ -82,7 +83,7 @@
     @VisibleForTesting
     void showFeedbackDialog(ContextualCard card) {
         final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
-        if (TextUtils.isEmpty(email)) {
+        if (!isFeedbackEnabled(email)) {
             return;
         }
         final Intent feedbackIntent = new Intent(mContext, ContextualCardFeedbackDialog.class);
@@ -93,6 +94,11 @@
         mContext.startActivity(feedbackIntent);
     }
 
+    @VisibleForTesting
+    boolean isFeedbackEnabled(String email) {
+        return !TextUtils.isEmpty(email) && Build.IS_DEBUGGABLE;
+    }
+
     private String getSimpleCardName(ContextualCard card) {
         final String[] split = card.getName().split("/");
         return split[split.length - 1];
diff --git a/src/com/android/settings/slices/SliceDataConverter.java b/src/com/android/settings/slices/SliceDataConverter.java
index db46c26..14abd1b 100644
--- a/src/com/android/settings/slices/SliceDataConverter.java
+++ b/src/com/android/settings/slices/SliceDataConverter.java
@@ -78,11 +78,8 @@
 
     private Context mContext;
 
-    private List<SliceData> mSliceData;
-
     public SliceDataConverter(Context context) {
         mContext = context;
-        mSliceData = new ArrayList<>();
     }
 
     /**
@@ -96,9 +93,7 @@
      * {@link com.android.settings.core.BasePreferenceController}.
      */
     public List<SliceData> getSliceData() {
-        if (!mSliceData.isEmpty()) {
-            return mSliceData;
-        }
+        List<SliceData> sliceData = new ArrayList<>();
 
         final Collection<Class> indexableClasses = FeatureFactory.getFactory(mContext)
                 .getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
@@ -117,12 +112,12 @@
 
             final List<SliceData> providerSliceData = getSliceDataFromProvider(provider,
                     fragmentName);
-            mSliceData.addAll(providerSliceData);
+            sliceData.addAll(providerSliceData);
         }
 
         final List<SliceData> a11ySliceData = getAccessibilitySliceData();
-        mSliceData.addAll(a11ySliceData);
-        return mSliceData;
+        sliceData.addAll(a11ySliceData);
+        return sliceData;
     }
 
     private List<SliceData> getSliceDataFromProvider(SearchIndexProvider provider,
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java
index e97e01e..94fbb97 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java
@@ -18,8 +18,10 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
@@ -28,7 +30,9 @@
 import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
+import android.os.Build;
 
+import com.android.settings.R;
 import com.android.settings.homepage.contextualcards.CardContentProvider;
 import com.android.settings.homepage.contextualcards.CardDatabaseHelper;
 import com.android.settings.homepage.contextualcards.ContextualCard;
@@ -48,6 +52,7 @@
 import org.robolectric.shadows.ShadowActivity;
 import org.robolectric.shadows.ShadowContentResolver;
 import org.robolectric.shadows.androidx.fragment.FragmentController;
+import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(RobolectricTestRunner.class)
 public class SliceContextualCardControllerTest {
@@ -95,11 +100,12 @@
     }
 
     @Test
-    public void onDismissed_noFeedbackEmail_shouldNotShowFeedbackDialog() {
+    public void onDismissed_feedbackDisabled_shouldNotShowFeedbackDialog() {
         mResolver.insert(CardContentProvider.REFRESH_CARD_URI, generateOneRow());
         final ContextualCardsFragment fragment =
                 FragmentController.of(new ContextualCardsFragment()).create().get();
         final ShadowActivity shadowActivity = Shadows.shadowOf(fragment.getActivity());
+        doReturn(false).when(mController).isFeedbackEnabled(anyString());
 
         mController.onDismissed(getTestSliceCard());
 
@@ -107,12 +113,12 @@
     }
 
     @Test
-    @Config(qualifiers = "mcc999")
-    public void onDismissed_hasFeedbackEmail_shouldShowFeedbackDialog() {
+    public void onDismissed_feedbackEnabled_shouldShowFeedbackDialog() {
         mResolver.insert(CardContentProvider.REFRESH_CARD_URI, generateOneRow());
         final ContextualCardsFragment fragment =
                 FragmentController.of(new ContextualCardsFragment()).create().get();
         final ShadowActivity shadowActivity = Shadows.shadowOf(fragment.getActivity());
+        doReturn(true).when(mController).isFeedbackEnabled(anyString());
 
         mController.onDismissed(getTestSliceCard());
 
@@ -120,6 +126,40 @@
                 .isEqualTo(ContextualCardFeedbackDialog.class.getName());
     }
 
+    @Test
+    @Config(qualifiers = "mcc999")
+    public void isFeedbackEnabled_hasFeedbackEmail_debug_returnTrue() {
+        ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
+        final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
+
+        assertThat(mController.isFeedbackEnabled(email)).isTrue();
+    }
+
+    @Test
+    @Config(qualifiers = "mcc999")
+    public void isFeedbackEnabled_hasFeedbackEmail_user_returnFalse() {
+        ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false);
+        final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
+
+        assertThat(mController.isFeedbackEnabled(email)).isFalse();
+    }
+
+    @Test
+    public void isFeedbackEnabled_noFeedbackEmail_debug_returnFalse() {
+        ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
+        final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
+
+        assertThat(mController.isFeedbackEnabled(email)).isFalse();
+    }
+
+    @Test
+    public void isFeedbackEnabled_noFeedbackEmail_user_returnFalse() {
+        ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false);
+        final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
+
+        assertThat(mController.isFeedbackEnabled(email)).isFalse();
+    }
+
     private ContentValues generateOneRow() {
         final ContentValues values = new ContentValues();
         values.put(CardDatabaseHelper.CardColumns.NAME, TEST_CARD_NAME);