OSDN Git Service

Merge "Increased char limit for translations" into qt-dev
authorJoshua Mccloskey <joshmccloskey@google.com>
Tue, 14 May 2019 19:13:11 +0000 (19:13 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Tue, 14 May 2019 19:13:11 +0000 (19:13 +0000)
43 files changed:
AndroidManifest.xml
res/drawable-nodpi/system_nav_2_button.png [moved from res/drawable-nodpi/gesture_swipe_up.png with 100% similarity]
res/drawable-nodpi/system_nav_3_button.png [new file with mode: 0644]
res/drawable-nodpi/system_nav_fully_gestural.png [new file with mode: 0644]
res/layout/settings_base_layout.xml
res/raw/system_nav_2_button.mp4 [moved from res/raw/gesture_swipe_up.mp4 with 100% similarity]
res/raw/system_nav_3_button.mp4 [new file with mode: 0644]
res/raw/system_nav_fully_gestural.mp4 [new file with mode: 0644]
res/values/strings.xml
res/values/themes.xml
res/xml/gestures.xml
res/xml/system_navigation_gesture_settings.xml
src/com/android/settings/SettingsActivity.java
src/com/android/settings/SetupWizardUtils.java
src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
src/com/android/settings/biometrics/face/FaceEnrollEducation.java
src/com/android/settings/core/SettingsBaseActivity.java
src/com/android/settings/core/SubSettingLauncher.java
src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java [deleted file]
src/com/android/settings/gestures/SystemNavigationGestureSettings.java
src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java [deleted file]
src/com/android/settings/gestures/SystemNavigationPreferenceController.java
src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java [deleted file]
src/com/android/settings/homepage/SettingsHomepageActivity.java
src/com/android/settings/network/telephony/ApnPreferenceController.java
src/com/android/settings/network/telephony/MobileNetworkUtils.java
src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
src/com/android/settings/wifi/WifiConfigController.java
src/com/android/settings/wifi/WifiSettings.java
src/com/android/settings/wifi/WifiUtils.java
src/com/android/settings/wifi/slice/WifiSlice.java
tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java
tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java [deleted file]
tests/robotests/src/com/android/settings/gestures/SystemNavigationGestureSettingsTest.java [new file with mode: 0644]
tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java [deleted file]
tests/robotests/src/com/android/settings/gestures/SystemNavigationPreferenceControllerTest.java [moved from tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java with 57% similarity]
tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java
tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java

index 6afdc23..1a5c239 100644 (file)
         </receiver>
 
         <activity android:name=".SubSettings"
-                android:parentActivityName="Settings"
-                android:theme="@style/Theme.SubSettings"/>
+                android:parentActivityName="Settings" />
 
         <activity android:name=".Settings$CreateShortcutActivity"
                   android:label="@string/settings_shortcut">
                 <action android:name="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                android:value="com.android.settings.accessibility.AccessibilitySettingsForSetupWizard" />
+            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+                android:value="true" />
+        </activity>
+
+        <activity-alias
+            android:name=".FontSizeSettingsForSetupWizardActivity"
+            android:exported="true"
+            android:targetActivity=".accessibility.AccessibilitySettingsForSetupWizardActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="com.android.settings.suggested.category.DISPLAY_SETTINGS" />
                 android:value="true" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.accessibility.AccessibilitySettingsForSetupWizard" />
-            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                android:value="true" />
-        </activity>
+        </activity-alias>
 
         <activity
             android:name="Settings$AccessibilityDaltonizerSettingsActivity"
diff --git a/res/drawable-nodpi/system_nav_3_button.png b/res/drawable-nodpi/system_nav_3_button.png
new file mode 100644 (file)
index 0000000..e78fc8b
Binary files /dev/null and b/res/drawable-nodpi/system_nav_3_button.png differ
diff --git a/res/drawable-nodpi/system_nav_fully_gestural.png b/res/drawable-nodpi/system_nav_fully_gestural.png
new file mode 100644 (file)
index 0000000..b301608
Binary files /dev/null and b/res/drawable-nodpi/system_nav_fully_gestural.png differ
index f94d25d..7216d76 100644 (file)
@@ -19,7 +19,6 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:fitsSystemWindows="true"
     android:orientation="vertical">
     <Toolbar
         android:id="@+id/action_bar"
@@ -31,5 +30,6 @@
     <FrameLayout
         android:id="@+id/content_frame"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"/>
+        android:layout_height="fill_parent"
+        android:background="?android:attr/windowBackground" />
 </LinearLayout>
diff --git a/res/raw/system_nav_3_button.mp4 b/res/raw/system_nav_3_button.mp4
new file mode 100644 (file)
index 0000000..1287f28
Binary files /dev/null and b/res/raw/system_nav_3_button.mp4 differ
diff --git a/res/raw/system_nav_fully_gestural.mp4 b/res/raw/system_nav_fully_gestural.mp4
new file mode 100644 (file)
index 0000000..165ce33
Binary files /dev/null and b/res/raw/system_nav_fully_gestural.mp4 differ
index e669a26..26cdde1 100644 (file)
     <string name="security_settings_face_enroll_education_title_unlock_disabled">Use your face to authenticate</string>
     <!-- Introduction detail message shown in face education [CHAR LIMIT=NONE] -->
     <string name="security_settings_face_enroll_education_message"></string>
+    <!-- Button that takes the user to the enrollment activity [CHAR LIMIT=20] -->
+    <string name="security_settings_face_enroll_education_start">Start</string>
     <!-- Button shown which shows accessibility toggles for face enrollment when clicked. [CHAR LIMIT=32] -->
     <string name="security_settings_face_enroll_introduction_accessibility">Use accessibility setup</string>
     <!-- Additional details shown when the accessibility toggle is expanded. [CHAR LIMIT=NONE]-->
index 4249f97..ce4eaaf 100644 (file)
 
     <style name="Theme.Settings" parent="Theme.SettingsBase">
         <item name="preferenceTheme">@style/PreferenceTheme</item>
-        <item name="android:clipToPadding">false</item>
-        <item name="android:clipChildren">false</item>
         <item name="android:listPreferredItemHeight">72dip</item>
         <item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
-        <item name="android:navigationBarColor">@android:color/transparent</item>
 
         <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
         <item name="face_layout_theme">@style/FaceLayoutTheme</item>
         <item name="android:textColorSecondary">@*android:color/secondary_text_light</item>
     </style>
 
+    <!-- Light theme for those pages inherit SubSettings and launched during setup flow -->
+    <style name="LightTheme.SubSettings.SetupWizard" parent="@android:style/Theme.DeviceDefault.Light">
+        <item name="android:windowLightStatusBar">true</item>
+        <item name="android:statusBarColor">@android:color/white</item>
+        <item name="android:navigationBarColor">@android:color/white</item>
+        <item name="android:windowLightNavigationBar">true</item>
+        <item name="android:windowBackground">@android:color/white</item>
+        <item name="android:navigationBarDividerColor">@*android:color/navigation_bar_divider_device_default_settings</item>
+
+        <item name="android:colorPrimary">@android:color/white</item>
+        <item name="android:colorPrimaryDark">@android:color/white</item>
+        <item name="android:colorAccent">@color/material_blue_700</item>
+    </style>
 </resources>
index 5dcb1b0..ff3a6b5 100644 (file)
@@ -49,7 +49,7 @@
         android:key="gesture_system_navigation_input_summary"
         android:title="@string/system_navigation_title"
         android:fragment="com.android.settings.gestures.SystemNavigationGestureSettings"
-        settings:controller="com.android.settings.gestures.SystemNavigationLegacyPreferenceController" />
+        settings:controller="com.android.settings.gestures.SystemNavigationPreferenceController" />
 
     <Preference
         android:key="gesture_tap_screen_input_summary"
index 97aacb8..b1045fc 100644 (file)
 
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="gesture_system_navigation_screen"
-    android:title="@string/system_navigation_title">
-
-    <com.android.settings.widget.VideoPreference
-        android:key="gesture_swipe_up_video"
-        app:animation="@raw/gesture_swipe_up"
-        app:preview="@drawable/gesture_swipe_up" />
-
-    <com.android.settings.widget.RadioButtonPreference
-        android:key="gesture_edge_to_edge"
-        android:title="@string/edge_to_edge_navigation_title"
-        android:summary="@string/edge_to_edge_navigation_summary"
-        app:keywords="@string/keywords_gesture"
-        app:controller="com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController"
-        app:allowDividerAbove="true" />
-
-    <com.android.settings.widget.RadioButtonPreference
-        android:key="gesture_swipe_up"
-        android:title="@string/swipe_up_to_switch_apps_title"
-        android:summary="@string/swipe_up_to_switch_apps_summary"
-        app:keywords="@string/keywords_gesture"
-        app:controller="com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController" />
-
-    <com.android.settings.widget.RadioButtonPreference
-        android:key="gesture_legacy"
-        android:title="@string/legacy_navigation_title"
-        android:summary="@string/legacy_navigation_summary"
-        app:keywords="@string/keywords_gesture"
-        app:controller="com.android.settings.gestures.SystemNavigationLegacyPreferenceController" />
-
-</PreferenceScreen>
\ No newline at end of file
+    android:title="@string/system_navigation_title"
+    settings:keywords="@string/keywords_system_navigation"/>
index 54c822e..5c553e1 100644 (file)
@@ -35,6 +35,7 @@ import android.os.UserManager;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
+import android.view.ViewGroup;
 import android.widget.Button;
 
 import androidx.annotation.Nullable;
@@ -50,6 +51,7 @@ import androidx.preference.PreferenceManager;
 import com.android.internal.util.ArrayUtils;
 import com.android.settings.Settings.WifiSettingsActivity;
 import com.android.settings.applications.manageapplications.ManageApplications;
+import com.android.settings.backup.BackupSettingsHelper;
 import com.android.settings.backup.UserBackupSettingsActivity;
 import com.android.settings.core.OnActivityResultListener;
 import com.android.settings.core.SettingsBaseActivity;
@@ -65,6 +67,8 @@ import com.android.settingslib.core.instrumentation.SharedPreferencesLogger;
 import com.android.settingslib.development.DevelopmentSettingsEnabler;
 import com.android.settingslib.drawer.DashboardCategory;
 
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -164,6 +168,8 @@ public class SettingsActivity extends SettingsBaseActivity
 
     private Button mNextButton;
 
+    private ViewGroup mContent;
+
     // Categories
     private ArrayList<DashboardCategory> mCategories = new ArrayList<>();
 
@@ -239,13 +245,17 @@ public class SettingsActivity extends SettingsBaseActivity
                 intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
 
         // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content
-        // insets
-        if (isSubSettings) {
+        // insets.
+        // If this is in setup flow, don't apply theme. Because light theme needs to be applied
+        // in SettingsBaseActivity#onCreate().
+        if (isSubSettings && !WizardManagerHelper.isAnySetupWizard(getIntent())) {
             setTheme(R.style.Theme_SubSettings);
         }
 
         setContentView(R.layout.settings_main_prefs);
 
+        mContent = findViewById(R.id.main_content);
+
         getSupportFragmentManager().addOnBackStackChangedListener(this);
 
         if (savedState != null) {
index 077d94c..bce6f3f 100644 (file)
 
 package com.android.settings;
 
+import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_FIRST_RUN;
+import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_SETUP_FLOW;
+
 import android.content.Intent;
+import android.os.Bundle;
 import android.sysprop.SetupWizardProperties;
 
 import com.google.android.setupcompat.util.WizardManagerHelper;
 import com.google.android.setupdesign.util.ThemeHelper;
 
+import java.util.Arrays;
+
 
 public class SetupWizardUtils {
 
@@ -90,4 +96,14 @@ public class SetupWizardUtils {
     public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
         WizardManagerHelper.copyWizardManagerExtras(fromIntent, toIntent);
     }
+
+    public static Bundle copyLifecycleExtra(Bundle srcBundle, Bundle dstBundle) {
+        for (String key :
+                Arrays.asList(
+                        EXTRA_IS_FIRST_RUN,
+                        EXTRA_IS_SETUP_FLOW)) {
+            dstBundle.putBoolean(key, srcBundle.getBoolean(key, false));
+        }
+        return dstBundle;
+    }
 }
index fc68d2c..0ed1644 100644 (file)
 
 package com.android.settings.accessibility;
 
+import android.content.ComponentName;
 import android.os.Bundle;
+import android.util.Log;
 import android.view.Menu;
 import android.view.accessibility.AccessibilityEvent;
 
+import androidx.annotation.VisibleForTesting;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceFragmentCompat;
 
 import com.android.settings.SettingsActivity;
+import com.android.settings.SetupWizardUtils;
 import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.display.FontSizePreferenceFragmentForSetupWizard;
 import com.android.settings.search.actionbar.SearchMenuController;
 import com.android.settings.support.actionbar.HelpResourceProvider;
 import com.android.settingslib.core.instrumentation.Instrumentable;
 
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
 public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
 
+    private static final String LOG_TAG = "A11ySettingsForSUW";
     private static final String SAVE_KEY_TITLE = "activity_title";
 
+    @VisibleForTesting
+    static final String CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW =
+            "com.android.settings.FontSizeSettingsForSetupWizardActivity";
+
     @Override
     protected void onSaveInstanceState(Bundle savedState) {
         savedState.putCharSequence(SAVE_KEY_TITLE, getTitle());
@@ -79,4 +91,33 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
                 .launch();
         return true;
     }
+
+    @Override
+    protected void onCreate(Bundle savedState) {
+        super.onCreate(savedState);
+
+        tryLaunchFontSizeSettings();
+    }
+
+    @VisibleForTesting
+    void tryLaunchFontSizeSettings() {
+        if (WizardManagerHelper.isAnySetupWizard(getIntent())
+                && new ComponentName(getPackageName(),
+                CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW).equals(
+                getIntent().getComponent())) {
+            final Bundle args = new Bundle();
+            args.putInt(HelpResourceProvider.HELP_URI_RESOURCE_KEY, 0);
+            args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
+            final SubSettingLauncher subSettingLauncher = new SubSettingLauncher(this)
+                    .setDestination(FontSizePreferenceFragmentForSetupWizard.class.getName())
+                    .setArguments(args)
+                    .setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN)
+                    .setExtras(SetupWizardUtils.copyLifecycleExtra(getIntent().getExtras(),
+                            new Bundle()));
+
+            Log.d(LOG_TAG, "Launch font size settings");
+            subSettingLauncher.launch();
+            finish();
+        }
+    }
 }
index 73fd11e..fae1785 100644 (file)
@@ -30,6 +30,7 @@ import android.os.UserHandle;
 import android.provider.Settings;
 import android.text.TextUtils;
 import android.view.View;
+import android.view.accessibility.AccessibilityManager;
 import android.widget.Button;
 import android.widget.CompoundButton;
 
@@ -99,17 +100,23 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
         );
 
         final FooterButton footerButton = new FooterButton.Builder(this)
-                .setText(R.string.wizard_next)
+                .setText(R.string.security_settings_face_enroll_education_start)
                 .setListener(this::onNextButtonClick)
                 .setButtonType(FooterButton.ButtonType.NEXT)
                 .setTheme(R.style.SudGlifButton_Primary)
                 .build();
 
+        boolean accessibilityEnabled = false;
+        final AccessibilityManager accessibilityManager = getApplicationContext().getSystemService(
+                AccessibilityManager.class);
+        if (accessibilityManager != null) {
+            accessibilityEnabled = accessibilityManager.isEnabled();
+        }
         mFooterBarMixin.setPrimaryButton(footerButton);
         final Context context = getApplicationContext();
         final boolean didDisplayEdu = Settings.Secure.getIntForUser(context.getContentResolver(),
                 FACE_UNLOCK_EDUCATION_INFO_DISPLAYED, OFF, mUserId) == ON;
-        if (!didDisplayEdu) {
+        if (!didDisplayEdu && !accessibilityEnabled) {
             Settings.Secure.putIntForUser(context.getContentResolver(),
                     FACE_UNLOCK_EDUCATION_INFO_DISPLAYED, ON, mUserId);
             footerButton.setEnabled(false);
@@ -128,6 +135,10 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
 
         mSwitchDiversity = findViewById(R.id.toggle_diversity);
         mSwitchDiversity.setListener(mSwitchDiversityListener);
+
+        if (accessibilityEnabled) {
+            accessibilityButton.callOnClick();
+        }
     }
 
     @Override
index 6dfdef4..5ff81d5 100644 (file)
@@ -37,8 +37,11 @@ import android.widget.Toolbar;
 import androidx.fragment.app.FragmentActivity;
 
 import com.android.settings.R;
+import com.android.settings.SubSettings;
 import com.android.settings.dashboard.CategoryManager;
 
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -65,13 +68,12 @@ public class SettingsBaseActivity extends FragmentActivity {
         if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
             requestWindowFeature(Window.FEATURE_NO_TITLE);
         }
+        // Apply SetupWizard light theme during setup flow. This is for SubSettings pages.
+        if (WizardManagerHelper.isAnySetupWizard(getIntent()) && this instanceof SubSettings) {
+            setTheme(R.style.LightTheme_SubSettings_SetupWizard);
+        }
         super.setContentView(R.layout.settings_base_layout);
-        final View decorView = getWindow().getDecorView();
 
-        decorView.setSystemUiVisibility(
-                decorView.getSystemUiVisibility()
-                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
-                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
         final Toolbar toolbar = findViewById(R.id.action_bar);
         if (theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
             toolbar.setVisibility(View.GONE);
index 39ecd78..5d9a528 100644 (file)
@@ -19,6 +19,7 @@ package com.android.settings.core;
 import android.annotation.StringRes;
 import android.content.Context;
 import android.content.Intent;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.UserHandle;
 import android.text.TextUtils;
@@ -89,6 +90,11 @@ public class SubSettingLauncher {
         return this;
     }
 
+    public SubSettingLauncher setExtras(Bundle extras) {
+        mLaunchRequest.extras = extras;
+        return this;
+    }
+
     public SubSettingLauncher setSourceMetricsCategory(int sourceMetricsCategory) {
         mLaunchRequest.sourceMetricsCategory = sourceMetricsCategory;
         return this;
@@ -136,6 +142,7 @@ public class SubSettingLauncher {
 
     public Intent toIntent() {
         final Intent intent = new Intent(Intent.ACTION_MAIN);
+        copyExtras(intent);
         intent.setClass(mContext, SubSettings.class);
         if (TextUtils.isEmpty(mLaunchRequest.destinationName)) {
             throw new IllegalArgumentException("Destination fragment must be set");
@@ -180,6 +187,11 @@ public class SubSettingLauncher {
         listener.startActivityForResult(intent, requestCode);
     }
 
+    private void copyExtras(Intent intent) {
+        if (mLaunchRequest.extras != null) {
+            intent.replaceExtras(mLaunchRequest.extras);
+        }
+    }
     /**
      * Simple container that has information about how to launch a subsetting.
      */
@@ -194,5 +206,6 @@ public class SubSettingLauncher {
         int mRequestCode;
         UserHandle userHandle;
         Bundle arguments;
+        Bundle extras;
     }
 }
index 4b2f50d..5c3772b 100644 (file)
@@ -78,9 +78,12 @@ public class ImeiInfoDialogController {
         final Context context = dialog.getContext();
         mSubscriptionInfo = context.getSystemService(SubscriptionManager.class)
                 .getActiveSubscriptionInfoForSimSlotIndex(slotId);
+        TelephonyManager tm = context.getSystemService(TelephonyManager.class);
         if (mSubscriptionInfo != null) {
             mTelephonyManager = context.getSystemService(TelephonyManager.class)
                     .createForSubscriptionId(mSubscriptionInfo.getSubscriptionId());
+        } else if(isValidSlotIndex(slotId, tm)) {
+            mTelephonyManager = tm;
         } else {
             mTelephonyManager = null;
         }
@@ -104,6 +107,7 @@ public class ImeiInfoDialogController {
     private void updateDialogForCdmaPhone() {
         final Resources res = mDialog.getContext().getResources();
         mDialog.setText(ID_MEID_NUMBER_VALUE, getMeid());
+        // MIN needs to read from SIM. So if no SIM, we should not show MIN on UI
         mDialog.setText(ID_MIN_NUMBER_VALUE, mSubscriptionInfo != null
                 ? mTelephonyManager.getCdmaMin(mSubscriptionInfo.getSubscriptionId())
                 : "");
@@ -137,7 +141,8 @@ public class ImeiInfoDialogController {
 
     @VisibleForTesting
     String getCdmaPrlVersion() {
-        return mTelephonyManager.getCdmaPrlVersion();
+        // PRL needs to read from SIM. So if no SIM, return empty
+        return mSubscriptionInfo != null ? mTelephonyManager.getCdmaPrlVersion() : "";
     }
 
     @VisibleForTesting
@@ -150,4 +155,9 @@ public class ImeiInfoDialogController {
     String getMeid() {
         return mTelephonyManager.getMeid(mSlotId);
     }
+
+    @VisibleForTesting
+    private boolean isValidSlotIndex(int slotIndex, TelephonyManager telephonyManager) {
+        return slotIndex >= 0 && slotIndex < telephonyManager.getPhoneCount();
+    }
 }
diff --git a/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java b/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java
deleted file mode 100644 (file)
index 0c5adc4..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
-
-import android.content.Context;
-import android.content.om.IOverlayManager;
-import android.os.ServiceManager;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-
-import com.android.settings.widget.RadioButtonPreference;
-
-public class SystemNavigationEdgeToEdgePreferenceController extends
-        SystemNavigationPreferenceController {
-    static final String PREF_KEY_EDGE_TO_EDGE = "gesture_edge_to_edge";
-
-    public SystemNavigationEdgeToEdgePreferenceController(Context context, String key) {
-        this(context, IOverlayManager.Stub.asInterface(ServiceManager.getService(
-                Context.OVERLAY_SERVICE)), key);
-    }
-
-    @VisibleForTesting
-    public SystemNavigationEdgeToEdgePreferenceController(Context context,
-            IOverlayManager overlayManager, String key) {
-        super(context, overlayManager, key, NAV_BAR_MODE_GESTURAL_OVERLAY);
-    }
-
-    @Override
-    public void onRadioButtonClicked(RadioButtonPreference preference) {
-        setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_GESTURAL_OVERLAY);
-        selectRadioButtonInGroup(PREF_KEY_EDGE_TO_EDGE, mPreferenceScreen);
-    }
-
-    @Override
-    public boolean isChecked() {
-        return isEdgeToEdgeEnabled(mContext);
-    }
-}
index ea5454b..e17b870 100644 (file)
 
 package com.android.settings.gestures;
 
+import static android.os.UserHandle.USER_CURRENT;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
+
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.SharedPreferences;
+import android.content.om.IOverlayManager;
+import android.graphics.drawable.Drawable;
+import android.os.RemoteException;
+import android.os.ServiceManager;
 import android.provider.SearchIndexableResource;
+import android.view.View;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
-import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settings.widget.RadioButtonPickerFragment;
+import com.android.settings.widget.RadioButtonPreference;
+import com.android.settings.widget.VideoPreference;
 import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.CandidateInfo;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 @SearchIndexable
-public class SystemNavigationGestureSettings extends DashboardFragment {
+public class SystemNavigationGestureSettings extends RadioButtonPickerFragment {
 
     private static final String TAG = "SystemNavigationGesture";
 
+    @VisibleForTesting
+    static final String KEY_SYSTEM_NAV_3BUTTONS = "system_nav_3buttons";
+    @VisibleForTesting
+    static final String KEY_SYSTEM_NAV_2BUTTONS = "system_nav_2buttons";
+    @VisibleForTesting
+    static final String KEY_SYSTEM_NAV_GESTURAL = "system_nav_gestural";
+
     public static final String PREF_KEY_SUGGESTION_COMPLETE =
             "pref_system_navigation_suggestion_complete";
 
+    private IOverlayManager mOverlayManager;
+
+    private VideoPreference mVideoPreference;
+
     @Override
     public void onAttach(Context context) {
         super.onAttach(context);
@@ -46,6 +75,12 @@ public class SystemNavigationGestureSettings extends DashboardFragment {
                 .getSuggestionFeatureProvider(context);
         SharedPreferences prefs = suggestionFeatureProvider.getSharedPrefs(context);
         prefs.edit().putBoolean(PREF_KEY_SUGGESTION_COMPLETE, true).apply();
+
+        mOverlayManager = IOverlayManager.Stub.asInterface(
+                ServiceManager.getService(Context.OVERLAY_SERVICE));
+
+        mVideoPreference = new VideoPreference(context);
+        setIllustrationVideo(mVideoPreference, getDefaultKey());
     }
 
     @Override
@@ -54,16 +89,153 @@ public class SystemNavigationGestureSettings extends DashboardFragment {
     }
 
     @Override
-    protected String getLogTag() {
-        return TAG;
+    protected int getPreferenceScreenResId() {
+        return R.xml.system_navigation_gesture_settings;
     }
 
     @Override
-    protected int getPreferenceScreenResId() {
-        return R.xml.system_navigation_gesture_settings;
+    protected void addStaticPreferences(PreferenceScreen screen) {
+        screen.addPreference(mVideoPreference);
+    }
+
+    @Override
+    protected List<? extends CandidateInfo> getCandidates() {
+        final Context c = getContext();
+        List<NavModeCandidateInfo> candidates = new ArrayList<>();
+
+        if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
+                NAV_BAR_MODE_GESTURAL_OVERLAY)) {
+            candidates.add(new NavModeCandidateInfo(
+                    c.getText(R.string.edge_to_edge_navigation_title),
+                    c.getText(R.string.edge_to_edge_navigation_summary),
+                    KEY_SYSTEM_NAV_GESTURAL, true /* enabled */));
+        }
+        if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
+                NAV_BAR_MODE_2BUTTON_OVERLAY)) {
+            candidates.add(new NavModeCandidateInfo(
+                    c.getText(R.string.swipe_up_to_switch_apps_title),
+                    c.getText(R.string.swipe_up_to_switch_apps_summary),
+                    KEY_SYSTEM_NAV_2BUTTONS, true /* enabled */));
+        }
+        if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
+                NAV_BAR_MODE_3BUTTON_OVERLAY)) {
+            candidates.add(new NavModeCandidateInfo(
+                    c.getText(R.string.legacy_navigation_title),
+                    c.getText(R.string.legacy_navigation_summary),
+                    KEY_SYSTEM_NAV_3BUTTONS, true /* enabled */));
+        }
+
+        return candidates;
+    }
+
+    @Override
+    protected String getDefaultKey() {
+        return getCurrentSystemNavigationMode(getContext());
+    }
+
+    @Override
+    protected boolean setDefaultKey(String key) {
+        setCurrentSystemNavigationMode(mOverlayManager, key);
+        setIllustrationVideo(mVideoPreference, key);
+        return true;
+    }
+
+    @VisibleForTesting
+    static String getCurrentSystemNavigationMode(Context context) {
+        if (SystemNavigationPreferenceController.isEdgeToEdgeEnabled(context)) {
+            return KEY_SYSTEM_NAV_GESTURAL;
+        } else if (SystemNavigationPreferenceController.isSwipeUpEnabled(context)) {
+            return KEY_SYSTEM_NAV_2BUTTONS;
+        } else {
+            return KEY_SYSTEM_NAV_3BUTTONS;
+        }
+    }
+
+    @VisibleForTesting
+    static void setCurrentSystemNavigationMode(IOverlayManager overlayManager, String key) {
+        switch (key) {
+            case KEY_SYSTEM_NAV_GESTURAL:
+                setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_GESTURAL_OVERLAY);
+                break;
+            case KEY_SYSTEM_NAV_2BUTTONS:
+                setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY);
+                break;
+            case KEY_SYSTEM_NAV_3BUTTONS:
+                setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY);
+                break;
+        }
+    }
+
+    /**
+     * Enables the specified overlay package.
+     */
+    static void setNavBarInteractionMode(IOverlayManager overlayManager, String overlayPackage) {
+        try {
+            overlayManager.setEnabledExclusiveInCategory(overlayPackage, USER_CURRENT);
+        } catch (RemoteException e) {
+            throw e.rethrowFromSystemServer();
+        }
+    }
+
+    static void setIllustrationVideo(VideoPreference videoPref, String systemNavKey) {
+        videoPref.setVideo(0, 0);
+        switch (systemNavKey) {
+            case KEY_SYSTEM_NAV_GESTURAL:
+                videoPref.setVideo(R.raw.system_nav_fully_gestural,
+                        R.drawable.system_nav_fully_gestural);
+                break;
+            case KEY_SYSTEM_NAV_2BUTTONS:
+                videoPref.setVideo(R.raw.system_nav_2_button, R.drawable.system_nav_2_button);
+                break;
+            case KEY_SYSTEM_NAV_3BUTTONS:
+                videoPref.setVideo(R.raw.system_nav_3_button, R.drawable.system_nav_3_button);
+                break;
+        }
+    }
+
+    @Override
+    public void bindPreferenceExtra(RadioButtonPreference pref,
+            String key, CandidateInfo info, String defaultKey, String systemDefaultKey) {
+        if (info instanceof NavModeCandidateInfo) {
+            pref.setSummary(((NavModeCandidateInfo) info).loadSummary());
+            pref.setAppendixVisibility(View.GONE);
+        }
+    }
+
+    static class NavModeCandidateInfo extends CandidateInfo {
+        private final CharSequence mLabel;
+        private final CharSequence mSummary;
+        private final String mKey;
+
+        NavModeCandidateInfo(CharSequence label, CharSequence summary, String key,
+                boolean enabled) {
+            super(enabled);
+            mLabel = label;
+            mSummary = summary;
+            mKey = key;
+        }
+
+        @Override
+        public CharSequence loadLabel() {
+            return mLabel;
+        }
+
+        public CharSequence loadSummary() {
+            return mSummary;
+        }
+
+        @Override
+        public Drawable loadIcon() {
+            return null;
+        }
+
+        @Override
+        public String getKey() {
+            return mKey;
+        }
     }
 
-    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
                 public List<SearchIndexableResource> getXmlResourcesToIndex(
diff --git a/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java b/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java
deleted file mode 100644 (file)
index 7ac9a03..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
-
-import android.content.Context;
-import android.content.om.IOverlayManager;
-import android.os.ServiceManager;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-
-import com.android.settings.widget.RadioButtonPreference;
-
-public class SystemNavigationLegacyPreferenceController extends
-        SystemNavigationPreferenceController {
-    static final String PREF_KEY_LEGACY = "gesture_legacy";
-
-    public SystemNavigationLegacyPreferenceController(Context context, String key) {
-        this(context, IOverlayManager.Stub.asInterface(ServiceManager.getService(
-                Context.OVERLAY_SERVICE)), key);
-    }
-
-    @VisibleForTesting
-    public SystemNavigationLegacyPreferenceController(Context context,
-            IOverlayManager overlayManager, String key) {
-        super(context, overlayManager, key, NAV_BAR_MODE_3BUTTON_OVERLAY);
-    }
-
-    @Override
-    public void onRadioButtonClicked(RadioButtonPreference preference) {
-        setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY);
-        selectRadioButtonInGroup(PREF_KEY_LEGACY, mPreferenceScreen);
-    }
-
-    @Override
-    public boolean isChecked() {
-        return !isEdgeToEdgeEnabled(mContext) && !isSwipeUpEnabled(mContext);
-    }
-}
index 664e7bb..d0d8155 100644 (file)
 
 package com.android.settings.gestures;
 
-import static android.os.UserHandle.USER_CURRENT;
 import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
 import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
 
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
-import android.content.om.IOverlayManager;
 import android.content.pm.PackageManager;
-import android.os.RemoteException;
-import android.text.TextUtils;
-import android.view.View;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
-import com.android.settings.widget.RadioButtonPreference;
+import com.android.settings.core.BasePreferenceController;
 
-public abstract class SystemNavigationPreferenceController extends GesturePreferenceController
-        implements RadioButtonPreference.OnClickListener {
+public class SystemNavigationPreferenceController extends BasePreferenceController {
 
+    static final String PREF_KEY_SYSTEM_NAVIGATION = "gesture_system_navigation";
     private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
-    private static final String PREF_KEY_VIDEO = "gesture_swipe_up_video";
-
-    private static final String[] RADIO_BUTTONS_IN_GROUP = {
-            SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY,
-            SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP,
-            SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE,
-    };
 
-    protected final IOverlayManager mOverlayManager;
-    protected PreferenceScreen mPreferenceScreen;
-    private final String mOverlayPackage;
-
-    public SystemNavigationPreferenceController(Context context, IOverlayManager overlayManager,
-            String key, String overlayPackage) {
+    public SystemNavigationPreferenceController(Context context, String key) {
         super(context, key);
-        mOverlayManager = overlayManager;
-        mOverlayPackage = overlayPackage;
     }
 
     @Override
     public int getAvailabilityStatus() {
-        return isGestureAvailable(mContext, mOverlayPackage) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
-    }
-
-    @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        mPreferenceScreen = screen;
-
-        Preference preference = screen.findPreference(getPreferenceKey());
-        if (preference != null && preference instanceof RadioButtonPreference) {
-            RadioButtonPreference radioPreference = (RadioButtonPreference) preference;
-            radioPreference.setOnClickListener(this);
-            radioPreference.setAppendixVisibility(View.GONE);
-        }
-    }
-
-    @Override
-    public boolean setChecked(boolean isChecked) {
-        if (!isChecked || mPreferenceScreen == null) {
-            return false;
-        }
-        Preference preference = mPreferenceScreen.findPreference(getPreferenceKey());
-        if (preference != null && preference instanceof RadioButtonPreference) {
-            onRadioButtonClicked((RadioButtonPreference) preference);
-        }
-        return true;
+        return isGestureAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
     }
 
     @Override
@@ -102,17 +52,7 @@ public abstract class SystemNavigationPreferenceController extends GesturePrefer
         }
     }
 
-    @Override
-    protected String getVideoPrefKey() {
-        return PREF_KEY_VIDEO;
-    }
-
-
     static boolean isGestureAvailable(Context context) {
-        return isGestureAvailable(context, null /* overlayPackage */);
-    }
-
-    static boolean isGestureAvailable(Context context, String overlayPackage) {
         // Skip if the swipe up settings are not available
         if (!context.getResources().getBoolean(
                 com.android.internal.R.bool.config_swipe_up_gesture_setting_available)) {
@@ -127,44 +67,22 @@ public abstract class SystemNavigationPreferenceController extends GesturePrefer
         }
 
         // Skip if the overview proxy service exists
-        final PackageManager pm = context.getPackageManager();
         final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
                 .setPackage(recentsComponentName.getPackageName());
-        if (pm.resolveService(quickStepIntent, PackageManager.MATCH_SYSTEM_ONLY) == null) {
+        if (context.getPackageManager().resolveService(quickStepIntent,
+                PackageManager.MATCH_SYSTEM_ONLY) == null) {
             return false;
         }
 
-        // Skip if the required overlay package is defined but doesn't exist
-        if (overlayPackage != null) {
-            try {
-                return pm.getPackageInfo(overlayPackage, 0 /* flags */) != null;
-            } catch (PackageManager.NameNotFoundException e) {
-                // Not found, just return unavailable
-                return false;
-            }
-        }
-
         return true;
     }
 
-    static void selectRadioButtonInGroup(String preferenceKey, PreferenceScreen screen) {
-        if (screen == null) {
-            return;
-        }
-        for (String key : RADIO_BUTTONS_IN_GROUP) {
-            ((RadioButtonPreference) screen.findPreference(key)).setChecked(
-                    TextUtils.equals(key, preferenceKey));
-        }
-    }
-
-    /**
-     * Enables the specified overlay package.
-     */
-    static void setNavBarInteractionMode(IOverlayManager overlayManager, String overlayPackage) {
+    static boolean isOverlayPackageAvailable(Context context, String overlayPackage) {
         try {
-            overlayManager.setEnabledExclusiveInCategory(overlayPackage, USER_CURRENT);
-        } catch (RemoteException e) {
-            throw e.rethrowFromSystemServer();
+            return context.getPackageManager().getPackageInfo(overlayPackage, 0) != null;
+        } catch (PackageManager.NameNotFoundException e) {
+            // Not found, just return unavailable
+            return false;
         }
     }
 
diff --git a/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java b/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java
deleted file mode 100644 (file)
index 592b231..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
-
-import android.content.Context;
-import android.content.om.IOverlayManager;
-import android.os.ServiceManager;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-
-import com.android.settings.widget.RadioButtonPreference;
-
-public class SystemNavigationSwipeUpPreferenceController extends
-        SystemNavigationPreferenceController {
-    static final String PREF_KEY_SWIPE_UP = "gesture_swipe_up";
-
-    public SystemNavigationSwipeUpPreferenceController(Context context, String key) {
-        this(context, IOverlayManager.Stub.asInterface(ServiceManager.getService(
-                Context.OVERLAY_SERVICE)), key);
-    }
-
-    @VisibleForTesting
-    public SystemNavigationSwipeUpPreferenceController(Context context,
-            IOverlayManager overlayManager, String key) {
-        super(context, overlayManager, key, NAV_BAR_MODE_2BUTTON_OVERLAY);
-    }
-
-    @Override
-    public void onRadioButtonClicked(RadioButtonPreference preference) {
-        setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY);
-        selectRadioButtonInGroup(PREF_KEY_SWIPE_UP, mPreferenceScreen);
-    }
-
-    @Override
-    public boolean isChecked() {
-        return isSwipeUpEnabled(mContext);
-    }
-}
index fa23101..e767664 100644 (file)
@@ -27,16 +27,16 @@ import android.widget.Toolbar;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentActivity;
 import androidx.fragment.app.FragmentManager;
 import androidx.fragment.app.FragmentTransaction;
 
 import com.android.settings.R;
 import com.android.settings.accounts.AvatarViewMixin;
+import com.android.settings.core.SettingsBaseActivity;
 import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
 import com.android.settings.overlay.FeatureFactory;
 
-public class SettingsHomepageActivity extends FragmentActivity {
+public class SettingsHomepageActivity extends SettingsBaseActivity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
index 9fdb6ea..98c1f5b 100644 (file)
@@ -65,8 +65,11 @@ public class ApnPreferenceController extends TelephonyBasePreferenceController i
         final boolean isGsmApn = MobileNetworkUtils.isGsmOptions(mContext, subId)
                 && carrierConfig != null
                 && carrierConfig.getBoolean(CarrierConfigManager.KEY_APN_EXPAND_BOOL);
+        final boolean hideCarrierNetwork = carrierConfig == null
+                || carrierConfig.getBoolean(
+                CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL);
 
-        return isCdmaApn || isGsmApn
+        return !hideCarrierNetwork && (isCdmaApn || isGsmApn)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
index 9b25338..0c099ca 100644 (file)
@@ -355,6 +355,8 @@ public class MobileNetworkUtils {
                 || carrierConfig == null
                 || !carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_OPERATOR_SELECTION_EXPAND_BOOL)
+                || carrierConfig.getBoolean(
+                CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)
                 || (carrierConfig.getBoolean(CarrierConfigManager.KEY_CSP_ENABLED_BOOL)
                 && !telephonyManager.isManualNetworkSelectionAllowed())) {
             return false;
index adfb1d8..56d0b2d 100644 (file)
@@ -52,7 +52,6 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
     private static final long MINIMUM_DIALOG_TIME_MILLIS = TimeUnit.SECONDS.toMillis(1);
 
     private final Handler mUiHandler;
-    private int mSubId;
     private TelephonyManager mTelephonyManager;
     private boolean mOnlyAutoSelectInHome;
     private List<OnNetworkSelectModeListener> mListeners;
index 9ac0d12..46171bc 100644 (file)
@@ -42,7 +42,6 @@ public class OpenNetworkSelectPagePreferenceController extends
         TelephonyBasePreferenceController implements
         AutoSelectPreferenceController.OnNetworkSelectModeListener {
 
-    private int mSubId;
     private TelephonyManager mTelephonyManager;
     private Preference mPreference;
 
index ba26f02..0be7c2b 100644 (file)
@@ -582,9 +582,11 @@ public class WifiConfigController implements TextWatcher,
     }
 
     /**
-     * Special handling for WPA2/WPA3 in Transition mode: The key SECURITY_PSK_SAE_TRANSITION is
-     * a pseudo key which results by the scan results, but never appears in the saved networks.
-     * A saved network is either WPA3 for supporting devices or WPA2 for non-supporting devices.
+     * Special handling for WPA2/WPA3 and OWE in Transition mode: The key
+     * SECURITY_PSK_SAE_TRANSITION and SECURITY_OWE_TRANSITION are pseudo keys which result by the
+     * scan results, but never appears in the saved networks.
+     * A saved network is either WPA3 for supporting devices or WPA2 for non-supporting devices,
+     * or, OWE for supporting devices or Open for non-supporting devices.
      *
      * @param accessPointSecurity Access point current security type
      * @return Converted security type (if required)
@@ -597,6 +599,14 @@ public class WifiConfigController implements TextWatcher,
                 return AccessPoint.SECURITY_PSK;
             }
         }
+        if (accessPointSecurity == AccessPoint.SECURITY_OWE_TRANSITION) {
+            if (mWifiManager.isEnhancedOpenSupported()) {
+                return AccessPoint.SECURITY_OWE;
+            } else {
+                return AccessPoint.SECURITY_NONE;
+            }
+        }
+
         return accessPointSecurity;
     }
 
@@ -948,7 +958,8 @@ public class WifiConfigController implements TextWatcher,
 
     private void showSecurityFields() {
         if (mAccessPointSecurity == AccessPoint.SECURITY_NONE ||
-                  mAccessPointSecurity == AccessPoint.SECURITY_OWE) {
+                mAccessPointSecurity == AccessPoint.SECURITY_OWE ||
+                mAccessPointSecurity == AccessPoint.SECURITY_OWE_TRANSITION) {
             mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
             return;
         }
index 4d3f230..8c4bfa2 100644 (file)
@@ -494,7 +494,9 @@ public class WifiSettings extends RestrictedSettingsFragment
                 if (isSavedNetwork) {
                     connect(mSelectedAccessPoint.getConfig(), isSavedNetwork);
                 } else if ((mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_NONE) ||
-                        (mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_OWE)) {
+                        (mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_OWE) ||
+                        (mSelectedAccessPoint.getSecurity()
+                                == AccessPoint.SECURITY_OWE_TRANSITION)) {
                     /** Bypass dialog for unsecured networks */
                     mSelectedAccessPoint.generateOpenNetworkConfig();
                     connect(mSelectedAccessPoint.getConfig(), isSavedNetwork);
@@ -748,7 +750,8 @@ public class WifiSettings extends RestrictedSettingsFragment
                 preference.setOrder(index);
                 if (mOpenSsid != null && mOpenSsid.equals(accessPoint.getSsidStr())
                         && (accessPoint.getSecurity() != AccessPoint.SECURITY_NONE &&
-                        accessPoint.getSecurity() != AccessPoint.SECURITY_OWE)) {
+                        accessPoint.getSecurity() != AccessPoint.SECURITY_OWE &&
+                        accessPoint.getSecurity() != AccessPoint.SECURITY_OWE_TRANSITION)) {
                     if (!accessPoint.isSaved() || isDisabledByWrongPassword(accessPoint)) {
                         onPreferenceTreeClick(preference);
                         mOpenSsid = null;
index 9b3c1b3..c4df567 100644 (file)
@@ -268,7 +268,8 @@ public class WifiUtils {
         if (accessPoint.isOsuProvider()) {
             return CONNECT_TYPE_OSU_PROVISION;
         } else if ((accessPoint.getSecurity() == AccessPoint.SECURITY_NONE) ||
-                (accessPoint.getSecurity() == AccessPoint.SECURITY_OWE)) {
+                (accessPoint.getSecurity() == AccessPoint.SECURITY_OWE) ||
+                (accessPoint.getSecurity() == AccessPoint.SECURITY_OWE_TRANSITION)) {
             return CONNECT_TYPE_OPEN_NETWORK;
         } else if (accessPoint.isSaved() && config != null
                 && config.getNetworkSelectionStatus() != null
index 9be9898..e5c8de5 100644 (file)
@@ -149,7 +149,6 @@ public class WifiSlice implements CustomSliceable {
         final IconCompat icon = IconCompat.createWithResource(mContext,
                 R.drawable.ic_settings_wireless);
         final String title = mContext.getString(R.string.wifi_settings);
-        final CharSequence summary = getSummary();
         final PendingIntent toggleAction = getBroadcastIntent(mContext);
         final PendingIntent primaryAction = getPrimaryAction();
         final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon,
@@ -162,7 +161,6 @@ public class WifiSlice implements CustomSliceable {
                 .setKeywords(getKeywords())
                 .addRow(new ListBuilder.RowBuilder()
                         .setTitle(title)
-                        .setSubtitle(summary)
                         .addEndItem(toggleSliceAction)
                         .setPrimaryAction(primarySliceAction));
     }
@@ -338,20 +336,6 @@ public class WifiSlice implements CustomSliceable {
         }
     }
 
-    private CharSequence getSummary() {
-        switch (mWifiManager.getWifiState()) {
-            case WifiManager.WIFI_STATE_ENABLED:
-            case WifiManager.WIFI_STATE_ENABLING:
-                return mContext.getText(R.string.switch_on_text);
-            case WifiManager.WIFI_STATE_DISABLED:
-            case WifiManager.WIFI_STATE_DISABLING:
-                return mContext.getText(R.string.switch_off_text);
-            case WifiManager.WIFI_STATE_UNKNOWN:
-            default:
-                return null;
-        }
-    }
-
     private PendingIntent getPrimaryAction() {
         final Intent intent = getIntent();
         return PendingIntent.getActivity(mContext, 0 /* requestCode */,
index b965d78..5f4f31b 100644 (file)
@@ -19,6 +19,7 @@ package com.android.settings;
 import static com.google.common.truth.Truth.assertThat;
 
 import android.content.Intent;
+import android.os.Bundle;
 import android.sysprop.SetupWizardProperties;
 
 import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -31,9 +32,6 @@ import org.robolectric.RobolectricTestRunner;
 @RunWith(RobolectricTestRunner.class)
 public class SetupWizardUtilsTest {
 
-    private static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
-    private static final String EXTRA_IS_FIRST_RUN = "firstRun";
-
     @Test
     public void testCopySetupExtras() {
         Intent fromIntent = new Intent();
@@ -46,6 +44,25 @@ public class SetupWizardUtilsTest {
         assertThat(theme).isEqualTo(toIntent.getStringExtra(WizardManagerHelper.EXTRA_THEME));
         assertThat(toIntent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, false))
                 .isTrue();
+        assertThat(toIntent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true))
+                .isFalse();
+    }
+
+    @Test
+    public void testCopyLifecycleExtra() {
+        Intent fromIntent = new Intent();
+        final String theme = "TEST_THEME";
+        fromIntent.putExtra(WizardManagerHelper.EXTRA_THEME, theme);
+        fromIntent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
+        Bundle dstBundle = new Bundle();
+        dstBundle = SetupWizardUtils.copyLifecycleExtra(fromIntent.getExtras(), dstBundle);
+
+        assertThat(dstBundle).isNotNull();
+        assertThat(dstBundle.getString(WizardManagerHelper.EXTRA_THEME)).isNull();
+        assertThat(dstBundle.getBoolean(WizardManagerHelper.EXTRA_IS_SETUP_FLOW))
+                .isTrue();
+        assertThat(dstBundle.getBoolean(WizardManagerHelper.EXTRA_IS_FIRST_RUN))
+                .isFalse();
     }
 
     @Test
@@ -87,7 +104,7 @@ public class SetupWizardUtilsTest {
 
     private Intent createSetupWizardIntent() {
         return new Intent()
-                .putExtra(EXTRA_IS_SETUP_FLOW, true)
-                .putExtra(EXTRA_IS_FIRST_RUN, true);
+                .putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)
+                .putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true);
     }
 }
index a0a9de9..c3a630b 100644 (file)
 
 package com.android.settings.accessibility;
 
+import static com.android.settings.accessibility.AccessibilitySettingsForSetupWizardActivity.CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW;
+
 import static com.google.common.truth.Truth.assertThat;
 
+import android.content.ComponentName;
 import android.content.Intent;
 
 import androidx.test.filters.SmallTest;
 
 import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.display.FontSizePreferenceFragmentForSetupWizard;
+
+import com.google.android.setupcompat.util.WizardManagerHelper;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.Robolectric;
 import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
 
 @RunWith(RobolectricTestRunner.class)
 @SmallTest
@@ -41,4 +50,37 @@ public class AccessibilitySettingsForSetupWizardActivityTest {
 
     assertThat(activity.getThemeResId()).isEqualTo(R.style.GlifV3Theme_Light);
   }
+
+  @Test
+  public void onCreate_hasFontSizeComponent_shouldGoToFontSizePreferenceDirectly() {
+    AccessibilitySettingsForSetupWizardActivity activity =
+            Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
+                    new Intent(Intent.ACTION_MAIN).setComponent(new ComponentName(
+                            RuntimeEnvironment.application, CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW)).
+                            putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true).
+                            putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
+
+    activity.tryLaunchFontSizeSettings();
+
+    final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
+    assertThat(launchIntent).isNotNull();
+    assertThat(launchIntent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(
+            FontSizePreferenceFragmentForSetupWizard.class.getName());
+    assertThat(activity.isFinishing()).isTrue();
+  }
+
+  @Test
+  public void onCreate_noFontSizeComponent_shouldNotFinishCurrentActivity() {
+    AccessibilitySettingsForSetupWizardActivity activity =
+            Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
+                    new Intent(Intent.ACTION_MAIN).
+                            putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true).
+                            putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
+
+    activity.tryLaunchFontSizeSettings();
+
+    final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
+    assertThat(launchIntent).isNull();
+    assertThat(activity.isFinishing()).isFalse();
+  }
 }
index f38668c..7ad8d63 100644 (file)
@@ -86,8 +86,8 @@ public class ImeiInfoDialogControllerTest {
 
         mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID));
 
-        doReturn(PRL_VERSION).when(mController).getCdmaPrlVersion();
-        doReturn(MEID_NUMBER).when(mController).getMeid();
+        when(mTelephonyManager.getCdmaPrlVersion()).thenReturn(PRL_VERSION);
+        when(mTelephonyManager.getMeid(anyInt())).thenReturn(MEID_NUMBER);
         when(mTelephonyManager.getCdmaMin(anyInt())).thenReturn(MIN_NUMBER);
         when(mTelephonyManager.getDeviceSoftwareVersion(anyInt())).thenReturn(IMEI_SV_NUMBER);
         when(mTelephonyManager.getImei(anyInt())).thenReturn(IMEI_NUMBER);
@@ -98,6 +98,7 @@ public class ImeiInfoDialogControllerTest {
         mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID + 1));
 
         mController.populateImeiInfo();
+
         verify(mDialog, never()).setText(anyInt(), any());
     }
 
@@ -129,17 +130,31 @@ public class ImeiInfoDialogControllerTest {
     }
 
     @Test
-    public void populateImeiInfo_cdmaSimDisabled_shouldRemoveImeiInfoAndSetMinToEmpty() {
+    public void populateImeiInfo_cdmaSimDisabled_shouldRemoveImeiInfoAndSetMinPrlToEmpty() {
         ReflectionHelpers.setField(mController, "mSubscriptionInfo", null);
         when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
 
         mController.populateImeiInfo();
 
+        verify(mDialog).setText(ID_MEID_NUMBER_VALUE, MEID_NUMBER);
         verify(mDialog).setText(ID_MIN_NUMBER_VALUE, "");
+        verify(mDialog).setText(ID_PRL_VERSION_VALUE, "");
         verify(mDialog).removeViewFromScreen(ID_GSM_SETTINGS);
     }
 
     @Test
+    public void populateImeiInfo_gsmSimDisabled_shouldSetImeiAndRemoveCdmaSettings() {
+        ReflectionHelpers.setField(mController, "mSubscriptionInfo", null);
+        when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_GSM);
+
+        mController.populateImeiInfo();
+
+        verify(mDialog).setText(eq(ID_IMEI_VALUE), any());
+        verify(mDialog).setText(eq(ID_IMEI_SV_VALUE), any());
+        verify(mDialog).removeViewFromScreen(ID_CDMA_SETTINGS);
+    }
+
+    @Test
     public void populateImeinfo_gsm_shouldSetImeiAndRemoveCdmaSettings() {
         when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_GSM);
 
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java
deleted file mode 100644 (file)
index 5c02101..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * 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.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-
-import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
-import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
-import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.om.IOverlayManager;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-
-import androidx.preference.PreferenceScreen;
-
-import com.android.internal.R;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settings.widget.RadioButtonPreference;
-
-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.Shadows;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowPackageManager;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows = SettingsShadowResources.class)
-public class SystemNavigationEdgeToEdgePreferenceControllerTest {
-
-    private Context mContext;
-    private ShadowPackageManager mPackageManager;
-
-    @Mock
-    private IOverlayManager mOverlayManager;
-
-    private SystemNavigationEdgeToEdgePreferenceController mController;
-
-    private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
-        SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
-                true);
-
-        mContext = RuntimeEnvironment.application;
-        mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
-
-        mController = new SystemNavigationEdgeToEdgePreferenceController(mContext, mOverlayManager,
-                PREF_KEY_EDGE_TO_EDGE);
-    }
-
-    @After
-    public void tearDown() {
-        SettingsShadowResources.reset();
-    }
-
-    @Test
-    public void testIsGestureAvailable_matchingServiceExists_shouldReturnTrue() {
-        final ComponentName recentsComponentName = ComponentName.unflattenFromString(
-                mContext.getString(com.android.internal.R.string.config_recentsComponentName));
-        final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
-                .setPackage(recentsComponentName.getPackageName());
-        final ResolveInfo info = new ResolveInfo();
-        info.serviceInfo = new ServiceInfo();
-        info.resolvePackageName = recentsComponentName.getPackageName();
-        info.serviceInfo.packageName = info.resolvePackageName;
-        info.serviceInfo.name = recentsComponentName.getClassName();
-        info.serviceInfo.applicationInfo = new ApplicationInfo();
-        info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
-        mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
-
-        assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext))
-                .isTrue();
-    }
-
-    @Test
-    public void testIsGestureAvailable_overlayDisabled_matchingServiceExists_shouldReturnFalse() {
-        SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
-                false);
-
-        final ComponentName recentsComponentName = ComponentName.unflattenFromString(
-                mContext.getString(com.android.internal.R.string.config_recentsComponentName));
-        final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
-                .setPackage(recentsComponentName.getPackageName());
-        mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
-
-        assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext))
-                .isFalse();
-    }
-
-    @Test
-    public void testIsGestureAvailable_noMatchingServiceExists_shouldReturnFalse() {
-        assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext))
-                .isFalse();
-    }
-
-    @Test
-    public void testIsGestureAvailable_noOverlayPackage_shouldReturnFalse() {
-        assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext,
-                "com.package.fake")).isFalse();
-    }
-
-    @Test
-    public void testIsChecked_defaultIsEdgeToEdge_shouldReturnTrue() {
-        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
-                NAV_BAR_MODE_GESTURAL);
-        assertThat(mController.isChecked()).isTrue();
-    }
-
-    @Test
-    public void testIsChecked_defaultIsLegacy_shouldReturnFalse() {
-        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
-                NAV_BAR_MODE_3BUTTON);
-        assertThat(mController.isChecked()).isFalse();
-    }
-
-    @Test
-    public void testIsChecked_defaultIsSwipeUp_shouldReturnFalse() {
-        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
-                NAV_BAR_MODE_2BUTTON);
-        assertThat(mController.isChecked()).isFalse();
-    }
-
-    @Test
-    public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
-        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
-                NAV_BAR_MODE_GESTURAL);
-        // Set the setting to be enabled.
-        mController.onRadioButtonClicked(null);
-        assertThat(mController.isChecked()).isTrue();
-    }
-
-    @Test
-    public void testOnRadioButtonClicked_setsCorrectRadioButtonChecked() {
-        RadioButtonPreference radioLegacy = mock(RadioButtonPreference.class);
-        RadioButtonPreference radioSwipeUp = mock(RadioButtonPreference.class);
-        RadioButtonPreference radioEdgeToEdge = mock(RadioButtonPreference.class);
-        PreferenceScreen screen = mock(PreferenceScreen.class);
-
-        when(screen.findPreference(PREF_KEY_LEGACY)).thenReturn(radioLegacy);
-        when(screen.findPreference(PREF_KEY_SWIPE_UP)).thenReturn(radioSwipeUp);
-        when(screen.findPreference(PREF_KEY_EDGE_TO_EDGE)).thenReturn(radioEdgeToEdge);
-
-        mController.displayPreference(screen);
-        mController.onRadioButtonClicked(radioEdgeToEdge);
-
-        verify(radioLegacy, times(1)).setChecked(false);
-        verify(radioSwipeUp, times(1)).setChecked(false);
-        verify(radioEdgeToEdge, times(1)).setChecked(true);
-    }
-
-    @Test
-    public void isSliceable_returnsFalse() {
-        assertThat(mController.isSliceable()).isFalse();
-    }
-
-    @Test
-    public void isSliceableIncorrectKey_returnsFalse() {
-        final SystemNavigationEdgeToEdgePreferenceController controller =
-                new SystemNavigationEdgeToEdgePreferenceController(mContext, "bad_key");
-        assertThat(controller.isSliceable()).isFalse();
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationGestureSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationGestureSettingsTest.java
new file mode 100644 (file)
index 0000000..1f3a758
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * 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.gestures;
+
+import static android.os.UserHandle.USER_CURRENT;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
+
+import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_2BUTTONS;
+import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_3BUTTONS;
+import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_GESTURAL;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.content.om.IOverlayManager;
+import android.os.ServiceManager;
+import android.provider.SearchIndexableResource;
+import android.text.TextUtils;
+
+import com.android.internal.R;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = SettingsShadowResources.class)
+public class SystemNavigationGestureSettingsTest {
+
+    private Context mContext;
+
+    private IOverlayManager mOverlayManager;
+
+    private SystemNavigationGestureSettings mSettings;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mOverlayManager = mock(IOverlayManager.class);
+
+        mSettings = new SystemNavigationGestureSettings();
+    }
+
+    @Test
+    public void testSearchIndexProvider_shouldIndexResource() {
+        final List<SearchIndexableResource> indexRes =
+                SystemNavigationGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
+                        RuntimeEnvironment.application, true /* enabled */);
+
+        assertThat(indexRes).isNotNull();
+        assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
+    }
+
+    @Test
+    public void testGetCurrentSystemNavigationMode() {
+        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+                NAV_BAR_MODE_GESTURAL);
+        assertThat(TextUtils.equals(mSettings.getCurrentSystemNavigationMode(mContext),
+                KEY_SYSTEM_NAV_GESTURAL)).isTrue();
+
+        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+                NAV_BAR_MODE_3BUTTON);
+        assertThat(TextUtils.equals(mSettings.getCurrentSystemNavigationMode(mContext),
+                KEY_SYSTEM_NAV_3BUTTONS)).isTrue();
+
+        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+                NAV_BAR_MODE_2BUTTON);
+        assertThat(TextUtils.equals(mSettings.getCurrentSystemNavigationMode(mContext),
+                KEY_SYSTEM_NAV_2BUTTONS)).isTrue();
+    }
+
+    @Test
+    public void testSetCurrentSystemNavigationMode() throws Exception {
+        mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_GESTURAL);
+        verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
+                NAV_BAR_MODE_GESTURAL_OVERLAY, USER_CURRENT);
+
+        mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_2BUTTONS);
+        verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
+                NAV_BAR_MODE_2BUTTON_OVERLAY, USER_CURRENT);
+
+        mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_3BUTTONS);
+        verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
+                NAV_BAR_MODE_3BUTTON_OVERLAY, USER_CURRENT);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java
deleted file mode 100644 (file)
index ebb1eb0..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * 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.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-
-import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
-import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
-import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.om.IOverlayManager;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-
-import androidx.preference.PreferenceScreen;
-
-import com.android.internal.R;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settings.widget.RadioButtonPreference;
-
-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.Shadows;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowPackageManager;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows = SettingsShadowResources.class)
-public class SystemNavigationLegacyPreferenceControllerTest {
-
-    private Context mContext;
-    private ShadowPackageManager mPackageManager;
-
-    @Mock
-    private IOverlayManager mOverlayManager;
-
-    private SystemNavigationLegacyPreferenceController mController;
-
-    private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
-        SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
-                true);
-
-        mContext = RuntimeEnvironment.application;
-        mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
-
-        mController = new SystemNavigationLegacyPreferenceController(mContext, mOverlayManager,
-                PREF_KEY_LEGACY);
-    }
-
-    @After
-    public void tearDown() {
-        SettingsShadowResources.reset();
-    }
-
-    @Test
-    public void testIsGestureAvailable_matchingServiceExists_shouldReturnTrue() {
-        final ComponentName recentsComponentName = ComponentName.unflattenFromString(
-                mContext.getString(com.android.internal.R.string.config_recentsComponentName));
-        final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
-                .setPackage(recentsComponentName.getPackageName());
-        final ResolveInfo info = new ResolveInfo();
-        info.serviceInfo = new ServiceInfo();
-        info.resolvePackageName = recentsComponentName.getPackageName();
-        info.serviceInfo.packageName = info.resolvePackageName;
-        info.serviceInfo.name = recentsComponentName.getClassName();
-        info.serviceInfo.applicationInfo = new ApplicationInfo();
-        info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
-        mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
-
-        assertThat(SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext))
-                .isTrue();
-    }
-
-    @Test
-    public void testIsGestureAvailable_overlayDisabled_matchingServiceExists_shouldReturnFalse() {
-        SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
-                false);
-
-        final ComponentName recentsComponentName = ComponentName.unflattenFromString(
-                mContext.getString(com.android.internal.R.string.config_recentsComponentName));
-        final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
-                .setPackage(recentsComponentName.getPackageName());
-        mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
-
-        assertThat(
-                SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext)).isFalse();
-    }
-
-    @Test
-    public void testIsGestureAvailable_noMatchingServiceExists_shouldReturnFalse() {
-        assertThat(
-                SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext)).isFalse();
-    }
-
-    @Test
-    public void testIsGestureAvailable_noOverlayPackage_shouldReturnFalse() {
-        assertThat(SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext,
-                "com.package.fake")).isFalse();
-    }
-
-    @Test
-    public void testIsChecked_defaultIsLegacy_shouldReturnTrue() {
-        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
-                NAV_BAR_MODE_3BUTTON);
-        assertThat(mController.isChecked()).isTrue();
-    }
-
-    @Test
-    public void testIsChecked_defaultIsSwipeUp_shouldReturnFalse() {
-        // Turn on the Swipe Up mode (2-buttons)
-        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
-                NAV_BAR_MODE_2BUTTON);
-        assertThat(mController.isChecked()).isFalse();
-    }
-
-    @Test
-    public void testIsChecked_defaultIsEdgeToEdge_shouldReturnFalse() {
-        // Turn on the Edge to Edge
-        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
-                NAV_BAR_MODE_GESTURAL);
-        assertThat(mController.isChecked()).isFalse();
-    }
-
-    @Test
-    public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
-        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
-                NAV_BAR_MODE_3BUTTON);
-        // Set the setting to be enabled.
-        mController.onRadioButtonClicked(null);
-        assertThat(mController.isChecked()).isTrue();
-    }
-
-    @Test
-    public void testOnRadioButtonClicked_setsCorrectRadioButtonChecked() {
-        RadioButtonPreference radioLegacy = mock(RadioButtonPreference.class);
-        RadioButtonPreference radioSwipeUp = mock(RadioButtonPreference.class);
-        RadioButtonPreference radioEdgeToEdge = mock(RadioButtonPreference.class);
-        PreferenceScreen screen = mock(PreferenceScreen.class);
-
-        when(screen.findPreference(PREF_KEY_LEGACY)).thenReturn(radioLegacy);
-        when(screen.findPreference(PREF_KEY_SWIPE_UP)).thenReturn(radioSwipeUp);
-        when(screen.findPreference(PREF_KEY_EDGE_TO_EDGE)).thenReturn(radioEdgeToEdge);
-
-        mController.displayPreference(screen);
-        mController.onRadioButtonClicked(radioLegacy);
-
-        verify(radioLegacy, times(1)).setChecked(true);
-        verify(radioSwipeUp, times(1)).setChecked(false);
-        verify(radioEdgeToEdge, times(1)).setChecked(false);
-    }
-
-    @Test
-    public void isSliceable_returnsFalse() {
-        assertThat(mController.isSliceable()).isFalse();
-    }
-
-    @Test
-    public void isSliceableIncorrectKey_returnsFalse() {
-        final SystemNavigationLegacyPreferenceController controller =
-                new SystemNavigationLegacyPreferenceController(mContext, "bad_key");
-        assertThat(controller.isSliceable()).isFalse();
-    }
-}
@@ -11,7 +11,7 @@
  * 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.
+ * limitations under the License
  */
 
 package com.android.settings.gestures;
@@ -20,36 +20,25 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
 import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
 import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
 
-import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
-import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
-import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
+import static com.android.settings.gestures.SystemNavigationPreferenceController.PREF_KEY_SYSTEM_NAVIGATION;
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
-import android.content.om.IOverlayManager;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.ResolveInfo;
 import android.content.pm.ServiceInfo;
-
-import androidx.preference.PreferenceScreen;
+import android.text.TextUtils;
 
 import com.android.internal.R;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settings.widget.RadioButtonPreference;
 
 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;
@@ -59,15 +48,12 @@ import org.robolectric.shadows.ShadowPackageManager;
 
 @RunWith(RobolectricTestRunner.class)
 @Config(shadows = SettingsShadowResources.class)
-public class SystemNavigationSwipeUpPreferenceControllerTest {
+public class SystemNavigationPreferenceControllerTest {
 
     private Context mContext;
     private ShadowPackageManager mPackageManager;
 
-    @Mock
-    private IOverlayManager mOverlayManager;
-
-    private SystemNavigationSwipeUpPreferenceController mController;
+    private SystemNavigationPreferenceController mController;
 
     private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
 
@@ -81,8 +67,8 @@ public class SystemNavigationSwipeUpPreferenceControllerTest {
         mContext = RuntimeEnvironment.application;
         mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
 
-        mController = new SystemNavigationSwipeUpPreferenceController(mContext, mOverlayManager,
-                PREF_KEY_SWIPE_UP);
+        mController = new SystemNavigationPreferenceController(mContext,
+                PREF_KEY_SYSTEM_NAVIGATION);
     }
 
     @After
@@ -105,8 +91,7 @@ public class SystemNavigationSwipeUpPreferenceControllerTest {
         info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
         mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
 
-        assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext))
-                .isTrue();
+        assertThat(SystemNavigationPreferenceController.isGestureAvailable(mContext)).isTrue();
     }
 
     @Test
@@ -120,80 +105,65 @@ public class SystemNavigationSwipeUpPreferenceControllerTest {
                 .setPackage(recentsComponentName.getPackageName());
         mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
 
-        assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext))
-                .isFalse();
+        assertThat(SystemNavigationPreferenceController.isGestureAvailable(mContext)).isFalse();
     }
 
     @Test
     public void testIsGestureAvailable_noMatchingServiceExists_shouldReturnFalse() {
-        assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext))
-                .isFalse();
+        assertThat(SystemNavigationPreferenceController.isGestureAvailable(mContext)).isFalse();
     }
 
     @Test
-    public void testIsGestureAvailable_noOverlayPackage_shouldReturnFalse() {
-        assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext,
+    public void testIsOverlayPackageAvailable_noOverlayPackage_shouldReturnFalse() {
+        assertThat(SystemNavigationPreferenceController.isOverlayPackageAvailable(mContext,
                 "com.package.fake")).isFalse();
     }
 
     @Test
-    public void testIsChecked_defaultIsSwipeUp_shouldReturnTrue() {
+    public void testIsSwipeUpEnabled() {
         SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
                 NAV_BAR_MODE_2BUTTON);
-        assertThat(mController.isChecked()).isTrue();
-    }
+        assertThat(SystemNavigationPreferenceController.isSwipeUpEnabled(mContext)).isTrue();
 
-    @Test
-    public void testIsChecked_defaultIsLegacy_shouldReturnFalse() {
         SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
                 NAV_BAR_MODE_3BUTTON);
-        assertThat(mController.isChecked()).isFalse();
-    }
+        assertThat(SystemNavigationPreferenceController.isSwipeUpEnabled(mContext)).isFalse();
 
-    @Test
-    public void testIsChecked_defaultIsEdgeToEdge_shouldReturnFalse() {
         SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
                 NAV_BAR_MODE_GESTURAL);
-        assertThat(mController.isChecked()).isFalse();
+        assertThat(SystemNavigationPreferenceController.isSwipeUpEnabled(mContext)).isFalse();
     }
 
     @Test
-    public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
+    public void testIsEdgeToEdgeEnabled() {
+        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+                NAV_BAR_MODE_GESTURAL);
+        assertThat(SystemNavigationPreferenceController.isEdgeToEdgeEnabled(mContext)).isTrue();
+
+        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+                NAV_BAR_MODE_3BUTTON);
+        assertThat(SystemNavigationPreferenceController.isEdgeToEdgeEnabled(mContext)).isFalse();
+
         SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
                 NAV_BAR_MODE_2BUTTON);
-        // Set the setting to be enabled.
-        mController.onRadioButtonClicked(null);
-        assertThat(mController.isChecked()).isTrue();
+        assertThat(SystemNavigationPreferenceController.isEdgeToEdgeEnabled(mContext)).isFalse();
     }
 
     @Test
-    public void testOnRadioButtonClicked_setsCorrectRadioButtonChecked() {
-        RadioButtonPreference radioLegacy = mock(RadioButtonPreference.class);
-        RadioButtonPreference radioSwipeUp = mock(RadioButtonPreference.class);
-        RadioButtonPreference radioEdgeToEdge = mock(RadioButtonPreference.class);
-        PreferenceScreen screen = mock(PreferenceScreen.class);
-
-        when(screen.findPreference(PREF_KEY_LEGACY)).thenReturn(radioLegacy);
-        when(screen.findPreference(PREF_KEY_SWIPE_UP)).thenReturn(radioSwipeUp);
-        when(screen.findPreference(PREF_KEY_EDGE_TO_EDGE)).thenReturn(radioEdgeToEdge);
-
-        mController.displayPreference(screen);
-        mController.onRadioButtonClicked(radioSwipeUp);
-
-        verify(radioLegacy, times(1)).setChecked(false);
-        verify(radioSwipeUp, times(1)).setChecked(true);
-        verify(radioEdgeToEdge, times(1)).setChecked(false);
-    }
+    public void testGetSummary() {
+        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+                NAV_BAR_MODE_GESTURAL);
+        assertThat(TextUtils.equals(mController.getSummary(), mContext.getText(
+                com.android.settings.R.string.edge_to_edge_navigation_title))).isTrue();
 
-    @Test
-    public void isSliceable_returnsFalse() {
-        assertThat(mController.isSliceable()).isFalse();
-    }
+        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+                NAV_BAR_MODE_3BUTTON);
+        assertThat(TextUtils.equals(mController.getSummary(),
+                mContext.getText(com.android.settings.R.string.legacy_navigation_title))).isTrue();
 
-    @Test
-    public void isSliceableIncorrectKey_returnsFalse() {
-        final SystemNavigationSwipeUpPreferenceController controller =
-                new SystemNavigationSwipeUpPreferenceController(mContext, "bad_key");
-        assertThat(controller.isSliceable()).isFalse();
+        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+                NAV_BAR_MODE_2BUTTON);
+        assertThat(TextUtils.equals(mController.getSummary(), mContext.getText(
+                com.android.settings.R.string.swipe_up_to_switch_apps_title))).isTrue();
     }
-}
+}
\ No newline at end of file
index e2ac8ce..ce4c9a2 100644 (file)
@@ -123,6 +123,18 @@ public class ApnPreferenceControllerTest {
         assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
     }
 
+
+    @Test
+    public void getAvailabilityStatus_hideCarrierNetworkSettings_returnUnavailable() {
+        doReturn(PhoneConstants.PHONE_TYPE_GSM).when(mTelephonyManager).getPhoneType();
+        final PersistableBundle bundle = new PersistableBundle();
+        bundle.putBoolean(CarrierConfigManager.KEY_APN_EXPAND_BOOL, true);
+        bundle.putBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL, true);
+        doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+    }
+
     @Test
     public void handPreferenceTreeClick_fireIntent() {
         ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
index 7dfe520..61599e6 100644 (file)
@@ -198,4 +198,25 @@ public class MobileNetworkUtilsTest {
         assertThat(MobileNetworkUtils.getSearchableSubscriptionId(mContext))
                 .isEqualTo(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
     }
+
+    @Test
+    public void shouldDisplayNetworkSelectOptions_HideCarrierNetwork_returnFalse() {
+        mCarrierConfig.putBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL,
+                true);
+
+        assertThat(MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, SUB_ID_1))
+                .isFalse();
+    }
+
+    @Test
+    public void shouldDisplayNetworkSelectOptions_allCheckPass_returnTrue() {
+        mCarrierConfig.putBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL,
+                false);
+        mCarrierConfig.putBoolean(CarrierConfigManager.KEY_OPERATOR_SELECTION_EXPAND_BOOL, true);
+        mCarrierConfig.putBoolean(CarrierConfigManager.KEY_CSP_ENABLED_BOOL, false);
+        when(mTelephonyManager.getPhoneType()).thenReturn(PhoneConstants.PHONE_TYPE_GSM);
+
+        assertThat(MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, SUB_ID_1))
+                .isTrue();
+    }
 }
index fabc50e..18ed006 100644 (file)
@@ -238,20 +238,13 @@ public class WifiSliceTest {
         setWorkerResults(createAccessPoint(AP1_NAME, true, true));
         doReturn(makeCaptivePortalNetworkCapabilities()).when(mConnectivityManager)
                 .getNetworkCapabilities(any());
+        final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
+                R.drawable.ic_settings_accent);
 
         final Slice wifiSlice = mWifiSlice.getSlice();
         final List<SliceItem> sliceItems = wifiSlice.getItems();
 
         SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP1_NAME);
-        assertCaptivePortalItems(sliceItems);
-    }
-
-    private void assertCaptivePortalItems(List<SliceItem> sliceItems) {
-        final String expectedSummary = mContext.getString(R.string.switch_on_text);
-        SliceTester.assertAnySliceItemContainsSubtitle(sliceItems, expectedSummary);
-
-        final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
-                R.drawable.ic_settings_accent);
         SliceTester.assertAnySliceItemContainsIcon(sliceItems, expectedIcon);
     }