Merge "Update enrollment edu animation." into sc-v2-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index dc11920..3949f36 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -197,7 +197,6 @@
</receiver>
<activity android:name=".SubSettings"
- android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout|smallestScreenSize"
android:theme="@style/Theme.SubSettings" />
<activity android:name=".Settings$CreateShortcutActivity"
@@ -242,6 +241,11 @@
android:exported="true"
android:launchMode="singleTask"
android:configChanges="orientation|screenSize|keyboardHidden">
+ <!-- Note: Since the framework does not support the multiple requests of network scan
+ from the UI, this singleTask can protect that there is only one
+ Settings$NetworkSelectActivity which can request the network scan.
+ If removing the "singleTask" in the future, please also modify the
+ Settings$NetworkSelectActivity's structure. -->
<intent-filter android:priority="1">
<!-- Displays the MobileNetworkActivity and opt-in dialog for capability discovery. -->
<action android:name="android.telephony.ims.action.SHOW_CAPABILITY_DISCOVERY_OPT_IN" />
@@ -371,6 +375,16 @@
</activity>
<activity
+ android:name="Settings$NetworkSelectActivity"
+ android:label="@string/choose_network_title"
+ android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout|smallestScreenSize">
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.network.telephony.NetworkSelectSettings" />
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+ </activity>
+
+ <activity
android:name="Settings$WifiDetailsSettingsActivity"
android:label="@string/wifi_details_title"
android:icon="@drawable/ic_homepage_network"
@@ -1258,6 +1272,23 @@
</activity>
<activity
+ android:name=".Settings$BlueToothPairingActivity"
+ android:label="@string/bluetooth_pairing_page_title"
+ android:permission="android.permission.BLUETOOTH_SCAN"
+ android:exported="true">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.BLUETOOTH_PAIRING_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.bluetooth.BluetoothPairingDetail" />
+ <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
+ android:value="@string/menu_key_connected_devices"/>
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+ </activity>
+
+ <activity
android:name="SettingsLicenseActivity"
android:label="@string/settings_license_activity_title"
android:exported="true"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 85d216e..b566d98 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5280,13 +5280,13 @@
<!-- Message of the magnification mode option to choose the magnification mode. [CHAR LIMIT=none] -->
<string name="accessibility_magnification_area_settings_mode_switch_summary">Tap the switch button to move between both options</string>
<!-- Title for the accessibility magnification switch shortcut dialog. [CHAR LIMIT=48] -->
- <string name="accessibility_magnification_switch_shortcut_title">Switch to accessibility button?</string>
+ <string name="accessibility_magnification_switch_shortcut_title">This may slow down your keyboard</string>
<!-- Message for the accessibility magnification switch shortcut dialog. [CHAR LIMIT=none] -->
- <string name="accessibility_magnification_switch_shortcut_message">Using triple-tap to magnify part of your screen causes typing and other delays.\n\nThe accessibility button floats on your screen over other apps. Tap it to magnify.</string>
- <!-- Title for the switch shortcut button in accessibility switch shortcut dialog to change the config shortcut value. [CHAR LIMIT=45] -->
- <string name="accessibility_magnification_switch_shortcut_positive_button">Switch to accessibility button</string>
- <!-- Title for the cancel button in accessibility switch shortcut dialog to keep the config shortcut value. [CHAR LIMIT=54] -->
- <string name="accessibility_magnification_switch_shortcut_negative_button">Use triple-tap</string>
+ <string name="accessibility_magnification_switch_shortcut_message">When using triple-tap to magnify part of your screen, you may notice issues over the keyboard.\n\nTo avoid this, you can change your magnification shortcut from triple-tap to another option.\n<annotation id="link">Change setting</annotation></string>
+ <!-- Title for the switch shortcut button in accessibility switch shortcut dialog to confirm the action. [CHAR LIMIT=45] -->
+ <string name="accessibility_magnification_switch_shortcut_positive_button">Continue anyway</string>
+ <!-- Title for the cancel button in accessibility switch shortcut dialog to go back to edit. [CHAR LIMIT=54] -->
+ <string name="accessibility_magnification_switch_shortcut_negative_button">Cancel</string>
<!-- Title for the accessibility preference screen to enable screen magnification settings. [CHAR LIMIT=35] -->
<string name="accessibility_magnification_service_settings_title">Magnification settings</string>
<!-- Title for the accessibility preference screen to enable triple-tap gesture screen magnification. [CHAR LIMIT=35] -->
diff --git a/res/xml/mobile_network_settings.xml b/res/xml/mobile_network_settings.xml
index 7d1ff09..673994a 100644
--- a/res/xml/mobile_network_settings.xml
+++ b/res/xml/mobile_network_settings.xml
@@ -223,7 +223,6 @@
<Preference
android:key="choose_network_key"
android:title="@string/choose_network_title"
- android:fragment="com.android.phone.NetworkSelectSetting"
settings:controller="com.android.settings.network.telephony.gsm.OpenNetworkSelectPagePreferenceController"/>
</PreferenceCategory>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 893c0ad..7154081 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -90,6 +90,7 @@
public static class PublicVolumeSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiSettingsActivity extends SettingsActivity { /* empty */ }
public static class NetworkProviderSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class NetworkSelectActivity extends SettingsActivity { /* empty */ }
/** Activity for the Wi-Fi network details settings. */
public static class WifiDetailsSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiP2pSettingsActivity extends SettingsActivity { /* empty */ }
@@ -123,6 +124,8 @@
public static class AccessibilityDaltonizerSettingsActivity extends SettingsActivity { /* empty */ }
/** Activity for lockscreen settings. */
public static class LockScreenSettingsActivity extends SettingsActivity { /* empty */ }
+ /** Activity for bluetooth pairing settings. */
+ public static class BlueToothPairingActivity extends SettingsActivity { /* empty */ }
/** Activity for Reduce Bright Colors. */
public static class ReduceBrightColorsSettingsActivity extends SettingsActivity { /* empty */ }
/** Activity for the security dashboard. */
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 2b5f695..d3d3604 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -377,8 +377,9 @@
public static Intent getTrampolineIntent(Intent intent, String highlightMenuKey) {
final Intent detailIntent = new Intent(intent);
// It's a deep link intent, SettingsHomepageActivity will set SplitPairRule and start it.
- final Intent trampolineIntent = new Intent(ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY);
- trampolineIntent.replaceExtras(detailIntent);
+ final Intent trampolineIntent = new Intent(ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY)
+ .setPackage(Utils.SETTINGS_PACKAGE_NAME)
+ .replaceExtras(detailIntent);
// Relay detail intent data to prevent failure of Intent#ParseUri.
// If Intent#getData() is not null, Intent#toUri will return an Uri which has the scheme of
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
index 3a6bea9..7a28e39 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
@@ -38,7 +38,6 @@
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.transition.SettingsTransitionHelper;
-import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.util.ThemeHelper;
@@ -130,7 +129,6 @@
final Intent intent = new Intent(this,
AccessibilityScreenSizeForSetupWizardActivity.class);
intent.putExtra(VISION_FRAGMENT_NO, FragmentType.FONT_SIZE);
- intent.putExtra(EXTRA_PAGE_TRANSITION_TYPE, TransitionType.TRANSITION_FADE);
startActivity(intent);
Log.d(LOG_TAG, "Launch font size settings");
finish();
diff --git a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
index 037f584..2ce2206 100644
--- a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
+++ b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
@@ -53,6 +53,7 @@
public class RemoveAccountPreferenceController extends AbstractPreferenceController
implements PreferenceControllerMixin, OnClickListener {
+ private static final String TAG = "RemoveAccountPrefController";
private static final String KEY_REMOVE_ACCOUNT = "remove_account";
private final MetricsFeatureProvider mMetricsFeatureProvider;
@@ -175,10 +176,11 @@
| IOException
| AuthenticatorException e) {
// handled below
- }
- if (failed) {
+ Log.w(TAG, "Remove account error: " + e);
RemoveAccountFailureDialog.show(getTargetFragment());
- } else {
+ }
+ Log.i(TAG, "failed: " + failed);
+ if (!failed) {
targetActivity.finish();
}
}, null, mUserHandle);
@@ -210,7 +212,7 @@
final Context context = getActivity();
return new AlertDialog.Builder(context)
- .setTitle(R.string.really_remove_account_title)
+ .setTitle(R.string.remove_account_label)
.setMessage(R.string.remove_account_failed)
.setPositiveButton(android.R.string.ok, null)
.create();
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index 74ea27b..eadb5b8 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -19,10 +19,12 @@
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.Intent;
+import android.hardware.SensorPrivacyManager;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.face.FaceManager;
import android.hardware.face.FaceSensorPropertiesInternal;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -34,10 +36,12 @@
import com.android.settings.R;
import com.android.settings.Utils;
+import com.android.settings.biometrics.BiometricEnrollActivity;
import com.android.settings.biometrics.BiometricEnrollIntroduction;
import com.android.settings.biometrics.BiometricUtils;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.utils.SensorPrivacyManagerHelper;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.google.android.setupcompat.template.FooterButton;
@@ -57,6 +61,7 @@
private FaceFeatureProvider mFaceFeatureProvider;
@Nullable private FooterButton mPrimaryFooterButton;
@Nullable private FooterButton mSecondaryFooterButton;
+ @Nullable private SensorPrivacyManager mSensorPrivacyManager;
@Override
protected void onCancelButtonClick(View view) {
@@ -150,6 +155,14 @@
});
}
}
+
+ mSensorPrivacyManager = getApplicationContext()
+ .getSystemService(SensorPrivacyManager.class);
+ final SensorPrivacyManagerHelper helper = SensorPrivacyManagerHelper
+ .getInstance(getApplicationContext());
+ final boolean cameraPrivacyEnabled = helper
+ .isSensorBlocked(SensorPrivacyManager.Sensors.CAMERA, mUserId);
+ Log.v(TAG, "cameraPrivacyEnabled : " + cameraPrivacyEnabled);
}
protected boolean generateChallengeOnCreate() {
@@ -309,6 +322,28 @@
}
@Override
+ protected void onNextButtonClick(View view) {
+ final boolean parentelConsentRequired =
+ getIntent()
+ .getBooleanExtra(BiometricEnrollActivity.EXTRA_REQUIRE_PARENTAL_CONSENT, false);
+ final boolean cameraPrivacyEnabled = SensorPrivacyManagerHelper
+ .getInstance(getApplicationContext())
+ .isSensorBlocked(SensorPrivacyManager.Sensors.CAMERA, mUserId);
+ final boolean isSetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
+ final boolean isSettingUp = isSetupWizard || (parentelConsentRequired
+ && !WizardManagerHelper.isUserSetupComplete(this));
+ if (cameraPrivacyEnabled && !isSettingUp) {
+ if (mSensorPrivacyManager == null) {
+ mSensorPrivacyManager = getApplicationContext()
+ .getSystemService(SensorPrivacyManager.class);
+ }
+ mSensorPrivacyManager.showSensorUseDialog(SensorPrivacyManager.Sensors.CAMERA);
+ } else {
+ super.onNextButtonClick(view);
+ }
+ }
+
+ @Override
@NonNull
protected FooterButton getPrimaryFooterButton() {
if (mPrimaryFooterButton == null) {
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 800800e..804f856 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -68,6 +68,7 @@
import com.android.settings.biometrics.face.FaceSettings;
import com.android.settings.biometrics.fingerprint.FingerprintSettings;
import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
+import com.android.settings.bluetooth.BluetoothPairingDetail;
import com.android.settings.bugreporthandler.BugReportHandlerPicker;
import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
@@ -119,6 +120,7 @@
import com.android.settings.network.NetworkProviderSettings;
import com.android.settings.network.apn.ApnEditor;
import com.android.settings.network.apn.ApnSettings;
+import com.android.settings.network.telephony.NetworkSelectSettings;
import com.android.settings.nfc.AndroidBeam;
import com.android.settings.nfc.PaymentSettings;
import com.android.settings.notification.ConfigureNotificationSettings;
@@ -175,6 +177,7 @@
public static final String[] ENTRY_FRAGMENTS = {
AdvancedConnectedDeviceDashboardFragment.class.getName(),
CreateShortcut.class.getName(),
+ BluetoothPairingDetail.class.getName(),
WifiSettings.class.getName(),
WifiNetworkDetailsFragment.class.getName(),
ConfigureWifiSettings.class.getName(),
@@ -318,6 +321,7 @@
InteractAcrossProfilesDetails.class.getName(),
MediaControlsSettings.class.getName(),
NetworkProviderSettings.class.getName(),
+ NetworkSelectSettings.class.getName(),
AlarmsAndRemindersDetails.class.getName(),
MediaManagementAppsDetails.class.getName()
};
@@ -341,6 +345,7 @@
Settings.WifiSettingsActivity.class.getName(),
Settings.DataUsageSummaryActivity.class.getName(),
Settings.NetworkProviderSettingsActivity.class.getName(),
+ Settings.NetworkSelectActivity.class.getName(),
// Home page > Connected devices
Settings.BluetoothSettingsActivity.class.getName(),
Settings.WifiDisplaySettingsActivity.class.getName(),
diff --git a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
index 0947938..cbfbd34 100644
--- a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
@@ -18,7 +18,6 @@
import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -32,8 +31,6 @@
import com.android.settingslib.core.lifecycle.events.OnStop;
import com.android.settingslib.utils.ThreadUtils;
-import java.util.HashMap;
-
public class TopLevelBatteryPreferenceController extends BasePreferenceController implements
LifecycleObserver, OnStart, OnStop, BatteryPreferenceController {
@@ -43,13 +40,9 @@
Preference mPreference;
private final BatteryBroadcastReceiver mBatteryBroadcastReceiver;
private BatteryInfo mBatteryInfo;
- private BatterySettingsFeatureProvider mBatterySettingsFeatureProvider;
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
private String mBatteryStatusLabel;
- @VisibleForTesting
- protected static HashMap<String, ComponentName> sReplacingActivityMap = new HashMap<>();
-
public TopLevelBatteryPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mBatteryBroadcastReceiver = new BatteryBroadcastReceiver(mContext);
@@ -63,8 +56,6 @@
}, true /* shortString */);
});
- mBatterySettingsFeatureProvider = FeatureFactory.getFactory(context)
- .getBatterySettingsFeatureProvider(context);
mBatteryStatusFeatureProvider = FeatureFactory.getFactory(context)
.getBatteryStatusFeatureProvider(context);
}
@@ -82,37 +73,6 @@
}
@Override
- public boolean handlePreferenceTreeClick(Preference preference) {
- String prefFrag = preference.getFragment();
- if (prefFrag == null || prefFrag.isEmpty()) {
- // Not a redirect, so use the default.
- return super.handlePreferenceTreeClick(preference);
- }
-
- ComponentName currentFragmentName = convertClassPathToComponentName(prefFrag);
- if (currentFragmentName == null) {
- return super.handlePreferenceTreeClick(preference);
- }
-
- ComponentName replacingActivity;
- if (sReplacingActivityMap.containsKey(prefFrag)) {
- replacingActivity = sReplacingActivityMap.get(prefFrag);
- } else {
- replacingActivity = mBatterySettingsFeatureProvider.getReplacingActivity(
- currentFragmentName);
- sReplacingActivityMap.put(prefFrag, replacingActivity);
- }
-
- if (replacingActivity == null || currentFragmentName.compareTo(replacingActivity) == 0) {
- return super.handlePreferenceTreeClick(preference);
- }
- Intent intent = new Intent();
- intent.setComponent(currentFragmentName);
- mContext.startActivity(intent);
- return true;
- }
-
- @Override
public void onStart() {
mBatteryBroadcastReceiver.register();
}
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index e25e1f5..9076053 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -125,11 +125,8 @@
}
Log.i(TAG, "showHomepageWithSuggestion: " + showSuggestion);
final View homepageView = mHomepageView;
- if (!mIsTwoPaneLastTime) {
- mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
- } else {
- mTwoPaneSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
- }
+ mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
+ mTwoPaneSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
mHomepageView = null;
mLoadedListeners.forEach(listener -> listener.onHomepageLoaded());
@@ -167,10 +164,13 @@
mCategoryMixin = new CategoryMixin(this);
getLifecycle().addObserver(mCategoryMixin);
+ final String highlightMenuKey = getHighlightMenuKey();
// Only allow features on high ram devices.
if (!getSystemService(ActivityManager.class).isLowRamDevice()) {
initAvatarView();
- showSuggestionFragment();
+ final boolean scrollNeeded = mIsEmbeddingActivityEnabled
+ && !TextUtils.equals(getString(DEFAULT_HIGHLIGHT_MENU_KEY), highlightMenuKey);
+ showSuggestionFragment(scrollNeeded);
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.CONTEXTUAL_HOME)) {
showFragment(() -> new ContextualCardsFragment(), R.id.contextual_cards_content);
}
@@ -178,7 +178,7 @@
mMainFragment = showFragment(() -> {
final TopLevelSettings fragment = new TopLevelSettings();
fragment.getArguments().putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY,
- getHighlightMenuKey());
+ highlightMenuKey);
return fragment;
}, R.id.main_content);
@@ -265,7 +265,7 @@
findViewById(R.id.settings_homepage_container).setBackgroundColor(color);
}
- private void showSuggestionFragment() {
+ private void showSuggestionFragment(boolean scrollNeeded) {
final Class<? extends Fragment> fragmentClass = FeatureFactory.getFactory(this)
.getSuggestionFeatureProvider(this).getContextualSuggestionFragment();
if (fragmentClass == null) {
@@ -275,8 +275,9 @@
mSuggestionView = findViewById(R.id.suggestion_content);
mTwoPaneSuggestionView = findViewById(R.id.two_pane_suggestion_content);
mHomepageView = findViewById(R.id.settings_homepage_container);
- // Hide the homepage for preparing the suggestion.
- mHomepageView.setVisibility(View.INVISIBLE);
+ // Hide the homepage for preparing the suggestion. If scrolling is needed, the list views
+ // should be initialized in the invisible homepage view to prevent a scroll flicker.
+ mHomepageView.setVisibility(scrollNeeded ? View.INVISIBLE : View.GONE);
// Schedule a timer to show the homepage and hide the suggestion on timeout.
mHomepageView.postDelayed(() -> showHomepageWithSuggestion(false),
HOMEPAGE_LOADING_TIMEOUT_MS);
diff --git a/src/com/android/settings/homepage/TopLevelSettings.java b/src/com/android/settings/homepage/TopLevelSettings.java
index 2bb8e34..f2e5a35 100644
--- a/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/src/com/android/settings/homepage/TopLevelSettings.java
@@ -54,6 +54,7 @@
private static final String PREF_KEY_SUPPORT = "top_level_support";
private TopLevelHighlightMixin mHighlightMixin;
+ private boolean mFirstStarted = true;
public TopLevelSettings() {
final Bundle args = new Bundle();
@@ -135,9 +136,11 @@
@Override
public void onStart() {
- // Set default highlight menu key for 1-pane homepage since it will show the placeholder
- // page once changing back to 2-pane.
- if (!ActivityEmbeddingUtils.isTwoPaneResolution(getActivity())) {
+ if (mFirstStarted) {
+ mFirstStarted = false;
+ } else if (!ActivityEmbeddingUtils.isTwoPaneResolution(getActivity())) {
+ // Set default highlight menu key for 1-pane homepage since it will show the placeholder
+ // page once changing back to 2-pane.
setHighlightMenuKey(getString(SettingsHomepageActivity.DEFAULT_HIGHLIGHT_MENU_KEY),
/* scrollNeeded= */ false);
}
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index 9e1b6da..5541888 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -316,7 +316,7 @@
: (serviceState.getState() == ServiceState.STATE_IN_SERVICE);
if (isDataInService || isVoiceInService || isCarrierNetworkActive) {
icon = mSubsPrefCtrlInjector.getIcon(mContext, level, numLevels,
- !mTelephonyManager.isDataEnabled());
+ !tmForSubId.isDataEnabled());
}
final boolean isActiveCellularNetwork =
diff --git a/src/com/android/settings/network/telephony/NetworkScanHelper.java b/src/com/android/settings/network/telephony/NetworkScanHelper.java
index e0a9c5e..740b6bb 100644
--- a/src/com/android/settings/network/telephony/NetworkScanHelper.java
+++ b/src/com/android/settings/network/telephony/NetworkScanHelper.java
@@ -227,6 +227,7 @@
mExecutor,
mInternalNetworkScanCallback);
if (mNetworkScanRequester == null) {
+ Log.d(TAG, "mNetworkScanRequester == null");
onError(NetworkScan.ERROR_RADIO_INTERFACE_ERROR);
}
}
diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
index c1c0f8f..9faecbb 100644
--- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java
+++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
@@ -19,6 +19,7 @@
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -98,7 +99,11 @@
mUseNewApi = getContext().getResources().getBoolean(
com.android.internal.R.bool.config_enableNewAutoSelectNetworkUI);
- mSubId = getArguments().getInt(Settings.EXTRA_SUB_ID);
+ Intent intent = getActivity().getIntent();
+ if (intent != null) {
+ mSubId = intent.getIntExtra(Settings.EXTRA_SUB_ID,
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ }
mPreferenceCategory = findPreference(PREF_KEY_NETWORK_OPERATORS);
mStatusMessagePreference = new Preference(getContext());
@@ -121,13 +126,12 @@
mIsAggregationEnabled = getContext().getResources().getBoolean(
R.bool.config_network_selection_list_aggregation_enabled);
Log.d(TAG, "init: mUseNewApi:" + mUseNewApi
- + " ,mIsAggregationEnabled:" + mIsAggregationEnabled);
+ + " ,mIsAggregationEnabled:" + mIsAggregationEnabled + " ,mSubId:" + mSubId);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
-
final Activity activity = getActivity();
if (activity != null) {
mProgressHeader = setPinnedHeaderView(R.layout.progress_header)
diff --git a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
index 997235c..028c4e7 100644
--- a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
@@ -20,9 +20,8 @@
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
import android.app.ProgressDialog;
-import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.os.Bundle;
+import android.content.Intent;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.Looper;
@@ -43,10 +42,8 @@
import androidx.preference.SwitchPreference;
import com.android.settings.R;
-import com.android.settings.core.SubSettingLauncher;
import com.android.settings.network.AllowedNetworkTypesListener;
import com.android.settings.network.telephony.MobileNetworkUtils;
-import com.android.settings.network.telephony.NetworkSelectSettings;
import com.android.settings.network.telephony.TelephonyTogglePreferenceController;
import com.android.settingslib.utils.ThreadUtils;
@@ -151,25 +148,26 @@
public boolean setChecked(boolean isChecked) {
if (isChecked) {
setAutomaticSelectionMode();
- return false;
} else {
- final Bundle bundle = new Bundle();
- bundle.putInt(Settings.EXTRA_SUB_ID, mSubId);
- new SubSettingLauncher(mContext)
- .setDestination(NetworkSelectSettings.class.getName())
- .setSourceMetricsCategory(SettingsEnums.MOBILE_NETWORK_SELECT)
- .setTitleRes(R.string.choose_network_title)
- .setArguments(bundle)
- .launch();
- return false;
+ if (mSwitchPreference != null) {
+ Intent intent = new Intent();
+ intent.setClassName("com.android.settings",
+ "com.android.settings.Settings$NetworkSelectActivity");
+ intent.putExtra(Settings.EXTRA_SUB_ID, mSubId);
+ mSwitchPreference.setIntent(intent);
+ }
}
+ return false;
}
@VisibleForTesting
Future setAutomaticSelectionMode() {
final long startMillis = SystemClock.elapsedRealtime();
showAutoSelectProgressBar();
- mSwitchPreference.setEnabled(false);
+ if (mSwitchPreference != null) {
+ mSwitchPreference.setIntent(null);
+ mSwitchPreference.setEnabled(false);
+ }
return ThreadUtils.postOnBackgroundThread(() -> {
// set network selection mode in background
mTelephonyManager.setNetworkSelectionModeAutomatic();
diff --git a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
index 4047009..54f5ce1 100644
--- a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
@@ -19,14 +19,12 @@
import static androidx.lifecycle.Lifecycle.Event.ON_START;
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
-import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.os.Bundle;
+import android.content.Intent;
import android.provider.Settings;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
-import android.text.TextUtils;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
@@ -35,10 +33,8 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.core.SubSettingLauncher;
import com.android.settings.network.AllowedNetworkTypesListener;
import com.android.settings.network.telephony.MobileNetworkUtils;
-import com.android.settings.network.telephony.NetworkSelectSettings;
import com.android.settings.network.telephony.TelephonyBasePreferenceController;
/**
@@ -102,6 +98,12 @@
super.updateState(preference);
preference.setEnabled(mTelephonyManager.getNetworkSelectionMode()
!= TelephonyManager.NETWORK_SELECTION_MODE_AUTO);
+
+ Intent intent = new Intent();
+ intent.setClassName("com.android.settings",
+ "com.android.settings.Settings$NetworkSelectActivity");
+ intent.putExtra(Settings.EXTRA_SUB_ID, mSubId);
+ preference.setIntent(intent);
}
@Override
@@ -114,23 +116,6 @@
}
}
- @Override
- public boolean handlePreferenceTreeClick(Preference preference) {
- if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
- final Bundle bundle = new Bundle();
- bundle.putInt(Settings.EXTRA_SUB_ID, mSubId);
- new SubSettingLauncher(mContext)
- .setDestination(NetworkSelectSettings.class.getName())
- .setSourceMetricsCategory(SettingsEnums.MOBILE_NETWORK_SELECT)
- .setTitleRes(R.string.choose_network_title)
- .setArguments(bundle)
- .launch();
- return true;
- }
-
- return false;
- }
-
public OpenNetworkSelectPagePreferenceController init(Lifecycle lifecycle, int subId) {
mSubId = subId;
mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 408ffbe..0c063db 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -1503,11 +1503,15 @@
}
// Shows display name of each active subscription.
- final String[] displayNames = SubscriptionUtil.getUniqueSubscriptionDisplayNames(
- mContext).values().stream().toArray(String[]::new);
- mEapSimSpinner.setAdapter(getSpinnerAdapter(displayNames));
+ final ArrayList<CharSequence> displayNames = new ArrayList<>();
+ for (SubscriptionInfo activeSubInfo : mActiveSubscriptionInfos) {
+ displayNames.add(
+ SubscriptionUtil.getUniqueSubscriptionDisplayName(activeSubInfo, mContext));
+ }
+ mEapSimSpinner.setAdapter(
+ getSpinnerAdapter(displayNames.toArray(new String[displayNames.size()])));
mEapSimSpinner.setSelection(0 /* position */);
- if (displayNames.length == 1) {
+ if (displayNames.size() == 1) {
mEapSimSpinner.setEnabled(false);
}
}
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 011c970..127c882 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -1482,11 +1482,15 @@
}
// Shows display name of each active subscription.
- final String[] displayNames = SubscriptionUtil.getUniqueSubscriptionDisplayNames(
- mContext).values().stream().toArray(String[]::new);
- mEapSimSpinner.setAdapter(getSpinnerAdapter(displayNames));
+ final ArrayList<CharSequence> displayNames = new ArrayList<>();
+ for (SubscriptionInfo activeSubInfo : mActiveSubscriptionInfos) {
+ displayNames.add(
+ SubscriptionUtil.getUniqueSubscriptionDisplayName(activeSubInfo, mContext));
+ }
+ mEapSimSpinner.setAdapter(
+ getSpinnerAdapter(displayNames.toArray(new String[displayNames.size()])));
mEapSimSpinner.setSelection(0 /* position */);
- if (displayNames.length == 1) {
+ if (displayNames.size() == 1) {
mEapSimSpinner.setEnabled(false);
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
index eef6988..9e563f2 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
@@ -21,11 +21,7 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -36,9 +32,7 @@
import androidx.preference.Preference;
import com.android.settings.R;
-import com.android.settings.testutils.FakeFeatureFactory;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -50,23 +44,13 @@
@RunWith(RobolectricTestRunner.class)
public class TopLevelBatteryPreferenceControllerTest {
private Context mContext;
- private FakeFeatureFactory mFeatureFactory;
private TopLevelBatteryPreferenceController mController;
- private BatterySettingsFeatureProvider mBatterySettingsFeatureProvider;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFeatureFactory = FakeFeatureFactory.setupForTest();
mContext = spy(Robolectric.setupActivity(Activity.class));
mController = new TopLevelBatteryPreferenceController(mContext, "test_key");
- mBatterySettingsFeatureProvider =
- mFeatureFactory.batterySettingsFeatureProvider;
- }
-
- @After
- public void cleanUp() {
- TopLevelBatteryPreferenceController.sReplacingActivityMap.clear();
}
@Test
@@ -81,54 +65,6 @@
}
@Test
- public void handlePreferenceTreeClick_noFragment_noCustomActivityCalled() {
- Preference preference = new Preference(mContext);
-
- assertThat(mController.handlePreferenceTreeClick(preference)).isFalse();
- }
-
- @Test
- public void handlePreferenceTreeClick_sameActivityReturned_noCustomActivityCalled() {
- String fragmentPath = "my.fragment.ClassName";
- Preference preference = mock(Preference.class);
- when(preference.getFragment()).thenReturn(fragmentPath);
- ComponentName pathName = mController.convertClassPathToComponentName(fragmentPath);
- when(mBatterySettingsFeatureProvider.getReplacingActivity(any())).thenReturn(pathName);
-
- assertThat(mController.handlePreferenceTreeClick(preference)).isFalse();
- }
-
- @Test
- public void handlePreferenceTreeClick_newActivityReturned_newActivityRedirected() {
- String fragmentPath = "my.fragment.ClassName";
- Preference preference = mock(Preference.class);
- when(preference.getFragment()).thenReturn(fragmentPath);
- String newFragmentPath = "my.fragment.NewClassName";
- ComponentName newPathName = mController.convertClassPathToComponentName(newFragmentPath);
- when(mBatterySettingsFeatureProvider.getReplacingActivity(any())).thenReturn(
- newPathName);
- doNothing().when(mContext).startActivity(any());
-
- assertThat(mController.handlePreferenceTreeClick(preference)).isTrue();
- }
-
- @Test
- public void handlePreferenceTreeClick_calledMultipleTimes_fetchedFromCache() {
- String fragmentPath = "my.fragment.ClassName";
- Preference preference = mock(Preference.class);
- when(preference.getFragment()).thenReturn(fragmentPath);
- String newFragmentPath = "my.fragment.NewClassName";
- ComponentName newPathName = mController.convertClassPathToComponentName(newFragmentPath);
- when(mBatterySettingsFeatureProvider.getReplacingActivity(any())).thenReturn(
- newPathName);
- doNothing().when(mContext).startActivity(any());
-
- assertThat(mController.handlePreferenceTreeClick(preference)).isTrue();
- assertThat(mController.handlePreferenceTreeClick(preference)).isTrue();
- verify(mBatterySettingsFeatureProvider, times(1)).getReplacingActivity(any());
- }
-
- @Test
public void convertClassPathToComponentName_nullInput_returnsNull() {
assertThat(mController.convertClassPathToComponentName(null)).isNull();
}