Merge "[Settings] Change the way in MobileNetworkListFragment for getting the subscription info from room db part3"
This commit is contained in:
@@ -22,9 +22,9 @@ import android.os.UserManager;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -42,6 +42,16 @@ public class MobileNetworkListFragment extends DashboardFragment {
|
||||
static final String KEY_PREFERENCE_CATEGORY_DOWNLOADED_SIM =
|
||||
"provider_model_downloaded_sim_category";
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
// Disable the animation of the preference list
|
||||
final RecyclerView prefListView = getListView();
|
||||
if (prefListView != null) {
|
||||
prefListView.setItemAnimator(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.network_provider_sims_list;
|
||||
@@ -67,11 +77,11 @@ public class MobileNetworkListFragment extends DashboardFragment {
|
||||
|
||||
NetworkProviderSimsCategoryController simCategoryPrefCtrl =
|
||||
new NetworkProviderSimsCategoryController(context, KEY_PREFERENCE_CATEGORY_SIM,
|
||||
getSettingsLifecycle());
|
||||
getSettingsLifecycle(), this);
|
||||
controllers.add(simCategoryPrefCtrl);
|
||||
NetworkProviderDownloadedSimsCategoryController downloadedSimsCategoryCtrl =
|
||||
new NetworkProviderDownloadedSimsCategoryController(context,
|
||||
KEY_PREFERENCE_CATEGORY_DOWNLOADED_SIM, getSettingsLifecycle());
|
||||
KEY_PREFERENCE_CATEGORY_DOWNLOADED_SIM, getSettingsLifecycle(), this);
|
||||
controllers.add(downloadedSimsCategoryCtrl);
|
||||
|
||||
return controllers;
|
||||
|
@@ -18,7 +18,10 @@ package com.android.settings.network;
|
||||
import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
@@ -78,6 +81,7 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
||||
private AirplaneModeObserver mAirplaneModeObserver;
|
||||
private Uri mAirplaneModeSettingUri;
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private IntentFilter mFilter = new IntentFilter();
|
||||
|
||||
private int mPhysicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
|
||||
private int mLogicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
|
||||
@@ -101,6 +105,8 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
||||
mAirplaneModeSettingUri = Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON);
|
||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
||||
mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_MOBILE_NETWORK_DB_CREATED);
|
||||
mFilter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
|
||||
mFilter.addAction(SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
|
||||
}
|
||||
|
||||
private class AirplaneModeObserver extends ContentObserver {
|
||||
@@ -125,9 +131,21 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
||||
}
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mDataSubscriptionChangedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final String action = intent.getAction();
|
||||
if (action.equals(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)
|
||||
|| action.equals(SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) {
|
||||
onSubscriptionsChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void addRegister(LifecycleOwner lifecycleOwner) {
|
||||
mSubscriptionManager.addOnSubscriptionsChangedListener(mContext.getMainExecutor(), this);
|
||||
mAirplaneModeObserver.register(mContext);
|
||||
mContext.registerReceiver(mDataSubscriptionChangedReceiver, mFilter);
|
||||
observeAllSubInfo(lifecycleOwner);
|
||||
observeAllUiccInfo(lifecycleOwner);
|
||||
observeAllMobileNetworkInfo(lifecycleOwner);
|
||||
@@ -137,6 +155,9 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
||||
mSubscriptionManager.removeOnSubscriptionsChangedListener(this);
|
||||
mAirplaneModeObserver.unRegister(mContext);
|
||||
mContext.getContentResolver().unregisterContentObserver(mAirplaneModeObserver);
|
||||
if (mDataSubscriptionChangedReceiver != null) {
|
||||
mContext.unregisterReceiver(mDataSubscriptionChangedReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
private void observeAllSubInfo(LifecycleOwner lifecycleOwner) {
|
||||
|
@@ -24,12 +24,13 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
@@ -40,6 +41,9 @@ import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
|
||||
import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
|
||||
import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -47,7 +51,7 @@ import java.util.Map;
|
||||
|
||||
public class NetworkProviderDownloadedSimListController extends
|
||||
AbstractPreferenceController implements
|
||||
LifecycleObserver, SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
|
||||
LifecycleObserver, MobileNetworkRepository.MobileNetworkCallback {
|
||||
private static final String TAG = "NetworkProviderDownloadedSimListCtrl";
|
||||
private static final String KEY_PREFERENCE_CATEGORY_DOWNLOADED_SIM =
|
||||
"provider_model_downloaded_sim_category";
|
||||
@@ -56,46 +60,32 @@ public class NetworkProviderDownloadedSimListController extends
|
||||
private static final String KEY_ADD_MORE = "add_more";
|
||||
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private SubscriptionsChangeListener mChangeListener;
|
||||
private PreferenceCategory mPreferenceCategory;
|
||||
private Map<Integer, Preference> mPreferences;
|
||||
private LifecycleOwner mLifecycleOwner;
|
||||
private MobileNetworkRepository mMobileNetworkRepository;
|
||||
private List<SubscriptionInfoEntity> mSubInfoEntityList = new ArrayList<>();
|
||||
|
||||
public NetworkProviderDownloadedSimListController(Context context, Lifecycle lifecycle) {
|
||||
public NetworkProviderDownloadedSimListController(Context context, Lifecycle lifecycle,
|
||||
LifecycleOwner lifecycleOwner) {
|
||||
super(context);
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
mChangeListener = new SubscriptionsChangeListener(context, this);
|
||||
mPreferences = new ArrayMap<>();
|
||||
mLifecycleOwner = lifecycleOwner;
|
||||
mMobileNetworkRepository = new MobileNetworkRepository(context, this);
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_RESUME)
|
||||
public void onResume() {
|
||||
mChangeListener.start();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
|
||||
mContext.registerReceiver(mDataSubscriptionChangedReceiver, filter);
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
update();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_PAUSE)
|
||||
public void onPause() {
|
||||
mChangeListener.stop();
|
||||
if (mDataSubscriptionChangedReceiver != null) {
|
||||
mContext.unregisterReceiver(mDataSubscriptionChangedReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
final BroadcastReceiver mDataSubscriptionChangedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final String action = intent.getAction();
|
||||
if (action.equals(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
@@ -113,18 +103,17 @@ public class NetworkProviderDownloadedSimListController extends
|
||||
final Map<Integer, Preference> existingPreferences = mPreferences;
|
||||
mPreferences = new ArrayMap<>();
|
||||
|
||||
final List<SubscriptionInfo> subscriptions = getAvailableDownloadedSubscriptions();
|
||||
for (SubscriptionInfo info : subscriptions) {
|
||||
final int subId = info.getSubscriptionId();
|
||||
final List<SubscriptionInfoEntity> subscriptions = getAvailableDownloadedSubscriptions();
|
||||
for (SubscriptionInfoEntity info : subscriptions) {
|
||||
final int subId = Integer.parseInt(info.subId);
|
||||
Preference pref = existingPreferences.remove(subId);
|
||||
if (pref == null) {
|
||||
pref = new Preference(mPreferenceCategory.getContext());
|
||||
mPreferenceCategory.addPreference(pref);
|
||||
}
|
||||
final CharSequence displayName = SubscriptionUtil.getUniqueSubscriptionDisplayName(
|
||||
info, mContext);
|
||||
final CharSequence displayName = info.uniqueName;
|
||||
pref.setTitle(displayName);
|
||||
pref.setSummary(getSummary(subId));
|
||||
pref.setSummary(getSummary(info));
|
||||
|
||||
pref.setOnPreferenceClickListener(clickedPref -> {
|
||||
MobileNetworkUtils.launchMobileNetworkSettings(mContext, info);
|
||||
@@ -137,12 +126,12 @@ public class NetworkProviderDownloadedSimListController extends
|
||||
}
|
||||
}
|
||||
|
||||
public CharSequence getSummary(int subId) {
|
||||
if (mSubscriptionManager.isActiveSubscriptionId(subId)) {
|
||||
CharSequence config = SubscriptionUtil.getDefaultSimConfig(mContext, subId);
|
||||
public CharSequence getSummary(SubscriptionInfoEntity subInfo) {
|
||||
if (subInfo.isActiveSubscriptionId) {
|
||||
CharSequence config = subInfo.defaultSimConfig;
|
||||
CharSequence summary = mContext.getResources().getString(
|
||||
R.string.sim_category_active_sim);
|
||||
if (config == null) {
|
||||
if (config == "") {
|
||||
return summary;
|
||||
} else {
|
||||
final StringBuilder activeSim = new StringBuilder();
|
||||
@@ -167,10 +156,11 @@ public class NetworkProviderDownloadedSimListController extends
|
||||
return KEY_PREFERENCE_DOWNLOADED_SIM;
|
||||
}
|
||||
|
||||
private List<SubscriptionInfo> getAvailableDownloadedSubscriptions() {
|
||||
List<SubscriptionInfo> subList = new ArrayList<>();
|
||||
for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mContext)) {
|
||||
if (info.isEmbedded()) {
|
||||
@VisibleForTesting
|
||||
protected List<SubscriptionInfoEntity> getAvailableDownloadedSubscriptions() {
|
||||
List<SubscriptionInfoEntity> subList = new ArrayList<>();
|
||||
for (SubscriptionInfoEntity info : mSubInfoEntityList) {
|
||||
if (info.isEmbedded) {
|
||||
subList.add(info);
|
||||
}
|
||||
}
|
||||
@@ -189,22 +179,27 @@ public class NetworkProviderDownloadedSimListController extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscriptionsChanged() {
|
||||
update();
|
||||
public void onAvailableSubInfoChanged(List<SubscriptionInfoEntity> subInfoEntityList) {
|
||||
if ((mSubInfoEntityList != null &&
|
||||
(subInfoEntityList.isEmpty() || !subInfoEntityList.equals(mSubInfoEntityList)))
|
||||
|| (!subInfoEntityList.isEmpty() && mSubInfoEntityList == null)) {
|
||||
Log.d(TAG, "subInfo list from framework is changed, update the subInfo entity list.");
|
||||
mSubInfoEntityList = subInfoEntityList;
|
||||
mPreferenceCategory.setVisible(isAvailable());
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected int getDefaultVoiceSubscriptionId() {
|
||||
return SubscriptionManager.getDefaultVoiceSubscriptionId();
|
||||
@Override
|
||||
public void onActiveSubInfoChanged(List<SubscriptionInfoEntity> activeSubInfoList) {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected int getDefaultSmsSubscriptionId() {
|
||||
return SubscriptionManager.getDefaultSmsSubscriptionId();
|
||||
@Override
|
||||
public void onAllUiccInfoChanged(List<UiccInfoEntity> uiccInfoEntityList) {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected int getDefaultDataSubscriptionId() {
|
||||
return SubscriptionManager.getDefaultDataSubscriptionId();
|
||||
@Override
|
||||
public void onAllMobileNetworkInfoChanged(
|
||||
List<MobileNetworkInfoEntity> mobileNetworkInfoEntityList) {
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package com.android.settings.network;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -22,10 +23,10 @@ public class NetworkProviderDownloadedSimsCategoryController extends
|
||||
private NetworkProviderDownloadedSimListController mNetworkProviderDownloadedSimListController;
|
||||
|
||||
public NetworkProviderDownloadedSimsCategoryController(Context context, String key,
|
||||
Lifecycle lifecycle) {
|
||||
Lifecycle lifecycle, LifecycleOwner lifecycleOwner) {
|
||||
super(context, key);
|
||||
mNetworkProviderDownloadedSimListController =
|
||||
new NetworkProviderDownloadedSimListController(mContext, lifecycle);
|
||||
new NetworkProviderDownloadedSimListController(mContext, lifecycle, lifecycleOwner);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -24,12 +24,13 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
@@ -40,58 +41,47 @@ import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
|
||||
import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
|
||||
import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class NetworkProviderSimListController extends AbstractPreferenceController implements
|
||||
LifecycleObserver, SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
|
||||
LifecycleObserver, MobileNetworkRepository.MobileNetworkCallback {
|
||||
private static final String TAG = "NetworkProviderSimListCtrl";
|
||||
private static final String KEY_PREFERENCE_CATEGORY_SIM = "provider_model_sim_category";
|
||||
private static final String KEY_PREFERENCE_SIM = "provider_model_sim_list";
|
||||
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private SubscriptionsChangeListener mChangeListener;
|
||||
private PreferenceCategory mPreferenceCategory;
|
||||
private Map<Integer, Preference> mPreferences;
|
||||
private LifecycleOwner mLifecycleOwner;
|
||||
private MobileNetworkRepository mMobileNetworkRepository;
|
||||
private List<SubscriptionInfoEntity> mSubInfoEntityList = new ArrayList<>();
|
||||
|
||||
public NetworkProviderSimListController(Context context, Lifecycle lifecycle) {
|
||||
public NetworkProviderSimListController(Context context, Lifecycle lifecycle,
|
||||
LifecycleOwner lifecycleOwner) {
|
||||
super(context);
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
mChangeListener = new SubscriptionsChangeListener(context, this);
|
||||
mPreferences = new ArrayMap<>();
|
||||
mLifecycleOwner = lifecycleOwner;
|
||||
mMobileNetworkRepository = new MobileNetworkRepository(context, this);
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_RESUME)
|
||||
public void onResume() {
|
||||
mChangeListener.start();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
|
||||
mContext.registerReceiver(mDataSubscriptionChangedReceiver, filter);
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
update();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_PAUSE)
|
||||
public void onPause() {
|
||||
mChangeListener.stop();
|
||||
if (mDataSubscriptionChangedReceiver != null) {
|
||||
mContext.unregisterReceiver(mDataSubscriptionChangedReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
final BroadcastReceiver mDataSubscriptionChangedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final String action = intent.getAction();
|
||||
if (action.equals(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
@@ -107,22 +97,22 @@ public class NetworkProviderSimListController extends AbstractPreferenceControll
|
||||
final Map<Integer, Preference> existingPreferences = mPreferences;
|
||||
mPreferences = new ArrayMap<>();
|
||||
|
||||
final List<SubscriptionInfo> subscriptions = getAvailablePhysicalSubscription();
|
||||
for (SubscriptionInfo info : subscriptions) {
|
||||
final int subId = info.getSubscriptionId();
|
||||
final List<SubscriptionInfoEntity> subscriptions = getAvailablePhysicalSubscriptions();
|
||||
for (SubscriptionInfoEntity info : subscriptions) {
|
||||
final int subId = Integer.parseInt(info.subId);
|
||||
Preference pref = existingPreferences.remove(subId);
|
||||
if (pref == null) {
|
||||
pref = new Preference(mPreferenceCategory.getContext());
|
||||
mPreferenceCategory.addPreference(pref);
|
||||
}
|
||||
final CharSequence displayName = SubscriptionUtil.getUniqueSubscriptionDisplayName(
|
||||
info, mContext);
|
||||
final CharSequence displayName = info.uniqueName;
|
||||
pref.setTitle(displayName);
|
||||
pref.setSummary(getSummary(subId, displayName));
|
||||
boolean isActiveSubscriptionId = info.isActiveSubscriptionId;
|
||||
pref.setSummary(getSummary(info, displayName));
|
||||
|
||||
pref.setOnPreferenceClickListener(clickedPref -> {
|
||||
if (!mSubscriptionManager.isActiveSubscriptionId(subId)
|
||||
&& !SubscriptionUtil.showToggleForPhysicalSim(mSubscriptionManager)) {
|
||||
if (!isActiveSubscriptionId && !SubscriptionUtil.showToggleForPhysicalSim(
|
||||
mSubscriptionManager)) {
|
||||
SubscriptionUtil.startToggleSubscriptionDialogActivity(mContext, subId,
|
||||
true);
|
||||
} else {
|
||||
@@ -137,12 +127,12 @@ public class NetworkProviderSimListController extends AbstractPreferenceControll
|
||||
}
|
||||
}
|
||||
|
||||
public CharSequence getSummary(int subId, CharSequence displayName) {
|
||||
if (mSubscriptionManager.isActiveSubscriptionId(subId)) {
|
||||
CharSequence config = SubscriptionUtil.getDefaultSimConfig(mContext, subId);
|
||||
public CharSequence getSummary(SubscriptionInfoEntity subInfo, CharSequence displayName) {
|
||||
if (subInfo.isActiveSubscriptionId) {
|
||||
CharSequence config = subInfo.defaultSimConfig;
|
||||
CharSequence summary = mContext.getResources().getString(
|
||||
R.string.sim_category_active_sim);
|
||||
if (config == null) {
|
||||
if (config == "") {
|
||||
return summary;
|
||||
} else {
|
||||
final StringBuilder activeSim = new StringBuilder();
|
||||
@@ -158,17 +148,17 @@ public class NetworkProviderSimListController extends AbstractPreferenceControll
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
if (!getAvailablePhysicalSubscription().isEmpty()) {
|
||||
if (!getAvailablePhysicalSubscriptions().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected List<SubscriptionInfo> getAvailablePhysicalSubscription() {
|
||||
List<SubscriptionInfo> subList = new ArrayList<>();
|
||||
for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mContext)) {
|
||||
if (!info.isEmbedded()) {
|
||||
protected List<SubscriptionInfoEntity> getAvailablePhysicalSubscriptions() {
|
||||
List<SubscriptionInfoEntity> subList = new ArrayList<>();
|
||||
for (SubscriptionInfoEntity info : mSubInfoEntityList) {
|
||||
if (!info.isEmbedded) {
|
||||
subList.add(info);
|
||||
}
|
||||
}
|
||||
@@ -185,8 +175,28 @@ public class NetworkProviderSimListController extends AbstractPreferenceControll
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscriptionsChanged() {
|
||||
update();
|
||||
public void onAvailableSubInfoChanged(List<SubscriptionInfoEntity> subInfoEntityList) {
|
||||
if ((mSubInfoEntityList != null &&
|
||||
(subInfoEntityList.isEmpty() || !subInfoEntityList.equals(mSubInfoEntityList)))
|
||||
|| (!subInfoEntityList.isEmpty() && mSubInfoEntityList == null)) {
|
||||
Log.d(TAG, "subInfo list from framework is changed, update the subInfo entity list.");
|
||||
mSubInfoEntityList = subInfoEntityList;
|
||||
mPreferenceCategory.setVisible(isAvailable());
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActiveSubInfoChanged(List<SubscriptionInfoEntity> activeSubInfoList) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllUiccInfoChanged(List<UiccInfoEntity> uiccInfoEntityList) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllMobileNetworkInfoChanged(
|
||||
List<MobileNetworkInfoEntity> mobileNetworkInfoEntityList) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,19 +205,4 @@ public class NetworkProviderSimListController extends AbstractPreferenceControll
|
||||
refreshSummary(mPreferenceCategory);
|
||||
update();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected int getDefaultVoiceSubscriptionId() {
|
||||
return SubscriptionManager.getDefaultVoiceSubscriptionId();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected int getDefaultSmsSubscriptionId() {
|
||||
return SubscriptionManager.getDefaultSmsSubscriptionId();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected int getDefaultDataSubscriptionId() {
|
||||
return SubscriptionManager.getDefaultDataSubscriptionId();
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.network;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -35,10 +36,11 @@ public class NetworkProviderSimsCategoryController extends PreferenceCategoryCon
|
||||
private NetworkProviderSimListController mNetworkProviderSimListController;
|
||||
private PreferenceCategory mPreferenceCategory;
|
||||
|
||||
public NetworkProviderSimsCategoryController(Context context, String key, Lifecycle lifecycle) {
|
||||
public NetworkProviderSimsCategoryController(Context context, String key, Lifecycle lifecycle,
|
||||
LifecycleOwner lifecycleOwner) {
|
||||
super(context, key);
|
||||
mNetworkProviderSimListController =
|
||||
new NetworkProviderSimListController(mContext, lifecycle);
|
||||
new NetworkProviderSimListController(mContext, lifecycle, lifecycleOwner);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -610,7 +610,7 @@ public class SubscriptionUtil {
|
||||
boolean isDefaultData = subId == getDefaultDataSubscriptionId();
|
||||
|
||||
if (!isDefaultData && !isDefaultCall && !isDefaultSms) {
|
||||
return null;
|
||||
return "";
|
||||
}
|
||||
|
||||
final StringBuilder defaultConfig = new StringBuilder();
|
||||
|
Reference in New Issue
Block a user