Fixed crash when broadcasting any data intents
Fixed by reverting some of the code introduced in
ag/2163254
Test: Telephony sanity tests
bug: 37870433, 33482463
Merged-In: Iafd85f12f272a24605a7d42594c1a317567d4403
Change-Id: Iafd85f12f272a24605a7d42594c1a317567d4403
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 7a3683f..9ecb209 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -646,6 +646,7 @@
} else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ int phoneId = SubscriptionManager.getPhoneId(subId);
final String apnType = intent.getStringExtra(PhoneConstants.DATA_APN_TYPE_KEY);
final String state = intent.getStringExtra(PhoneConstants.STATE_KEY);
final String reason = intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY);
@@ -655,6 +656,8 @@
Log.d(LOG_TAG, "- reason: " + reason);
Log.d(LOG_TAG, "- subId: " + subId);
}
+ Phone phone = SubscriptionManager.isValidPhoneId(phoneId) ?
+ PhoneFactory.getPhone(phoneId) : PhoneFactory.getDefaultPhone();
// If the apn type of data connection state changed event is NOT default,
// ignore the broadcast intent and avoid action.
@@ -668,7 +671,7 @@
// (b) you just lost data connectivity because you're roaming.
if (PhoneConstants.DataState.DISCONNECTED.name().equals(state)
&& Phone.REASON_ROAMING_ON.equals(reason)
- && !getPhone(subId).getDataRoamingEnabled()) {
+ && !phone.getDataRoamingEnabled()) {
// Notify the user that data call is disconnected due to roaming. Note that
// calling this multiple times will not cause multiple notifications.
mHandler.sendEmptyMessage(EVENT_DATA_ROAMING_DISCONNECTED);