[Settings] Fix unable to accessing Fi
1. Get subscription ID from intent 2. Application context for proxy SubscriptionManager (since this is singleton) Bug: 144172733 Test: Manual Change-Id: I2f49d55da3380adeb40e8ff9414057113cb4ac35
This commit is contained in:
@@ -24,6 +24,7 @@ import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
@@ -37,6 +38,8 @@ import java.util.List;
|
||||
public abstract class ActiveSubsciptionsListener
|
||||
extends SubscriptionManager.OnSubscriptionsChangedListener {
|
||||
|
||||
private static final String TAG = "ActiveSubsciptions";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -155,6 +158,18 @@ public abstract class ActiveSubsciptionsListener
|
||||
}
|
||||
mIsCachedDataAvailable = mIsMonitoringDataChange;
|
||||
mCachedActiveSubscriptionInfo = getSubscriptionManager().getActiveSubscriptionInfoList();
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
return mCachedActiveSubscriptionInfo;
|
||||
}
|
||||
|
||||
@@ -246,7 +261,10 @@ public abstract class ActiveSubsciptionsListener
|
||||
}
|
||||
|
||||
private boolean clearCachedSubId(int subId) {
|
||||
if ((!mIsCachedDataAvailable) || (mCachedActiveSubscriptionInfo == null)) {
|
||||
if (!mIsCachedDataAvailable) {
|
||||
return false;
|
||||
}
|
||||
if (mCachedActiveSubscriptionInfo == null) {
|
||||
return false;
|
||||
}
|
||||
for (SubscriptionInfo subInfo : mCachedActiveSubscriptionInfo) {
|
||||
|
@@ -35,8 +35,7 @@ import java.util.List;
|
||||
/**
|
||||
* A proxy to the subscription manager
|
||||
*/
|
||||
public class ProxySubscriptionManager extends SubscriptionManager.OnSubscriptionsChangedListener
|
||||
implements LifecycleObserver {
|
||||
public class ProxySubscriptionManager implements LifecycleObserver {
|
||||
|
||||
/**
|
||||
* Interface for monitor active subscriptions list changing
|
||||
@@ -65,7 +64,7 @@ public class ProxySubscriptionManager extends SubscriptionManager.OnSubscription
|
||||
if (sSingleton != null) {
|
||||
return sSingleton;
|
||||
}
|
||||
sSingleton = new ProxySubscriptionManager(context);
|
||||
sSingleton = new ProxySubscriptionManager(context.getApplicationContext());
|
||||
return sSingleton;
|
||||
}
|
||||
|
||||
@@ -110,12 +109,6 @@ public class ProxySubscriptionManager extends SubscriptionManager.OnSubscription
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscriptionsChanged() {
|
||||
clearCache();
|
||||
notifyAllListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lifecycle for data within proxy
|
||||
*
|
||||
|
@@ -89,9 +89,12 @@ public class MobileNetworkActivity extends SettingsBaseActivity
|
||||
mProxySubscriptionMgr.setLifecycle(getLifecycle());
|
||||
mProxySubscriptionMgr.addActiveSubscriptionsListener(this);
|
||||
|
||||
final Intent startIntent = getIntent();
|
||||
mCurSubscriptionId = savedInstanceState != null
|
||||
? savedInstanceState.getInt(Settings.EXTRA_SUB_ID, SUB_ID_NULL)
|
||||
: SUB_ID_NULL;
|
||||
: ((startIntent != null)
|
||||
? startIntent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL)
|
||||
: SUB_ID_NULL);
|
||||
|
||||
final SubscriptionInfo subscription = getSubscription();
|
||||
updateTitleAndNavigation(subscription);
|
||||
|
Reference in New Issue
Block a user