Merge changes I7d29b58c,I2f1d22fb,I55e0fa2c into sc-v2-dev
* changes: [Provider Model] Internal cleanup - remove Provider Model flag and deprecated legacy UI part.3 [Provider Model] Internal cleanup - remove Provider Model flag and deprecated legacy UI part.2 [Provider Model] Internal cleanup - remove Provider Model flag and deprecated legacy UI
This commit is contained in:
@@ -39,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;
|
||||
@@ -49,7 +48,6 @@ public class CarrierWifiTogglePreferenceController extends TogglePreferenceContr
|
||||
String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mContext = context;
|
||||
mIsProviderModelEnabled = Utils.isProviderModelEnabled(context);
|
||||
}
|
||||
|
||||
/** Initialize related properties */
|
||||
@@ -62,9 +60,6 @@ public class CarrierWifiTogglePreferenceController extends TogglePreferenceContr
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!mIsProviderModelEnabled) {
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
return mIsCarrierProvisionWifiEnabled ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
|
@@ -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";
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -126,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));
|
||||
|
@@ -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 {
|
||||
|
@@ -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,9 +114,6 @@ 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);
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -60,7 +60,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.android.settings.AirplaneModeEnabler;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.RestrictedSettingsFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.datausage.DataUsagePreference;
|
||||
@@ -279,17 +278,6 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
if (!Utils.isProviderModelEnabled(getContext())) {
|
||||
final Intent intent = new Intent(getContext(), WifiSettingsActivity.class);
|
||||
final Bundle extras = getActivity().getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
intent.putExtras(extras);
|
||||
}
|
||||
getContext().startActivity(intent);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
mAirplaneModeEnabler = new AirplaneModeEnabler(getContext(), this);
|
||||
|
||||
// TODO(b/37429702): Add animations and preference comparator back after initial screen is
|
||||
@@ -1187,10 +1175,6 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.network_provider_settings) {
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return Utils.isProviderModelEnabled(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
|
@@ -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,
|
||||
@@ -228,14 +221,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();
|
||||
@@ -349,50 +334,6 @@ 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);
|
||||
@@ -472,8 +413,7 @@ 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() {
|
||||
@@ -492,7 +432,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
.filter(subInfo ->
|
||||
mSubsPrefCtrlInjector.canSubscriptionBeDisplayed(mContext,
|
||||
subInfo.getSubscriptionId()))
|
||||
.count() >= (mSubsPrefCtrlInjector.isProviderModelEnabled(mContext) ? 1 : 2);
|
||||
.count() >= 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -537,12 +477,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;
|
||||
}
|
||||
@@ -602,13 +536,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.
|
||||
*/
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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]));
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user