Snap for 7985315 from c51a58d819 to sc-v2-release
Change-Id: Ibd4c7dec32a87e8f4f012cb08875ab133f22ddb5
This commit is contained in:
@@ -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" />
|
||||
@@ -370,6 +374,16 @@
|
||||
android:value="true"/>
|
||||
</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"
|
||||
|
||||
@@ -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] -->
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ public class Settings extends SettingsActivity {
|
||||
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 */ }
|
||||
|
||||
@@ -377,8 +377,9 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
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
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.android.settings.search.actionbar.SearchMenuController;
|
||||
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 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
||||
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();
|
||||
|
||||
@@ -53,6 +53,7 @@ import java.io.IOException;
|
||||
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 @@ public class RemoveAccountPreferenceController extends AbstractPreferenceControl
|
||||
| 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 @@ public class RemoveAccountPreferenceController extends AbstractPreferenceControl
|
||||
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();
|
||||
|
||||
@@ -120,6 +120,7 @@ import com.android.settings.network.NetworkDashboardFragment;
|
||||
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;
|
||||
@@ -320,6 +321,7 @@ public class SettingsGateway {
|
||||
InteractAcrossProfilesDetails.class.getName(),
|
||||
MediaControlsSettings.class.getName(),
|
||||
NetworkProviderSettings.class.getName(),
|
||||
NetworkSelectSettings.class.getName(),
|
||||
AlarmsAndRemindersDetails.class.getName(),
|
||||
MediaManagementAppsDetails.class.getName()
|
||||
};
|
||||
@@ -343,6 +345,7 @@ public class SettingsGateway {
|
||||
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(),
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.settings.fuelgauge;
|
||||
|
||||
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.OnStart;
|
||||
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 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
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 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
}, true /* shortString */);
|
||||
});
|
||||
|
||||
mBatterySettingsFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getBatterySettingsFeatureProvider(context);
|
||||
mBatteryStatusFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getBatteryStatusFeatureProvider(context);
|
||||
}
|
||||
@@ -81,37 +72,6 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
@@ -125,11 +125,8 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
||||
}
|
||||
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());
|
||||
|
||||
@@ -54,6 +54,7 @@ public class TopLevelSettings extends DashboardFragment implements
|
||||
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 @@ public class TopLevelSettings extends DashboardFragment implements
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
: (serviceState.getState() == ServiceState.STATE_IN_SERVICE);
|
||||
if (isDataInService || isVoiceInService || isCarrierNetworkActive) {
|
||||
icon = mSubsPrefCtrlInjector.getIcon(mContext, level, numLevels,
|
||||
!mTelephonyManager.isDataEnabled());
|
||||
!tmForSubId.isDataEnabled());
|
||||
}
|
||||
|
||||
final boolean isActiveCellularNetwork =
|
||||
|
||||
@@ -227,6 +227,7 @@ public class NetworkScanHelper {
|
||||
mExecutor,
|
||||
mInternalNetworkScanCallback);
|
||||
if (mNetworkScanRequester == null) {
|
||||
Log.d(TAG, "mNetworkScanRequester == null");
|
||||
onError(NetworkScan.ERROR_RADIO_INTERFACE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.settings.network.telephony;
|
||||
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 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
|
||||
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 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
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)
|
||||
|
||||
@@ -20,9 +20,8 @@ import static androidx.lifecycle.Lifecycle.Event.ON_START;
|
||||
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.PreferenceScreen;
|
||||
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 class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
|
||||
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();
|
||||
|
||||
@@ -19,14 +19,12 @@ package com.android.settings.network.telephony.gsm;
|
||||
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.Preference;
|
||||
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 @@ public class OpenNetworkSelectPagePreferenceController extends
|
||||
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 @@ public class OpenNetworkSelectPagePreferenceController extends
|
||||
}
|
||||
}
|
||||
|
||||
@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)
|
||||
|
||||
@@ -21,11 +21,7 @@ import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_
|
||||
|
||||
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 android.content.Context;
|
||||
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 @@ import org.robolectric.annotation.Config;
|
||||
@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
|
||||
@@ -80,54 +64,6 @@ public class TopLevelBatteryPreferenceControllerTest {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
Reference in New Issue
Block a user