SubscriptionController store SPN brdcst in carrier
Save the current PLMN/SPN in the carrier name of the SubscriptionInfo.
Bug: 18223317
Change-Id: I75ceba8ca8e1d9eb356292296b84a9cdac2e54e2
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java
index 24b9a1b..4d4a838 100644
--- a/src/java/com/android/internal/telephony/SubscriptionController.java
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java
@@ -16,10 +16,12 @@
package com.android.internal.telephony;
+import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
@@ -156,6 +158,32 @@
}
};
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (DBG) logd("onReceive " + intent);
+ // TODO: Have GsmServiceStateTracker insert this data directly and deprecate
+ // this broadcast.
+ int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ if (intent.getAction().equals(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION)) {
+ if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false)) {
+ String carrierText = intent.getStringExtra(TelephonyIntents.EXTRA_PLMN);
+ if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SPN, false)) {
+ // Need to show both plmn and spn.
+ String separator = mContext.getString(
+ com.android.internal.R.string.kg_text_message_separator).toString();
+ carrierText = new StringBuilder().append(carrierText).append(separator)
+ .append(intent.getStringExtra(TelephonyIntents.EXTRA_SPN))
+ .toString();
+ }
+ setCarrierText(carrierText, subId);
+ } else if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false)) {
+ setCarrierText(intent.getStringExtra(TelephonyIntents.EXTRA_PLMN), subId);
+ }
+ }
+ }
+ };
public static SubscriptionController init(Phone phone) {
synchronized (SubscriptionController.class) {
@@ -196,6 +224,8 @@
if(ServiceManager.getService("isub") == null) {
ServiceManager.addService("isub", this);
}
+ mContext.registerReceiver(mReceiver,
+ new IntentFilter(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION));
if (DBG) logdl("[SubscriptionController] init by Context");
}
@@ -211,6 +241,8 @@
if(ServiceManager.getService("isub") == null) {
ServiceManager.addService("isub", this);
}
+ mContext.registerReceiver(mReceiver,
+ new IntentFilter(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION));
if (DBG) logdl("[SubscriptionController] init by Phone");
}
@@ -727,6 +759,26 @@
}
/**
+ * Set carrier text by simInfo index
+ * @param text new carrier text
+ * @param subId the unique SubInfoRecord index in database
+ * @return the number of records updated
+ */
+ private int setCarrierText(String text, int subId) {
+ if (DBG) logd("[setCarrierText]+ text:" + text + " subId:" + subId);
+ enforceSubscriptionPermission();
+
+ ContentValues value = new ContentValues(1);
+ value.put(SubscriptionManager.CARRIER_NAME, text);
+
+ int result = mContext.getContentResolver().update(SubscriptionManager.CONTENT_URI, value,
+ SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=" + Long.toString(subId), null);
+ notifySubscriptionInfoChanged();
+
+ return result;
+ }
+
+ /**
* Set SIM color tint by simInfo index
* @param tint the tint color of the SIM
* @param subId the unique SubInfoRecord index in database