Merge "Update SubscriptionManager API as per API council." into lmp-mr1-dev
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 7b91b7d..8e79366 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -47,7 +47,7 @@
import android.telephony.RadioAccessFamily;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
-import android.telephony.SubInfoRecord;
+import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -769,8 +769,8 @@
}
boolean isValid = false;
- List<SubInfoRecord> slist = SubscriptionManager.getActiveSubInfoList();
- for (SubInfoRecord subInfoRecord : slist) {
+ List<SubscriptionInfo> slist = SubscriptionManager.getActiveSubscriptionInfoList();
+ for (SubscriptionInfo subInfoRecord : slist) {
if (subInfoRecord.getSubscriptionId() == subId) {
isValid = true;
break;
diff --git a/src/com/android/phone/SubscriptionInfoHelper.java b/src/com/android/phone/SubscriptionInfoHelper.java
index 926a156..1255452 100644
--- a/src/com/android/phone/SubscriptionInfoHelper.java
+++ b/src/com/android/phone/SubscriptionInfoHelper.java
@@ -20,7 +20,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
-import android.telephony.SubInfoRecord;
+import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.text.TextUtils;
@@ -75,7 +75,7 @@
return intent;
}
- public static void addExtrasToIntent(Intent intent, SubInfoRecord subscription) {
+ public static void addExtrasToIntent(Intent intent, SubscriptionInfo subscription) {
intent.putExtra(SubscriptionInfoHelper.SUB_ID_EXTRA, subscription.getSubscriptionId());
intent.putExtra(
SubscriptionInfoHelper.SUB_LABEL_EXTRA, subscription.getDisplayName().toString());
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index 5226e0d..a99c5f0 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -12,7 +12,7 @@
import android.preference.PreferenceFragment;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
-import android.telephony.SubInfoRecord;
+import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -297,7 +297,7 @@
}
private void initAccountList() {
- for (SubInfoRecord subscription : SubscriptionManager.getActiveSubInfoList()) {
+ 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 2f20621..7bd396b 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -16,11 +16,8 @@
package com.android.services.telephony;
-import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.telecom.PhoneAccount;
@@ -28,7 +25,8 @@
import android.telecom.TelecomManager;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
-import android.telephony.SubInfoRecord;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionListener;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -36,7 +34,6 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.PhoneProxy;
-import com.android.internal.telephony.TelephonyIntents;
import com.android.phone.R;
import java.util.Arrays;
@@ -129,7 +126,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.
- SubInfoRecord record = SubscriptionManager.getSubInfoForSubscriber(subId);
+ SubscriptionInfo record = SubscriptionManager.getSubscriptionInfoForSubscriber(subId);
if (record != null) {
subDisplayName = record.getDisplayName();
slotId = record.getSubscriptionId();
@@ -189,31 +186,12 @@
return colors[((int) subId) % colors.length];
}
- private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ private final SubscriptionListener mSubscriptionListener = new SubscriptionListener() {
@Override
- public void onReceive(Context context, Intent intent) {
- boolean rebuildAccounts = false;
- String action = intent.getAction();
- if (TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED.equals(action)) {
- int status = intent.getIntExtra(
- SubscriptionManager.INTENT_KEY_DETECT_STATUS,
- SubscriptionManager.EXTRA_VALUE_NOCHANGE);
- Log.i(this, "SUBINFO_RECORD_UPDATED : %d.", status);
- // Anytime the SIM state changes...rerun the setup
- // We rely on this notification even when the status is EXTRA_VALUE_NOCHANGE,
- // so we explicitly do not check for that here.
- rebuildAccounts = true;
- } else if (TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE.equals(action)) {
- String columnName = intent.getStringExtra(TelephonyIntents.EXTRA_COLUMN_NAME);
- String stringContent = intent.getStringExtra(TelephonyIntents.EXTRA_STRING_CONTENT);
- Log.v(this, "SUBINFO_CONTENT_CHANGE: Column: %s Content: %s",
- columnName, stringContent);
- rebuildAccounts = true;
- }
- if (rebuildAccounts) {
- tearDownAccounts();
- setupAccounts();
- }
+ public void onSubscriptionInfoChanged() {
+ // Any time the SubscriptionInfo changes...rerun the setup
+ tearDownAccounts();
+ setupAccounts();
}
};
@@ -253,12 +231,14 @@
* Sets up all the phone accounts for SIMs on first boot.
*/
void setupOnBoot() {
- // We need to register for both types of intents if we want to see added/removed Subs
- // along with changes to a given Sub.
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED);
- intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE);
- mContext.registerReceiver(mReceiver, intentFilter);
+ // TODO: When this object "finishes" we should unregister by invoking
+ // 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
+ 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.