diff options
author | Sridhar Dubbaka <sdubbaka@codeaurora.org> | 2015-09-11 15:01:53 +0530 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-07-01 05:06:31 -0700 |
commit | 9d5aa27f688b0d12e749bd693a6040adc836623e (patch) | |
tree | 0e1660625609c1c4dbcb594ccdaf100392475ef0 | |
parent | 7a760133672874bf4668b6c13a6d6e23e1e9470d (diff) | |
download | android_packages_apps_CellBroadcastReceiver-9d5aa27f688b0d12e749bd693a6040adc836623e.tar.gz android_packages_apps_CellBroadcastReceiver-9d5aa27f688b0d12e749bd693a6040adc836623e.tar.bz2 android_packages_apps_CellBroadcastReceiver-9d5aa27f688b0d12e749bd693a6040adc836623e.zip |
Add Msim support for Service State intent in CB receiver
Currently, Cellbroadcast message ids are configured for
defaultsmsSubId only.With this change,CB message ids are
configured for both subs, if they are in IN service.
Change-Id: I13facf694daacc56f717d1e08144097f05d034e7
-rw-r--r-- | src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java index 548a07a2..b58ba716 100644 --- a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java +++ b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java @@ -46,8 +46,8 @@ import java.util.List; public class CellBroadcastReceiver extends BroadcastReceiver { private static final String TAG = "CellBroadcastReceiver"; - static final boolean DBG = false; // STOPSHIP: change to false before ship - private static int mServiceState = -1; + static final boolean DBG = true; // STOPSHIP: change to false before ship + private int[] mServiceState = null; private static final String GET_LATEST_CB_AREA_INFO_ACTION = "android.cellbroadcastreceiver.GET_LATEST_CB_AREA_INFO"; @@ -63,22 +63,36 @@ public class CellBroadcastReceiver extends BroadcastReceiver { if (TelephonyIntents.ACTION_SERVICE_STATE_CHANGED.equals(action)) { if (DBG) log("Intent ACTION_SERVICE_STATE_CHANGED"); - int subId = intent.getExtras().getInt(PhoneConstants.SUBSCRIPTION_KEY); + int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, + SubscriptionManager.INVALID_SUBSCRIPTION_ID); Log.d(TAG, "subscriptionId = " + subId); if (!SubscriptionManager.isValidSubscriptionId(subId)) { return; } ServiceState serviceState = ServiceState.newFromBundle(intent.getExtras()); int newState = serviceState.getState(); - if (newState != mServiceState) { + SubscriptionInfo subInfo = SubscriptionManager.from(context). + getActiveSubscriptionInfo(subId); + if (subInfo == null) { + loge("subId is not active:" + subId); + return; + } + int slotId = subInfo.getSimSlotIndex(); + if (mServiceState == null) { + int phoneCount = TelephonyManager.getDefault().getPhoneCount(); + mServiceState = new int[phoneCount]; + for (int i = 0; i < phoneCount; i++) { + mServiceState[i] = ServiceState.STATE_OUT_OF_SERVICE; + } + } + if (newState != mServiceState[slotId]) { Log.d(TAG, "Service state changed! " + newState + " Full: " + serviceState + - " Current state=" + mServiceState); - mServiceState = newState; - + " Current state=" + mServiceState[slotId]); + mServiceState[slotId] = newState; if (((newState == ServiceState.STATE_IN_SERVICE) || (newState == ServiceState.STATE_EMERGENCY_ONLY)) && (UserHandle.myUserId() == UserHandle.USER_OWNER)) { - startConfigService(context.getApplicationContext(), subId); + startConfigService(context.getApplicationContext(), slotId);; } } } else if (IccCardProxy.ACTION_INTERNAL_SIM_STATE_CHANGED.equals(action)){ |