Make taps on subscriptions in multi-network header go to mobile page
This CL does 2 things: -Makes the MobileNetworkActivity class capable of showing details for "available" in addition to just "active" networks. This is useful for dual-standby devices where one subscription is active and another is registered but not currently active. It also changes the title of this screen to be the network display name (defaults to the carrier name but can be customized by the user) instead of the generic "Mobile network". -Wires up the subscription entries in the multi-network header (which only appears when a device has multiple subscriptions) so that taps on a subscription preference bring you to the MobileNetworkActivity screen to show details for that network. Bug: 116349402 Test: make RunSettingsRoboTests Change-Id: I0e985652c1d8ec3c597b6b6e4426d222e2ad5352
This commit is contained in:
@@ -20,10 +20,13 @@ import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.telephony.MobileNetworkActivity;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -125,7 +128,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
mSubscriptionPreferences = new ArrayMap<>();
|
||||
|
||||
int order = mStartOrder;
|
||||
for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mManager) ) {
|
||||
for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mManager)) {
|
||||
final int subId = info.getSubscriptionId();
|
||||
Preference pref = existingPrefs.remove(subId);
|
||||
if (pref == null) {
|
||||
@@ -139,8 +142,9 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
// TODO(asargent) - set summary here to indicate default for calls/sms and data
|
||||
|
||||
pref.setOnPreferenceClickListener(clickedPref -> {
|
||||
// TODO(asargent) - make this start MobileNetworkActivity once we've
|
||||
// added support for it to take a subscription id
|
||||
final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
|
||||
intent.putExtra(Settings.EXTRA_SUB_ID, subId);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
|
||||
|
@@ -25,7 +25,6 @@ import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
|
||||
@@ -43,14 +42,12 @@ import com.android.settings.core.SettingsBaseActivity;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MobileNetworkActivity extends SettingsBaseActivity {
|
||||
|
||||
private static final String TAG = "MobileSettingsActivity";
|
||||
private static final String TAG = "MobileNetworkActivity";
|
||||
@VisibleForTesting
|
||||
static final String MOBILE_SETTINGS_TAG = "mobile_settings:";
|
||||
@VisibleForTesting
|
||||
@@ -94,6 +91,13 @@ public class MobileNetworkActivity extends SettingsBaseActivity {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
// Set the title to the name of the subscription. If we don't have subscription info, the
|
||||
// title will just default to the label for this activity that's already specified in
|
||||
// AndroidManifest.xml.
|
||||
final SubscriptionInfo subscription = getSubscription();
|
||||
if (subscription != null) {
|
||||
setTitle(subscription.getDisplayName());
|
||||
}
|
||||
updateSubscriptions(savedInstanceState);
|
||||
}
|
||||
|
||||
@@ -136,25 +140,41 @@ public class MobileNetworkActivity extends SettingsBaseActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current subId to display. First check whether intent has {@link
|
||||
* Settings#EXTRA_SUB_ID}. If not, just display first one in list
|
||||
* since it is already sorted by sim slot.
|
||||
* Get the current subscription to display. First check whether intent has {@link
|
||||
* Settings#EXTRA_SUB_ID} and if so find the subscription with that id. If not, just return the
|
||||
* first one in the mSubscriptionInfos list since it is already sorted by sim slot.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
int getSubscriptionId() {
|
||||
SubscriptionInfo getSubscription() {
|
||||
final Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
final int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL);
|
||||
if (subId != SUB_ID_NULL && mSubscriptionManager.isActiveSubscriptionId(subId)) {
|
||||
return subId;
|
||||
if (subId != SUB_ID_NULL) {
|
||||
for (SubscriptionInfo subscription :
|
||||
mSubscriptionManager.getAvailableSubscriptionInfoList()) {
|
||||
if (subscription.getSubscriptionId() == subId) {
|
||||
return subscription;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(mSubscriptionInfos)) {
|
||||
return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
return null;
|
||||
}
|
||||
return mSubscriptionInfos.get(0);
|
||||
}
|
||||
|
||||
return mSubscriptionInfos.get(0).getSubscriptionId();
|
||||
/**
|
||||
* Get the current subId to display.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
int getSubscriptionId() {
|
||||
final SubscriptionInfo subscription = getSubscription();
|
||||
if (subscription != null) {
|
||||
return subscription.getSubscriptionId();
|
||||
}
|
||||
return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
Reference in New Issue
Block a user