Revert "Additional changes to SubscriptionManager API as per API council."
This reverts commit 88fd66a22ab781927556a34cdb7b14179efea917.
Change-Id: Ia6353137c665ca048bb1b02dee7bd581dec9973f
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 6cf0d7e..afeebd8 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -102,8 +102,6 @@
private static final String UP_ACTIVITY_CLASS =
"com.android.settings.Settings$WirelessSettingsActivity";
- private SubscriptionManager mSubscriptionManager;
-
//UI objects
private ListPreference mButtonPreferredNetworkMode;
private ListPreference mButtonEnabledNetworks;
@@ -112,7 +110,7 @@
private Preference mLteDataServicePref;
private static final String iface = "rmnet0"; //TODO: this will go away
- private List<SubscriptionInfo> mSelectableSubInfos = new ArrayList<SubscriptionInfo>();
+ private List<SubscriptionInfo> mSelectableSubInfos = null;
private UserManager mUm;
private Phone mPhone;
@@ -276,12 +274,9 @@
super.onCreate(icicle);
final Context context = getApplicationContext();
- mPhone = PhoneGlobals.getPhone();
- mHandler = new MyHandler();
- mUm = (UserManager) getSystemService(Context.USER_SERVICE);
+ mSelectableSubInfos = new ArrayList<SubscriptionInfo>();
final TelephonyManager tm =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- mSubscriptionManager = SubscriptionManager.from(this);
for (int i = 0; i < tm.getSimCount(); i++) {
SubscriptionInfo sir = findRecordBySlotId(i);
@@ -290,6 +285,10 @@
}
}
+ mPhone = PhoneGlobals.getPhone();
+ mHandler = new MyHandler();
+ mUm = (UserManager) getSystemService(Context.USER_SERVICE);
+
if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
mUnavailable = true;
setContentView(R.layout.telephony_disallowed_preference_screen);
@@ -1090,18 +1089,16 @@
* finds a record with slotId.
* Since the number of SIMs are few, an array is fine.
*/
- public SubscriptionInfo findRecordBySlotId(final int slotId) {
+ public static SubscriptionInfo findRecordBySlotId(final int slotId) {
final List<SubscriptionInfo> subInfoList =
- mSubscriptionManager.getActiveSubscriptionInfoList();
- if (subInfoList != null) {
- final int subInfoLength = subInfoList.size();
+ SubscriptionManager.getActiveSubscriptionInfoList();
+ final int subInfoLength = subInfoList.size();
- for (int i = 0; i < subInfoLength; ++i) {
- final SubscriptionInfo sir = subInfoList.get(i);
- if (sir.getSimSlotIndex() == slotId) {
- //Right now we take the first subscription on a SIM.
- return sir;
- }
+ for (int i = 0; i < subInfoLength; ++i) {
+ final SubscriptionInfo sir = subInfoList.get(i);
+ if (sir.getSimSlotIndex() == slotId) {
+ //Right now we take the first subscription on a SIM.
+ return sir;
}
}
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 58f5919..e8cffa9 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -133,14 +133,13 @@
/** The singleton instance. */
private static PhoneInterfaceManager sInstance;
- private PhoneGlobals mApp;
- private Phone mPhone;
- private CallManager mCM;
- private AppOpsManager mAppOps;
- private MainThreadHandler mMainThreadHandler;
- private SubscriptionManager mSubscriptionManager;
- private SharedPreferences mTelephonySharedPreferences;
+ PhoneGlobals mApp;
+ Phone mPhone;
+ CallManager mCM;
+ AppOpsManager mAppOps;
+ MainThreadHandler mMainThreadHandler;
+ SharedPreferences mTelephonySharedPreferences;
private static final String PREF_CARRIERS_ALPHATAG_PREFIX = "carrier_alphtag_";
private static final String PREF_CARRIERS_NUMBER_PREFIX = "carrier_number_";
private static final String PREF_ENABLE_VIDEO_CALLING = "enable_video_calling";
@@ -727,8 +726,6 @@
mMainThreadHandler = new MainThreadHandler();
mTelephonySharedPreferences =
PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
- mSubscriptionManager = SubscriptionManager.from(app);
-
publish();
}
@@ -793,13 +790,11 @@
}
boolean isValid = false;
- List<SubscriptionInfo> slist = mSubscriptionManager.getActiveSubscriptionInfoList();
- if (slist != null) {
- for (SubscriptionInfo subInfoRecord : slist) {
- if (subInfoRecord.getSubscriptionId() == subId) {
- isValid = true;
- break;
- }
+ List<SubscriptionInfo> slist = SubscriptionManager.getActiveSubscriptionInfoList();
+ for (SubscriptionInfo subInfoRecord : slist) {
+ if (subInfoRecord.getSubscriptionId() == subId) {
+ isValid = true;
+ break;
}
}
if (isValid == false) {
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index 9d7be9b..a99c5f0 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -50,8 +50,6 @@
private String LOG_TAG = PhoneAccountSettingsFragment.class.getSimpleName();
private TelecomManager mTelecomManager;
- private SubscriptionManager mSubscriptionManager;
-
private Context mApplicationContext;
private PreferenceCategory mAccountList;
@@ -70,7 +68,6 @@
mTelecomManager = TelecomManager.from(getActivity());
mApplicationContext = getActivity().getApplicationContext();
- mSubscriptionManager = SubscriptionManager.from(mApplicationContext);
}
@Override
@@ -300,11 +297,7 @@
}
private void initAccountList() {
- List<SubscriptionInfo> sil = mSubscriptionManager.getActiveSubscriptionInfoList();
- if (sil == null) {
- return;
- }
- for (SubscriptionInfo subscription : sil) {
+ for (SubscriptionInfo subscription : SubscriptionManager.getActiveSubscriptionInfoList()) {
CharSequence label = subscription.getDisplayName();
Intent intent = new Intent(TelecomManager.ACTION_SHOW_CALL_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index c105fff..3523288 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -27,8 +27,8 @@
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionListener;
import android.telephony.SubscriptionManager;
-import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -82,7 +82,7 @@
// Populate the phone account data.
int subId = mPhone.getSubId();
int color = PhoneAccount.NO_COLOR;
- int slotId = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
+ int slotId = SubscriptionManager.INVALID_SLOT_ID;
String line1Number = mTelephonyManager.getLine1NumberForSubscriber(subId);
if (line1Number == null) {
line1Number = "";
@@ -108,8 +108,7 @@
CharSequence subDisplayName = null;
// We can only get the real slotId from the SubInfoRecord, we can't calculate the
// slotId from the subId or the phoneId in all instances.
- SubscriptionInfo record =
- mSubscriptionManager.getActiveSubscriptionInfo(subId);
+ SubscriptionInfo record = SubscriptionManager.getSubscriptionInfoForSubscriber(subId);
if (record != null) {
subDisplayName = record.getDisplayName();
slotId = record.getSimSlotIndex();
@@ -171,10 +170,9 @@
}
}
- private OnSubscriptionsChangedListener mOnSubscriptionsChangedListener =
- new OnSubscriptionsChangedListener() {
+ private final SubscriptionListener mSubscriptionListener = new SubscriptionListener() {
@Override
- public void onSubscriptionsChanged() {
+ public void onSubscriptionInfoChanged() {
// Any time the SubscriptionInfo changes...rerun the setup
tearDownAccounts();
setupAccounts();
@@ -197,7 +195,6 @@
private final Context mContext;
private final TelecomManager mTelecomManager;
private final TelephonyManager mTelephonyManager;
- private final SubscriptionManager mSubscriptionManager;
private List<AccountEntry> mAccounts = new LinkedList<AccountEntry>();
private int mServiceState = ServiceState.STATE_POWER_OFF;
@@ -205,7 +202,6 @@
mContext = context;
mTelecomManager = TelecomManager.from(context);
mTelephonyManager = TelephonyManager.from(context);
- mSubscriptionManager = SubscriptionManager.from(context);
}
static synchronized final TelecomAccountRegistry getInstance(Context context) {
@@ -220,14 +216,13 @@
*/
void setupOnBoot() {
// TODO: When this object "finishes" we should unregister by invoking
- // SubscriptionManager.getInstance(mContext).unregister(mOnSubscriptionsChangedListener);
+ // SubscriptionManager.unregister(mContext, mSubscriptionListener);
// This is not strictly necessary because it will be unregistered if the
// notification fails but it is good form.
- // Register for SubscriptionInfo list changes which is guaranteed
- // to invoke onSubscriptionsChanged the first time.
- SubscriptionManager.from(mContext).registerOnSubscriptionsChangedListener(
- mOnSubscriptionsChangedListener);
+ // Register for SubscriptionInfo list changes
+ SubscriptionManager.register(mContext, mSubscriptionListener,
+ SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED);
// We also need to listen for changes to the service state (e.g. emergency -> in service)
// because this could signal a removal or addition of a SIM in a single SIM phone.