[Settings] Unable to display disabled SIM (part 2)
1. Disabled SIMs are accessed through getAvailableSubscriptionInfoList() API. 2. Support of DSDS enable/disable runtime change intent detection 3. Add support for AutoCloseable Bug: 144172733 Test: Manual Change-Id: Ibce65c854aee2ae07ca94cbdd4bd2ce656f5f2c8
This commit is contained in:
@@ -25,6 +25,7 @@ import android.os.Looper;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -39,9 +40,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
* A listener for active subscription change
|
||||
*/
|
||||
public abstract class ActiveSubsciptionsListener
|
||||
extends SubscriptionManager.OnSubscriptionsChangedListener {
|
||||
extends SubscriptionManager.OnSubscriptionsChangedListener
|
||||
implements AutoCloseable {
|
||||
|
||||
private static final String TAG = "ActiveSubsciptions";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -61,6 +64,8 @@ public abstract class ActiveSubsciptionsListener
|
||||
CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
|
||||
mSubscriptionChangeIntentFilter.addAction(
|
||||
TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
|
||||
mSubscriptionChangeIntentFilter.addAction(
|
||||
TelephonyManager.ACTION_MULTI_SIM_CONFIG_CHANGED);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -134,6 +139,13 @@ public abstract class ActiveSubsciptionsListener
|
||||
monitorSubscriptionsChange(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of {@code AutoCloseable}
|
||||
*/
|
||||
public void close() {
|
||||
stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SubscriptionManager
|
||||
*
|
||||
@@ -174,15 +186,17 @@ public abstract class ActiveSubsciptionsListener
|
||||
mCachedActiveSubscriptionInfo = getSubscriptionManager().getActiveSubscriptionInfoList();
|
||||
mCacheState.compareAndSet(STATE_LISTENING, STATE_DATA_CACHED);
|
||||
|
||||
if ((mCachedActiveSubscriptionInfo == null)
|
||||
|| (mCachedActiveSubscriptionInfo.size() <= 0)) {
|
||||
Log.d(TAG, "active subscriptions: " + mCachedActiveSubscriptionInfo);
|
||||
} else {
|
||||
final StringBuilder logString = new StringBuilder("active subscriptions:");
|
||||
for (SubscriptionInfo subInfo : mCachedActiveSubscriptionInfo) {
|
||||
logString.append(" " + subInfo.getSubscriptionId());
|
||||
if (DEBUG) {
|
||||
if ((mCachedActiveSubscriptionInfo == null)
|
||||
|| (mCachedActiveSubscriptionInfo.size() <= 0)) {
|
||||
Log.d(TAG, "active subscriptions: " + mCachedActiveSubscriptionInfo);
|
||||
} else {
|
||||
final StringBuilder logString = new StringBuilder("active subscriptions:");
|
||||
for (SubscriptionInfo subInfo : mCachedActiveSubscriptionInfo) {
|
||||
logString.append(" " + subInfo.getSubscriptionId());
|
||||
}
|
||||
Log.d(TAG, logString.toString());
|
||||
}
|
||||
Log.d(TAG, logString.toString());
|
||||
}
|
||||
|
||||
return mCachedActiveSubscriptionInfo;
|
||||
@@ -208,12 +222,12 @@ public abstract class ActiveSubsciptionsListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of accessible subscription info
|
||||
* Get a list of all subscription info which accessible by Settings app
|
||||
*
|
||||
* @return A list of accessible subscription info
|
||||
*/
|
||||
public List<SubscriptionInfo> getAccessibleSubscriptionsInfo() {
|
||||
return getSubscriptionManager().getAccessibleSubscriptionInfoList();
|
||||
return getSubscriptionManager().getAvailableSubscriptionInfoList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,11 +237,12 @@ public abstract class ActiveSubsciptionsListener
|
||||
* @return A subscription info which is accessible list
|
||||
*/
|
||||
public SubscriptionInfo getAccessibleSubscriptionInfo(int subId) {
|
||||
if (mCacheState.get() >= STATE_DATA_CACHED) {
|
||||
final SubscriptionInfo activeSubInfo = getActiveSubscriptionInfo(subId);
|
||||
if (activeSubInfo != null) {
|
||||
return activeSubInfo;
|
||||
}
|
||||
// Always check if subId is part of activeSubscriptions
|
||||
// since there's cache design within SubscriptionManager.
|
||||
// That give us a chance to avoid from querying ContentProvider.
|
||||
final SubscriptionInfo activeSubInfo = getActiveSubscriptionInfo(subId);
|
||||
if (activeSubInfo != null) {
|
||||
return activeSubInfo;
|
||||
}
|
||||
|
||||
final List<SubscriptionInfo> subInfoList = getAccessibleSubscriptionsInfo();
|
||||
|
@@ -140,6 +140,7 @@ public class ProxySubscriptionManager implements LifecycleObserver {
|
||||
|
||||
@OnLifecycleEvent(ON_DESTROY)
|
||||
void onDestroy() {
|
||||
mSubsciptionsMonitor.close();
|
||||
mAirplaneModeMonitor.close();
|
||||
|
||||
if (mLifecycle != null) {
|
||||
|
@@ -101,7 +101,7 @@ public class ActiveSubsciptionsListenerTest {
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
mListener.stop();
|
||||
mListener.close();
|
||||
}
|
||||
|
||||
private class ActiveSubsciptionsListenerImpl extends ActiveSubsciptionsListener {
|
||||
|
Reference in New Issue
Block a user