</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"
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"
<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>
<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]-->
<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>
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"
<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"/>
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.Nullable;
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;
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;
private Button mNextButton;
+ private ViewGroup mContent;
+
// Categories
private ArrayList<DashboardCategory> mCategories = new ArrayList<>();
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) {
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 {
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;
+ }
}
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());
.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();
+ }
+ }
}
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;
);
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);
mSwitchDiversity = findViewById(R.id.toggle_diversity);
mSwitchDiversity.setListener(mSwitchDiversityListener);
+
+ if (accessibilityEnabled) {
+ accessibilityButton.callOnClick();
+ }
}
@Override
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;
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);
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;
return this;
}
+ public SubSettingLauncher setExtras(Bundle extras) {
+ mLaunchRequest.extras = extras;
+ return this;
+ }
+
public SubSettingLauncher setSourceMetricsCategory(int sourceMetricsCategory) {
mLaunchRequest.sourceMetricsCategory = sourceMetricsCategory;
return this;
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");
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.
*/
int mRequestCode;
UserHandle userHandle;
Bundle arguments;
+ Bundle extras;
}
}
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;
}
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())
: "");
@VisibleForTesting
String getCdmaPrlVersion() {
- return mTelephonyManager.getCdmaPrlVersion();
+ // PRL needs to read from SIM. So if no SIM, return empty
+ return mSubscriptionInfo != null ? mTelephonyManager.getCdmaPrlVersion() : "";
}
@VisibleForTesting
String getMeid() {
return mTelephonyManager.getMeid(mSlotId);
}
+
+ @VisibleForTesting
+ private boolean isValidSlotIndex(int slotIndex, TelephonyManager telephonyManager) {
+ return slotIndex >= 0 && slotIndex < telephonyManager.getPhoneCount();
+ }
}
+++ /dev/null
-/*
- * 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);
- }
-}
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);
.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
}
@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(
+++ /dev/null
-/*
- * 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);
- }
-}
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
}
}
- @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)) {
}
// 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;
}
}
+++ /dev/null
-/*
- * 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);
- }
-}
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) {
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;
}
|| 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;
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;
TelephonyBasePreferenceController implements
AutoSelectPreferenceController.OnNetworkSelectModeListener {
- private int mSubId;
private TelephonyManager mTelephonyManager;
private Preference mPreference;
}
/**
- * 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)
return AccessPoint.SECURITY_PSK;
}
}
+ if (accessPointSecurity == AccessPoint.SECURITY_OWE_TRANSITION) {
+ if (mWifiManager.isEnhancedOpenSupported()) {
+ return AccessPoint.SECURITY_OWE;
+ } else {
+ return AccessPoint.SECURITY_NONE;
+ }
+ }
+
return accessPointSecurity;
}
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;
}
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);
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;
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
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,
.setKeywords(getKeywords())
.addRow(new ListBuilder.RowBuilder()
.setTitle(title)
- .setSubtitle(summary)
.addEndItem(toggleSliceAction)
.setPrimaryAction(primarySliceAction));
}
}
}
- 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 */,
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;
@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();
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
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);
}
}
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
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();
+ }
}
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);
mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID + 1));
mController.populateImeiInfo();
+
verify(mDialog, never()).setText(anyInt(), any());
}
}
@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);
+++ /dev/null
-/*
- * 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();
- }
-}
--- /dev/null
+/*
+ * 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);
+ }
+}
+++ /dev/null
-/*
- * 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();
- }
-}
* 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;
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;
@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";
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
info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
- assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext))
- .isTrue();
+ assertThat(SystemNavigationPreferenceController.isGestureAvailable(mContext)).isTrue();
}
@Test
.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
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);
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();
+ }
}
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);
}