Merge sc-v2-dev-plus-aosp-without-vendor@8084891

Bug: 214455710
Merged-In: I962c318f41adcf180b885f2052ce0ec4952edfb6
Change-Id: I77764eaf895ac3c13c7440adb5b3f597a516d690
This commit is contained in:
Xin Li
2022-02-11 07:29:32 +00:00
704 changed files with 54456 additions and 61773 deletions

View File

@@ -22,6 +22,7 @@ import android.provider.Settings;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.widget.SettingsMainSwitchPreferenceController;
/**
@@ -62,4 +63,9 @@ public class AdaptiveConnectivityTogglePreferenceController extends
mWifiManager.setWifiScoringEnabled(isChecked);
return true;
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_network;
}
}

View File

@@ -120,6 +120,11 @@ public class AirplaneModePreferenceController extends TogglePreferenceController
return isAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_network;
}
@Override
public void onStart() {
if (isAvailable()) {

View File

@@ -22,6 +22,7 @@ import androidx.lifecycle.Lifecycle;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.wifi.WifiPickerTrackerHelper;
@@ -38,7 +39,6 @@ public class CarrierWifiTogglePreferenceController extends TogglePreferenceContr
protected static final String CARRIER_WIFI_NETWORK_PREF_KEY = "carrier_wifi_network";
protected final Context mContext;
protected boolean mIsProviderModelEnabled;
protected int mSubId;
protected WifiPickerTrackerHelper mWifiPickerTrackerHelper;
protected boolean mIsCarrierProvisionWifiEnabled;
@@ -48,7 +48,6 @@ public class CarrierWifiTogglePreferenceController extends TogglePreferenceContr
String preferenceKey) {
super(context, preferenceKey);
mContext = context;
mIsProviderModelEnabled = Utils.isProviderModelEnabled(context);
}
/** Initialize related properties */
@@ -61,9 +60,6 @@ public class CarrierWifiTogglePreferenceController extends TogglePreferenceContr
@Override
public int getAvailabilityStatus() {
if (!mIsProviderModelEnabled) {
return CONDITIONALLY_UNAVAILABLE;
}
return mIsCarrierProvisionWifiEnabled ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@@ -88,6 +84,11 @@ public class CarrierWifiTogglePreferenceController extends TogglePreferenceContr
updateCarrierNetworkPreference();
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_network;
}
@Override
public void onWifiStateChanged() {
updateCarrierNetworkPreference();

View File

@@ -45,7 +45,12 @@ import java.util.Map;
* This populates the entries on a page which lists all available mobile subscriptions. Each entry
* has the name of the subscription with some subtext giving additional detail, and clicking on the
* entry brings you to a details page for that network.
*
* @deprecated This class will be removed in Android U, use
* {@link NetworkProviderSimsCategoryController} and
* {@link NetworkProviderDownloadedSimsCategoryController} instead.
*/
@Deprecated
public class MobileNetworkListController extends AbstractPreferenceController implements
LifecycleObserver, SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
private static final String TAG = "MobileNetworkListCtlr";

View File

@@ -44,9 +44,7 @@ public class MobileNetworkListFragment extends DashboardFragment {
@Override
protected int getPreferenceScreenResId() {
return Utils.isProviderModelEnabled(getContext())
? R.xml.network_provider_sims_list
: R.xml.mobile_network_list;
return R.xml.network_provider_sims_list;
}
@Override
@@ -63,18 +61,14 @@ public class MobileNetworkListFragment extends DashboardFragment {
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
if (Utils.isProviderModelEnabled(getContext())) {
NetworkProviderSimsCategoryController simCategoryPrefCtrl =
new NetworkProviderSimsCategoryController(context, KEY_PREFERENCE_CATEGORY_SIM,
getSettingsLifecycle());
controllers.add(simCategoryPrefCtrl);
NetworkProviderDownloadedSimsCategoryController downloadedSimsCategoryCtrl =
new NetworkProviderDownloadedSimsCategoryController(context,
KEY_PREFERENCE_CATEGORY_DOWNLOADED_SIM, getSettingsLifecycle());
controllers.add(downloadedSimsCategoryCtrl);
} else {
controllers.add(new MobileNetworkListController(getContext(), getLifecycle()));
}
NetworkProviderSimsCategoryController simCategoryPrefCtrl =
new NetworkProviderSimsCategoryController(context, KEY_PREFERENCE_CATEGORY_SIM,
getSettingsLifecycle());
controllers.add(simCategoryPrefCtrl);
NetworkProviderDownloadedSimsCategoryController downloadedSimsCategoryCtrl =
new NetworkProviderDownloadedSimsCategoryController(context,
KEY_PREFERENCE_CATEGORY_DOWNLOADED_SIM, getSettingsLifecycle());
controllers.add(downloadedSimsCategoryCtrl);
return controllers;
}
@@ -87,9 +81,7 @@ public class MobileNetworkListFragment extends DashboardFragment {
boolean enabled) {
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = Utils.isProviderModelEnabled(context)
? R.xml.network_provider_sims_list
: R.xml.mobile_network_list;
sir.xmlResId = R.xml.network_provider_sims_list;
result.add(sir);
return result;
}

View File

@@ -35,7 +35,6 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.network.helper.SelectableSubscriptions;
import com.android.settings.network.helper.SubscriptionAnnotation;
import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.overlay.FeatureFactory;
@@ -127,22 +126,13 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
}
return mContext.getString(R.string.mobile_network_tap_to_activate, displayName);
} else {
if (com.android.settings.Utils.isProviderModelEnabled(mContext)) {
return getSummaryForProviderModel(subs);
}
final int count = subs.size();
return mContext.getResources().getQuantityString(R.plurals.mobile_network_summary_count,
count, count);
return subs.stream()
.mapToInt(SubscriptionAnnotation::getSubscriptionId)
.mapToObj(subId -> mStatusCache.getDisplayName(subId))
.collect(Collectors.joining(", "));
}
}
private CharSequence getSummaryForProviderModel(List<SubscriptionAnnotation> subs) {
return subs.stream()
.mapToInt(SubscriptionAnnotation::getSubscriptionId)
.mapToObj(subId -> mStatusCache.getDisplayName(subId))
.collect(Collectors.joining(", "));
}
private void logPreferenceClick(Preference preference) {
mMetricsFeatureProvider.logClickedPreference(preference,
preference.getExtras().getInt(DashboardFragment.CATEGORY));
@@ -202,6 +192,9 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|| mStatusCache.isPhysicalSimDisableSupport()) {
final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
// MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
MobileNetworkTwoPaneUtils.registerTwoPaneForMobileNetwork(mContext, intent,
null);
mContext.startActivity(intent);
return true;
}

View File

@@ -0,0 +1,29 @@
package com.android.settings.network;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
public class MobileNetworkTwoPaneUtils {
private static final String TAG = "MobileNetworkTwoPaneUtils";
/**
* TODO: b/206061070, the problem of multi-instance should be fixed in Android T to apply the
* Settings' architecture and 2 panes mode instead of registering the rule.
*
* The launchMode of MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
*/
public static void registerTwoPaneForMobileNetwork(Context context, Intent intent,
@Nullable String secondaryIntentAction) {
Log.d(TAG, "registerTwoPaneForMobileNetwork");
ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
context,
intent.getComponent(),
secondaryIntentAction /* secondaryIntentAction */,
false /* clearTop */);
}
}

View File

@@ -32,9 +32,9 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
* are two or more active mobile subscriptions. It shows an overview of available network
* connections with an entry for wifi (if connected) and an entry for each subscription.
*
* TODO(tomhsu) when provider model is completed, this class will be replaced
* by {@link NetworkMobileProviderController}
* @deprecated This class will be removed in Android U, there is no networks header anymore.
*/
@Deprecated
public class MultiNetworkHeaderController extends BasePreferenceController implements
WifiConnectionPreferenceController.UpdateListener,
SubscriptionsPreferenceController.UpdateListener {

View File

@@ -60,20 +60,13 @@ public class NetworkDashboardFragment extends DashboardFragment implements
@Override
protected int getPreferenceScreenResId() {
if (Utils.isProviderModelEnabled(getContext())) {
return R.xml.network_provider_internet;
} else {
return R.xml.network_and_internet;
}
return R.xml.network_provider_internet;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (!Utils.isProviderModelEnabled(context)) {
use(MultiNetworkHeaderController.class).init(getSettingsLifecycle());
}
use(AirplaneModePreferenceController.class).setFragment(this);
getSettingsLifecycle().addObserver(use(AllInOneTetherPreferenceController.class));
}
@@ -100,16 +93,8 @@ public class NetworkDashboardFragment extends DashboardFragment implements
MobilePlanPreferenceHost mobilePlanHost) {
final MobilePlanPreferenceController mobilePlanPreferenceController =
new MobilePlanPreferenceController(context, mobilePlanHost);
final WifiPrimarySwitchPreferenceController wifiPreferenceController =
Utils.isProviderModelEnabled(context)
? null
: new WifiPrimarySwitchPreferenceController(
context,
metricsFeatureProvider);
final InternetPreferenceController internetPreferenceController =
Utils.isProviderModelEnabled(context)
? new InternetPreferenceController(context, lifecycle)
: null;
new InternetPreferenceController(context, lifecycle);
final VpnPreferenceController vpnPreferenceController =
new VpnPreferenceController(context);
@@ -118,9 +103,6 @@ public class NetworkDashboardFragment extends DashboardFragment implements
if (lifecycle != null) {
lifecycle.addObserver(mobilePlanPreferenceController);
if (wifiPreferenceController != null) {
lifecycle.addObserver(wifiPreferenceController);
}
lifecycle.addObserver(vpnPreferenceController);
lifecycle.addObserver(privateDnsPreferenceController);
}
@@ -132,16 +114,11 @@ public class NetworkDashboardFragment extends DashboardFragment implements
controllers.add(vpnPreferenceController);
controllers.add(new ProxyPreferenceController(context));
controllers.add(mobilePlanPreferenceController);
if (wifiPreferenceController != null) {
controllers.add(wifiPreferenceController);
}
if (internetPreferenceController != null) {
controllers.add(internetPreferenceController);
}
controllers.add(privateDnsPreferenceController);
if (Utils.isProviderModelEnabled(context)) {
controllers.add(new NetworkProviderCallsSmsController(context, lifecycle));
}
controllers.add(new NetworkProviderCallsSmsController(context, lifecycle));
return controllers;
}
@@ -176,20 +153,7 @@ public class NetworkDashboardFragment extends DashboardFragment implements
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.network_and_internet) {
@Override
// TODO(b/167474581): Should remove this method when Provider Model finished.
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
boolean enabled) {
if (Utils.isProviderModelEnabled(context)) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.network_provider_internet;
return Arrays.asList(sir);
}
return super.getXmlResourcesToIndex(context, enabled);
}
new BaseSearchIndexProvider(R.xml.network_provider_internet) {
@Override
public List<AbstractPreferenceController> createPreferenceControllers(Context
context) {

View File

@@ -100,8 +100,7 @@ public class NetworkProviderCallsSmsFragment extends DashboardFragment {
@Override
protected boolean isPageSearchEnabled(Context context) {
return Utils.isProviderModelEnabled(context) &&
context.getSystemService(UserManager.class).isAdminUser();
return context.getSystemService(UserManager.class).isAdminUser();
}
};
}

View File

@@ -130,6 +130,8 @@ public class NetworkProviderDownloadedSimListController extends
pref.setOnPreferenceClickListener(clickedPref -> {
final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
// MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
MobileNetworkTwoPaneUtils.registerTwoPaneForMobileNetwork(mContext, intent, null);
mContext.startActivity(intent);
return true;
});

View File

@@ -19,6 +19,8 @@ package com.android.settings.network;
import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
import static com.android.settings.Settings.WifiSettingsActivity;
import android.app.Activity;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
@@ -131,7 +133,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
@VisibleForTesting
static final String PREF_KEY_FIRST_ACCESS_POINTS = "first_access_points";
private static final String PREF_KEY_ACCESS_POINTS = "access_points";
private static final String PREF_KEY_CONFIGURE_WIFI_SETTINGS = "configure_wifi_settings";
private static final String PREF_KEY_CONFIGURE_NETWORK_SETTINGS = "configure_network_settings";
private static final String PREF_KEY_SAVED_NETWORKS = "saved_networks";
@VisibleForTesting
static final String PREF_KEY_DATA_USAGE = "non_carrier_data_usage";
@@ -270,8 +272,6 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
if (mWifiManager != null) {
setLoading(true, false);
mIsViewLoading = true;
getView().postDelayed(mRemoveLoadingRunnable,
mWifiManager.isWifiEnabled() ? 1000 : 100);
}
}
@@ -297,7 +297,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
mConnectedWifiEntryPreferenceCategory = findPreference(PREF_KEY_CONNECTED_ACCESS_POINTS);
mFirstWifiEntryPreferenceCategory = findPreference(PREF_KEY_FIRST_ACCESS_POINTS);
mWifiEntryPreferenceCategory = findPreference(PREF_KEY_ACCESS_POINTS);
mConfigureWifiSettingsPreference = findPreference(PREF_KEY_CONFIGURE_WIFI_SETTINGS);
mConfigureWifiSettingsPreference = findPreference(PREF_KEY_CONFIGURE_NETWORK_SETTINGS);
mSavedNetworksPreference = findPreference(PREF_KEY_SAVED_NETWORKS);
mAddWifiNetworkPreference = new AddWifiNetworkPreference(getPrefContext());
mDataUsagePreference = findPreference(PREF_KEY_DATA_USAGE);
@@ -417,6 +417,10 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
@Override
public void onStart() {
super.onStart();
if (mIsViewLoading) {
final long delayMillis = mWifiManager.isWifiEnabled() ? 1000 : 100;
getView().postDelayed(mRemoveLoadingRunnable, delayMillis);
}
if (mIsRestricted) {
restrictUi();
return;
@@ -464,7 +468,9 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
@Override
public void onDestroy() {
mAirplaneModeEnabler.close();
if (mAirplaneModeEnabler != null) {
mAirplaneModeEnabler.close();
}
super.onDestroy();
}
@@ -1130,7 +1136,8 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
@Override
public void onScan(WifiDialog2 dialog, String ssid) {
// Launch QR code scanner to join a network.
startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid),
startActivityForResult(
WifiDppUtils.getEnrolleeQrCodeScannerIntent(dialog.getContext(), ssid),
REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
}
@@ -1168,6 +1175,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.network_provider_settings) {
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);

View File

@@ -128,6 +128,9 @@ public class NetworkProviderSimListController extends AbstractPreferenceControll
} else {
final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
// MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
MobileNetworkTwoPaneUtils.registerTwoPaneForMobileNetwork(mContext, intent,
null);
mContext.startActivity(intent);
}
return true;

View File

@@ -290,7 +290,7 @@ public class ProviderModelSlice extends WifiSlice {
final String screenTitle = mContext.getText(R.string.provider_internet_settings).toString();
return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
NetworkProviderSettings.class.getName(), "" /* key */, screenTitle,
SettingsEnums.SLICE)
SettingsEnums.SLICE, this)
.setClassName(mContext.getPackageName(), SubSettings.class.getName())
.setData(getUri());
}

View File

@@ -74,15 +74,8 @@ import java.util.Map;
import java.util.Set;
/**
* If the provider model is not enabled, this controller manages a set of Preferences it places into
* a PreferenceGroup owned by some parent
* controller class - one for each available subscription. This controller is only considered
* available if there are 2 or more subscriptions.
*
* If the provider model is enabled, this controller manages preference with data subscription
* information and make its state display on preference.
* TODO this class will clean up the multiple subscriptions functionality after the provider
* model is released.
* This controller manages preference with data subscription information and make its state
* display on preference.
*/
public class SubscriptionsPreferenceController extends AbstractPreferenceController implements
LifecycleObserver, SubscriptionsChangeListener.SubscriptionsChangeListenerClient,
@@ -101,6 +94,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
private SignalStrengthListener mSignalStrengthListener;
private TelephonyDisplayInfoListener mTelephonyDisplayInfoListener;
private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
private final WifiManager mWifiManager;
@VisibleForTesting
final BroadcastReceiver mConnectionChangeReceiver = new BroadcastReceiver() {
@@ -157,6 +151,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
mStartOrder = startOrder;
mTelephonyManager = context.getSystemService(TelephonyManager.class);
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
mWifiManager = context.getSystemService(WifiManager.class);
mSubscriptionPreferences = new ArrayMap<>();
mSubscriptionsListener = new SubscriptionsChangeListener(context, this);
mDataEnabledListener = new MobileDataEnabledListener(context, this);
@@ -228,14 +223,6 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
return;
}
if (mSubsPrefCtrlInjector.isProviderModelEnabled(mContext)) {
updateForProvider();
} else {
updateForBase();
}
}
private void updateForProvider() {
SubscriptionInfo subInfo = mSubscriptionManager.getDefaultDataSubscriptionInfo();
if (subInfo == null) {
mPreferenceGroup.removeAll();
@@ -286,9 +273,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
final boolean isDataInService = (regInfo == null)
? false
: regInfo.isRegistered();
final boolean isCarrierNetworkActive =
(mWifiPickerTrackerHelper != null)
&& mWifiPickerTrackerHelper.isCarrierNetworkActive();
final boolean isCarrierNetworkActive = isCarrierNetworkActive();
String result = mSubsPrefCtrlInjector.getNetworkType(
mContext, mConfig, mTelephonyDisplayInfo, subId, isCarrierNetworkActive);
if (mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext) || isCarrierNetworkActive) {
@@ -306,20 +291,15 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
final SignalStrength strength = tmForSubId.getSignalStrength();
int level = (strength == null) ? 0 : strength.getLevel();
int numLevels = SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
if (shouldInflateSignalStrength(subId)) {
level += 1;
boolean isCarrierNetworkActive = isCarrierNetworkActive();
if (shouldInflateSignalStrength(subId) || isCarrierNetworkActive) {
level = isCarrierNetworkActive
? SignalStrength.NUM_SIGNAL_STRENGTH_BINS
: (level + 1);
numLevels += 1;
}
Drawable icon = mSubsPrefCtrlInjector.getIcon(mContext, level, numLevels,
!mTelephonyManager.isDataEnabled());
final boolean isActiveCellularNetwork =
mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext);
if (isActiveCellularNetwork || (mWifiPickerTrackerHelper != null)
&& mWifiPickerTrackerHelper.isCarrierNetworkActive()) {
icon.setTint(Utils.getColorAccentDefaultColor(mContext));
return icon;
}
Drawable icon = mContext.getDrawable(R.drawable.ic_signal_strength_zero_bar_no_internet);
final ServiceState serviceState = tmForSubId.getServiceState();
final NetworkRegistrationInfo regInfo = (serviceState == null)
@@ -334,11 +314,17 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
final boolean isVoiceInService = (serviceState == null)
? false
: (serviceState.getState() == ServiceState.STATE_IN_SERVICE);
if (isDataInService || isVoiceInService) {
return icon;
if (isDataInService || isVoiceInService || isCarrierNetworkActive) {
icon = mSubsPrefCtrlInjector.getIcon(mContext, level, numLevels,
!tmForSubId.isDataEnabled());
}
final boolean isActiveCellularNetwork =
mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext);
if (isActiveCellularNetwork || isCarrierNetworkActive) {
icon.setTint(Utils.getColorAccentDefaultColor(mContext));
}
icon = mContext.getDrawable(R.drawable.ic_signal_strength_zero_bar_no_internet);
return icon;
}
@@ -349,53 +335,11 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
mSubsGearPref.setSummary("");
}
private void updateForBase() {
final Map<Integer, Preference> existingPrefs = mSubscriptionPreferences;
mSubscriptionPreferences = new ArrayMap<>();
int order = mStartOrder;
final Set<Integer> activeSubIds = new ArraySet<>();
final int dataDefaultSubId = mSubsPrefCtrlInjector.getDefaultDataSubscriptionId();
for (SubscriptionInfo info :
SubscriptionUtil.getActiveSubscriptions(mSubscriptionManager)) {
final int subId = info.getSubscriptionId();
// Avoid from showing subscription(SIM)s which has been marked as hidden
// For example, only one subscription will be shown when there're multiple
// subscriptions with same group UUID.
if (!mSubsPrefCtrlInjector.canSubscriptionBeDisplayed(mContext, subId)) {
continue;
}
activeSubIds.add(subId);
Preference pref = existingPrefs.remove(subId);
if (pref == null) {
pref = new Preference(mPreferenceGroup.getContext());
mPreferenceGroup.addPreference(pref);
}
pref.setTitle(SubscriptionUtil.getUniqueSubscriptionDisplayName(info, mContext));
final boolean isDefaultForData = (subId == dataDefaultSubId);
pref.setSummary(getSummary(subId, isDefaultForData));
setIcon(pref, subId, isDefaultForData);
pref.setOrder(order++);
pref.setOnPreferenceClickListener(clickedPref -> {
startMobileNetworkActivity(mContext, subId);
return true;
});
mSubscriptionPreferences.put(subId, pref);
}
mSignalStrengthListener.updateSubscriptionIds(activeSubIds);
// Remove any old preferences that no longer map to a subscription.
for (Preference pref : existingPrefs.values()) {
mPreferenceGroup.removePreference(pref);
}
mUpdateListener.onChildrenUpdated();
}
private static void startMobileNetworkActivity(Context context, int subId) {
final Intent intent = new Intent(context, MobileNetworkActivity.class);
intent.putExtra(Settings.EXTRA_SUB_ID, subId);
// MobileNetworkActivity is singleTask, set SplitPairRule to show in 2-pane.
MobileNetworkTwoPaneUtils.registerTwoPaneForMobileNetwork(context, intent, null);
context.startActivity(intent);
}
@@ -470,12 +414,12 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
}
/**
* @return true if there are at least 2 available subscriptions,
* or if there is at least 1 available subscription for provider model.
* @return true if there is at least 1 available subscription.
*/
@Override
public boolean isAvailable() {
if (mSubscriptionsListener.isAirplaneModeOn()) {
if (mSubscriptionsListener.isAirplaneModeOn()
&& (!mWifiManager.isWifiEnabled() || !isCarrierNetworkActive())) {
return false;
}
List<SubscriptionInfo> subInfoList =
@@ -483,6 +427,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
if (subInfoList == null) {
return false;
}
return subInfoList.stream()
// Avoid from showing subscription(SIM)s which has been marked as hidden
// For example, only one subscription will be shown when there're multiple
@@ -490,7 +435,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
.filter(subInfo ->
mSubsPrefCtrlInjector.canSubscriptionBeDisplayed(mContext,
subInfo.getSubscriptionId()))
.count() >= (mSubsPrefCtrlInjector.isProviderModelEnabled(mContext) ? 1 : 2);
.count() >= 1;
}
@Override
@@ -535,12 +480,6 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
update();
}
@VisibleForTesting
boolean canSubscriptionBeDisplayed(Context context, int subId) {
return (SubscriptionUtil.getAvailableSubscription(context,
ProxySubscriptionManager.getInstance(context), subId) != null);
}
public void setWifiPickerTrackerHelper(WifiPickerTrackerHelper helper) {
mWifiPickerTrackerHelper = helper;
}
@@ -559,6 +498,11 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
return new SubsPrefCtrlInjector();
}
boolean isCarrierNetworkActive() {
return mWifiPickerTrackerHelper != null
&& mWifiPickerTrackerHelper.isCarrierNetworkActive();
}
/**
* To inject necessary data from each static api.
*/
@@ -600,13 +544,6 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
return MobileNetworkUtils.activeNetworkIsCellular(context);
}
/**
* Confirms the flag of Provider Model switch is turned on or not.
*/
public boolean isProviderModelEnabled(Context context) {
return Utils.isProviderModelEnabled(context);
}
/**
* Gets config for carrier customization.
*/

View File

@@ -25,6 +25,7 @@ import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.datausage.DataSaverBackend;
@@ -117,6 +118,11 @@ public abstract class TetherBasePreferenceController extends TogglePreferenceCon
return AVAILABLE;
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_network;
}
@Override
public void onTetherStateUpdated(@TetherEnabler.TetheringState int state) {
mTetheringState = state;

View File

@@ -156,7 +156,7 @@ public class VpnPreferenceController extends AbstractPreferenceController
summary = getNameForVpnConfig(vpn, UserHandle.of(uid));
}
// Optionally add warning icon if an insecure VPN is present.
if (Utils.isProviderModelEnabled(mContext) && mPreference instanceof VpnInfoPreference) {
if (mPreference instanceof VpnInfoPreference) {
final int insecureVpnCount = getInsecureVpnCount();
boolean isInsecureVPN = insecureVpnCount > 0;
((VpnInfoPreference) mPreference).setInsecureVpn(isInsecureVPN);

View File

@@ -1256,7 +1256,8 @@ public class ApnEditor extends SettingsPreferenceFragment
if (!readOnlyApnTypes.contains(apnType)
&& !apnType.equals(APN_TYPE_IA)
&& !apnType.equals(APN_TYPE_EMERGENCY)
&& !apnType.equals(APN_TYPE_MCX)) {
&& !apnType.equals(APN_TYPE_MCX)
&& !apnType.equals(APN_TYPE_IMS)) {
if (first) {
first = false;
} else {

View File

@@ -45,10 +45,6 @@ public class CallsDefaultSubscriptionController extends DefaultSubscriptionContr
@Override
public CharSequence getSummary() {
if (Utils.isProviderModelEnabled(mContext)) {
return MobileNetworkUtils.getPreferredStatus(isRtlMode(), mContext, mManager, true);
} else {
return super.getSummary();
}
return MobileNetworkUtils.getPreferredStatus(isRtlMode(), mContext, mManager, true);
}
}

View File

@@ -94,12 +94,7 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere
@Override
public int getAvailabilityStatus(int subId) {
final List<SubscriptionInfo> subs = SubscriptionUtil.getActiveSubscriptions(mManager);
if (subs.size() > 1 || Utils.isProviderModelEnabled(mContext)) {
return AVAILABLE;
} else {
return CONDITIONALLY_UNAVAILABLE;
}
return AVAILABLE;
}
@OnLifecycleEvent(ON_RESUME)
@@ -162,7 +157,7 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere
final ArrayList<CharSequence> displayNames = new ArrayList<>();
final ArrayList<CharSequence> subscriptionIds = new ArrayList<>();
if (Utils.isProviderModelEnabled(mContext) && subs.size() == 1) {
if (subs.size() == 1) {
mPreference.setEnabled(false);
mPreference.setSummary(SubscriptionUtil.getUniqueSubscriptionDisplayName(
subs.get(0), mContext));
@@ -190,6 +185,7 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere
subscriptionIds.add(Integer.toString(SubscriptionManager.INVALID_SUBSCRIPTION_ID));
}
mPreference.setEnabled(true);
mPreference.setEntries(displayNames.toArray(new CharSequence[0]));
mPreference.setEntryValues(subscriptionIds.toArray(new CharSequence[0]));

View File

@@ -145,6 +145,11 @@ public class MobileDataSlice implements CustomSliceable {
return new Intent(mContext, MobileNetworkActivity.class);
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_network;
}
@Override
public Class<? extends SliceBackgroundWorker> getBackgroundWorkerClass() {
return MobileDataWorker.class;

View File

@@ -207,6 +207,7 @@ public class MobileNetworkActivity extends SettingsBaseActivity
protected void runSubscriptionUpdate(Runnable onUpdateRemaining) {
SubscriptionInfo subInfo = getSubscription(mCurSubscriptionId, null);
if (subInfo == null) {
onUpdateRemaining.run();
tryToFinishActivity();
return;
}

View File

@@ -227,6 +227,7 @@ public class NetworkScanHelper {
mExecutor,
mInternalNetworkScanCallback);
if (mNetworkScanRequester == null) {
Log.d(TAG, "mNetworkScanRequester == null");
onError(NetworkScan.ERROR_RADIO_INTERFACE_ERROR);
}
}

View File

@@ -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;
@@ -50,6 +51,7 @@ import com.android.settingslib.utils.ThreadUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -97,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());
@@ -120,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)
@@ -326,12 +331,19 @@ public class NetworkSelectSettings extends DashboardFragment {
CellInfoUtil.getCellIdentityMccMnc(cellInfo.getCellIdentity()));
Class className = cellInfo.getClass();
if (aggregatedList.stream().anyMatch(
Optional<CellInfo> itemInTheList = aggregatedList.stream().filter(
item -> {
String itemPlmn = CellInfoUtil.getNetworkTitle(item.getCellIdentity(),
CellInfoUtil.getCellIdentityMccMnc(item.getCellIdentity()));
return itemPlmn.equals(plmn) && item.getClass().equals(className);
})) {
})
.findFirst();
if (itemInTheList.isPresent()) {
if (cellInfo.isRegistered() && !itemInTheList.get().isRegistered()) {
// Adding the registered cellinfo item into list. If there are two registered
// cellinfo items, then select first one from source list.
aggregatedList.set(aggregatedList.indexOf(itemInTheList.get()), cellInfo);
}
continue;
}
aggregatedList.add(cellInfo);

View File

@@ -46,6 +46,7 @@ public class NrAdvancedCallingPreferenceController extends TelephonyTogglePrefer
Preference mPreference;
private TelephonyManager mTelephonyManager;
private PhoneCallStateTelephonyCallback mTelephonyCallback;
private boolean mIsVonrEnabledFromCarrierConfig = false;
private boolean mIsVonrVisibleFromCarrierConfig = false;
private boolean mIsNrEnableFromCarrierConfig = false;
private boolean mHas5gCapability = false;
@@ -83,6 +84,9 @@ public class NrAdvancedCallingPreferenceController extends TelephonyTogglePrefer
if (carrierConfig == null) {
return this;
}
mIsVonrEnabledFromCarrierConfig = carrierConfig.getBoolean(
CarrierConfigManager.KEY_VONR_ENABLED_BOOL);
mIsVonrVisibleFromCarrierConfig = carrierConfig.getBoolean(
CarrierConfigManager.KEY_VONR_SETTING_VISIBILITY_BOOL);
@@ -92,6 +96,7 @@ public class NrAdvancedCallingPreferenceController extends TelephonyTogglePrefer
Log.d(TAG, "mHas5gCapability: " + mHas5gCapability
+ ",mIsNrEnabledFromCarrierConfig: " + mIsNrEnableFromCarrierConfig
+ ",mIsVonrEnabledFromCarrierConfig: " + mIsVonrEnabledFromCarrierConfig
+ ",mIsVonrVisibleFromCarrierConfig: " + mIsVonrVisibleFromCarrierConfig);
return this;
}
@@ -100,7 +105,10 @@ public class NrAdvancedCallingPreferenceController extends TelephonyTogglePrefer
public int getAvailabilityStatus(int subId) {
init(subId);
if (mHas5gCapability && mIsNrEnableFromCarrierConfig && mIsVonrVisibleFromCarrierConfig) {
if (mHas5gCapability
&& mIsNrEnableFromCarrierConfig
&& mIsVonrEnabledFromCarrierConfig
&& mIsVonrVisibleFromCarrierConfig) {
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;

View File

@@ -61,10 +61,6 @@ public class SmsDefaultSubscriptionController extends DefaultSubscriptionControl
@Override
public CharSequence getSummary() {
if (Utils.isProviderModelEnabled(mContext)) {
return MobileNetworkUtils.getPreferredStatus(isRtlMode(), mContext, mManager, false);
} else {
return super.getSummary();
}
return MobileNetworkUtils.getPreferredStatus(isRtlMode(), mContext, mManager, false);
}
}

View File

@@ -65,6 +65,12 @@ public abstract class TelephonyTogglePreferenceController extends TogglePreferen
return false;
}
@Override
public int getSliceHighlightMenuRes() {
// not needed since it's not sliceable
return NO_RES;
}
/**
* Get carrier config based on specific subscription id.
*

View File

@@ -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();

View File

@@ -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)