[Settings] mSubId should not be overridden in TelephonyBasePreferenceController

mSubId is a protected member provided by parent class.
Overriding mSubId should be avoided.

Bug: 150535296
Test: manual
Merged-In: I391b034c9badd43094ab52b8b6488bca07ef3c86
Change-Id: I65fda30d1e699695315eb57d8930a27fdebb5a46
This commit is contained in:
Bonian Chen
2020-04-06 22:00:18 +08:00
parent fb2690102b
commit 1b36fda316
2 changed files with 13 additions and 6 deletions

View File

@@ -28,16 +28,21 @@ import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.network.SubscriptionsChangeListener;
public class DisabledSubscriptionController extends BasePreferenceController implements
/**
* Preference controller group which can hide UI option from visible when SIM is no longer in
* active.
*/
public class DisabledSubscriptionController extends TelephonyBasePreferenceController implements
SubscriptionsChangeListener.SubscriptionsChangeListenerClient, LifecycleObserver {
private PreferenceCategory mCategory;
private int mSubId;
private SubscriptionsChangeListener mChangeListener;
private SubscriptionManager mSubscriptionManager;
/**
* Constructor of preference controller
*/
public DisabledSubscriptionController(Context context, String preferenceKey) {
super(context, preferenceKey);
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
@@ -45,6 +50,9 @@ public class DisabledSubscriptionController extends BasePreferenceController imp
mChangeListener = new SubscriptionsChangeListener(context, this);
}
/**
* Re-initialize the configuration based on subscription id provided
*/
public void init(Lifecycle lifecycle, int subId) {
lifecycle.addObserver(this);
mSubId = subId;
@@ -69,7 +77,7 @@ public class DisabledSubscriptionController extends BasePreferenceController imp
}
private void update() {
if (mCategory == null || mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
if (mCategory == null || !SubscriptionManager.isValidSubscriptionId(mSubId)) {
return;
}
// TODO b/135222940: re-evaluate whether to use mSubscriptionManager#isSubscriptionEnabled
@@ -77,7 +85,7 @@ public class DisabledSubscriptionController extends BasePreferenceController imp
}
@Override
public int getAvailabilityStatus() {
public int getAvailabilityStatus(int subId) {
return AVAILABLE_UNSEARCHABLE;
}

View File

@@ -44,7 +44,6 @@ public abstract class CdmaBasePreferenceController extends TelephonyBasePreferen
protected Preference mPreference;
protected TelephonyManager mTelephonyManager;
protected PreferenceManager mPreferenceManager;
protected int mSubId;
private DataContentObserver mDataContentObserver;
public CdmaBasePreferenceController(Context context, String key) {