Merge "Match phoneId in the record if the subId is invalid"

This commit is contained in:
Hui Wang
2021-10-27 02:35:52 +00:00
committed by Gerrit Code Review

View File

@@ -1029,7 +1029,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
return; return;
} }
int phoneId = getPhoneIdFromSubId(subId);
synchronized (mRecords) { synchronized (mRecords) {
// register // register
IBinder b = callback.asBinder(); IBinder b = callback.asBinder();
@@ -1052,21 +1051,24 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
// Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID, // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
// force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
if (!SubscriptionManager.isValidSubscriptionId(subId)) { if (!SubscriptionManager.isValidSubscriptionId(subId)) {
if (DBG) {
log("invalid subscription id, use default id");
}
r.subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; r.subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
} else {//APP specify subID } else {//APP specify subID
r.subId = subId; r.subId = subId;
} }
r.phoneId = phoneId; r.phoneId = getPhoneIdFromSubId(r.subId);
r.eventList = events; r.eventList = events;
if (DBG) { if (DBG) {
log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId); log("listen: Register r=" + r + " r.subId=" + r.subId + " r.phoneId=" + r.phoneId);
} }
if (notifyNow && validatePhoneId(phoneId)) { if (notifyNow && validatePhoneId(r.phoneId)) {
if (events.contains(TelephonyCallback.EVENT_SERVICE_STATE_CHANGED)){ if (events.contains(TelephonyCallback.EVENT_SERVICE_STATE_CHANGED)){
try { try {
if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]); if (VDBG) log("listen: call onSSC state=" + mServiceState[r.phoneId]);
ServiceState rawSs = new ServiceState(mServiceState[phoneId]); ServiceState rawSs = new ServiceState(mServiceState[r.phoneId]);
if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
r.callback.onServiceStateChanged(rawSs); r.callback.onServiceStateChanged(rawSs);
} else if (checkCoarseLocationAccess(r, Build.VERSION_CODES.Q)) { } else if (checkCoarseLocationAccess(r, Build.VERSION_CODES.Q)) {
@@ -1082,8 +1084,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
if (events.contains(TelephonyCallback.EVENT_SIGNAL_STRENGTH_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_SIGNAL_STRENGTH_CHANGED)) {
try { try {
if (mSignalStrength[phoneId] != null) { if (mSignalStrength[r.phoneId] != null) {
int gsmSignalStrength = mSignalStrength[phoneId] int gsmSignalStrength = mSignalStrength[r.phoneId]
.getGsmSignalStrength(); .getGsmSignalStrength();
r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
: gsmSignalStrength)); : gsmSignalStrength));
@@ -1096,7 +1098,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
TelephonyCallback.EVENT_MESSAGE_WAITING_INDICATOR_CHANGED)) { TelephonyCallback.EVENT_MESSAGE_WAITING_INDICATOR_CHANGED)) {
try { try {
r.callback.onMessageWaitingIndicatorChanged( r.callback.onMessageWaitingIndicatorChanged(
mMessageWaiting[phoneId]); mMessageWaiting[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
@@ -1105,7 +1107,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
TelephonyCallback.EVENT_CALL_FORWARDING_INDICATOR_CHANGED)) { TelephonyCallback.EVENT_CALL_FORWARDING_INDICATOR_CHANGED)) {
try { try {
r.callback.onCallForwardingIndicatorChanged( r.callback.onCallForwardingIndicatorChanged(
mCallForwarding[phoneId]); mCallForwarding[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
@@ -1113,11 +1115,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
if (validateEventAndUserLocked( if (validateEventAndUserLocked(
r, TelephonyCallback.EVENT_CELL_LOCATION_CHANGED)) { r, TelephonyCallback.EVENT_CELL_LOCATION_CHANGED)) {
try { try {
if (DBG_LOC) log("listen: mCellIdentity = " + mCellIdentity[phoneId]); if (DBG_LOC) log("listen: mCellIdentity = " + mCellIdentity[r.phoneId]);
if (checkCoarseLocationAccess(r, Build.VERSION_CODES.BASE) if (checkCoarseLocationAccess(r, Build.VERSION_CODES.BASE)
&& checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { && checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
// null will be translated to empty CellLocation object in client. // null will be translated to empty CellLocation object in client.
r.callback.onCellLocationChanged(mCellIdentity[phoneId]); r.callback.onCellLocationChanged(mCellIdentity[r.phoneId]);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
@@ -1125,38 +1127,38 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
if (events.contains(TelephonyCallback.EVENT_LEGACY_CALL_STATE_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_LEGACY_CALL_STATE_CHANGED)) {
try { try {
r.callback.onLegacyCallStateChanged(mCallState[phoneId], r.callback.onLegacyCallStateChanged(mCallState[r.phoneId],
getCallIncomingNumber(r, phoneId)); getCallIncomingNumber(r, r.phoneId));
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_CALL_STATE_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_CALL_STATE_CHANGED)) {
try { try {
r.callback.onCallStateChanged(mCallState[phoneId]); r.callback.onCallStateChanged(mCallState[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_DATA_CONNECTION_STATE_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_DATA_CONNECTION_STATE_CHANGED)) {
try { try {
r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], r.callback.onDataConnectionStateChanged(mDataConnectionState[r.phoneId],
mDataConnectionNetworkType[phoneId]); mDataConnectionNetworkType[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_DATA_ACTIVITY_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_DATA_ACTIVITY_CHANGED)) {
try { try {
r.callback.onDataActivity(mDataActivity[phoneId]); r.callback.onDataActivity(mDataActivity[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED)) {
try { try {
if (mSignalStrength[phoneId] != null) { if (mSignalStrength[r.phoneId] != null) {
r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]); r.callback.onSignalStrengthsChanged(mSignalStrength[r.phoneId]);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
@@ -1166,8 +1168,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED)) { TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED)) {
updateReportSignalStrengthDecision(r.subId); updateReportSignalStrengthDecision(r.subId);
try { try {
if (mSignalStrength[phoneId] != null) { if (mSignalStrength[r.phoneId] != null) {
r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]); r.callback.onSignalStrengthsChanged(mSignalStrength[r.phoneId]);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
@@ -1176,11 +1178,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
if (validateEventAndUserLocked( if (validateEventAndUserLocked(
r, TelephonyCallback.EVENT_CELL_INFO_CHANGED)) { r, TelephonyCallback.EVENT_CELL_INFO_CHANGED)) {
try { try {
if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = " if (DBG_LOC) {
+ mCellInfo.get(phoneId)); log("listen: mCellInfo[" + r.phoneId + "] = "
+ mCellInfo.get(r.phoneId));
}
if (checkCoarseLocationAccess(r, Build.VERSION_CODES.BASE) if (checkCoarseLocationAccess(r, Build.VERSION_CODES.BASE)
&& checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { && checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
r.callback.onCellInfoChanged(mCellInfo.get(phoneId)); r.callback.onCellInfoChanged(mCellInfo.get(r.phoneId));
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
@@ -1188,22 +1192,22 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
if (events.contains(TelephonyCallback.EVENT_PRECISE_CALL_STATE_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_PRECISE_CALL_STATE_CHANGED)) {
try { try {
r.callback.onPreciseCallStateChanged(mPreciseCallState[phoneId]); r.callback.onPreciseCallStateChanged(mPreciseCallState[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_CALL_DISCONNECT_CAUSE_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_CALL_DISCONNECT_CAUSE_CHANGED)) {
try { try {
r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause[phoneId], r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause[r.phoneId],
mCallPreciseDisconnectCause[phoneId]); mCallPreciseDisconnectCause[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_IMS_CALL_DISCONNECT_CAUSE_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_IMS_CALL_DISCONNECT_CAUSE_CHANGED)) {
try { try {
r.callback.onImsCallDisconnectCauseChanged(mImsReasonInfo.get(phoneId)); r.callback.onImsCallDisconnectCauseChanged(mImsReasonInfo.get(r.phoneId));
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
@@ -1212,7 +1216,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
TelephonyCallback.EVENT_PRECISE_DATA_CONNECTION_STATE_CHANGED)) { TelephonyCallback.EVENT_PRECISE_DATA_CONNECTION_STATE_CHANGED)) {
try { try {
for (PreciseDataConnectionState pdcs for (PreciseDataConnectionState pdcs
: mPreciseDataConnectionStates.get(phoneId).values()) { : mPreciseDataConnectionStates.get(r.phoneId).values()) {
r.callback.onPreciseDataConnectionStateChanged(pdcs); r.callback.onPreciseDataConnectionStateChanged(pdcs);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -1229,29 +1233,29 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
if (events.contains(TelephonyCallback.EVENT_VOICE_ACTIVATION_STATE_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_VOICE_ACTIVATION_STATE_CHANGED)) {
try { try {
r.callback.onVoiceActivationStateChanged( r.callback.onVoiceActivationStateChanged(
mVoiceActivationState[phoneId]); mVoiceActivationState[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_DATA_ACTIVATION_STATE_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_DATA_ACTIVATION_STATE_CHANGED)) {
try { try {
r.callback.onDataActivationStateChanged(mDataActivationState[phoneId]); r.callback.onDataActivationStateChanged(mDataActivationState[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_USER_MOBILE_DATA_STATE_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_USER_MOBILE_DATA_STATE_CHANGED)) {
try { try {
r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]); r.callback.onUserMobileDataStateChanged(mUserMobileDataState[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED)) {
try { try {
if (mTelephonyDisplayInfos[phoneId] != null) { if (mTelephonyDisplayInfos[r.phoneId] != null) {
r.callback.onDisplayInfoChanged(mTelephonyDisplayInfos[phoneId]); r.callback.onDisplayInfoChanged(mTelephonyDisplayInfos[r.phoneId]);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
@@ -1288,20 +1292,20 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
if (events.contains(TelephonyCallback.EVENT_SRVCC_STATE_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_SRVCC_STATE_CHANGED)) {
try { try {
r.callback.onSrvccStateChanged(mSrvccState[phoneId]); r.callback.onSrvccStateChanged(mSrvccState[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_CALL_ATTRIBUTES_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_CALL_ATTRIBUTES_CHANGED)) {
try { try {
r.callback.onCallAttributesChanged(mCallAttributes[phoneId]); r.callback.onCallAttributesChanged(mCallAttributes[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
} }
if (events.contains(TelephonyCallback.EVENT_BARRING_INFO_CHANGED)) { if (events.contains(TelephonyCallback.EVENT_BARRING_INFO_CHANGED)) {
BarringInfo barringInfo = mBarringInfo.get(phoneId); BarringInfo barringInfo = mBarringInfo.get(r.phoneId);
BarringInfo biNoLocation = barringInfo != null BarringInfo biNoLocation = barringInfo != null
? barringInfo.createLocationInfoSanitizedCopy() : null; ? barringInfo.createLocationInfoSanitizedCopy() : null;
if (VDBG) log("listen: call onBarringInfoChanged=" + barringInfo); if (VDBG) log("listen: call onBarringInfoChanged=" + barringInfo);
@@ -1319,8 +1323,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
r.callback.onPhysicalChannelConfigChanged( r.callback.onPhysicalChannelConfigChanged(
shouldSanitizeLocationForPhysicalChannelConfig(r) shouldSanitizeLocationForPhysicalChannelConfig(r)
? getLocationSanitizedConfigs( ? getLocationSanitizedConfigs(
mPhysicalChannelConfigs.get(phoneId)) mPhysicalChannelConfigs.get(r.phoneId))
: mPhysicalChannelConfigs.get(phoneId)); : mPhysicalChannelConfigs.get(r.phoneId));
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
@@ -1329,7 +1333,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
TelephonyCallback.EVENT_DATA_ENABLED_CHANGED)) { TelephonyCallback.EVENT_DATA_ENABLED_CHANGED)) {
try { try {
r.callback.onDataEnabledChanged( r.callback.onDataEnabledChanged(
mIsDataEnabled[phoneId], mDataEnabledReason[phoneId]); mIsDataEnabled[r.phoneId], mDataEnabledReason[r.phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
} }
@@ -1337,9 +1341,9 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
if (events.contains( if (events.contains(
TelephonyCallback.EVENT_LINK_CAPACITY_ESTIMATE_CHANGED)) { TelephonyCallback.EVENT_LINK_CAPACITY_ESTIMATE_CHANGED)) {
try { try {
if (mLinkCapacityEstimateLists.get(phoneId) != null) { if (mLinkCapacityEstimateLists.get(r.phoneId) != null) {
r.callback.onLinkCapacityEstimateChanged(mLinkCapacityEstimateLists r.callback.onLinkCapacityEstimateChanged(mLinkCapacityEstimateLists
.get(phoneId)); .get(r.phoneId));
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
@@ -1581,7 +1585,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_SERVICE_STATE_CHANGED) TelephonyCallback.EVENT_SERVICE_STATE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
ServiceState stateToSend; ServiceState stateToSend;
@@ -1643,7 +1647,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
if ((activationType == SIM_ACTIVATION_TYPE_VOICE) if ((activationType == SIM_ACTIVATION_TYPE_VOICE)
&& r.matchTelephonyCallbackEvent( && r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_VOICE_ACTIVATION_STATE_CHANGED) TelephonyCallback.EVENT_VOICE_ACTIVATION_STATE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
if (DBG) { if (DBG) {
log("notifyVoiceActivationStateForPhoneId: callback.onVASC r=" + r log("notifyVoiceActivationStateForPhoneId: callback.onVASC r=" + r
+ " subId=" + subId + " phoneId=" + phoneId + " subId=" + subId + " phoneId=" + phoneId
@@ -1654,7 +1658,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
if ((activationType == SIM_ACTIVATION_TYPE_DATA) if ((activationType == SIM_ACTIVATION_TYPE_DATA)
&& r.matchTelephonyCallbackEvent( && r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_DATA_ACTIVATION_STATE_CHANGED) TelephonyCallback.EVENT_DATA_ACTIVATION_STATE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
if (DBG) { if (DBG) {
log("notifyDataActivationStateForPhoneId: callback.onDASC r=" + r log("notifyDataActivationStateForPhoneId: callback.onDASC r=" + r
+ " subId=" + subId + " phoneId=" + phoneId + " subId=" + subId + " phoneId=" + phoneId
@@ -1696,7 +1700,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED) TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED)
|| r.matchTelephonyCallbackEvent( || r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED)) TelephonyCallback.EVENT_ALWAYS_REPORTED_SIGNAL_STRENGTH_CHANGED))
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
if (DBG) { if (DBG) {
log("notifySignalStrengthForPhoneId: callback.onSsS r=" + r log("notifySignalStrengthForPhoneId: callback.onSsS r=" + r
@@ -1710,7 +1714,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_SIGNAL_STRENGTH_CHANGED) TelephonyCallback.EVENT_SIGNAL_STRENGTH_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
int gsmSignalStrength = signalStrength.getGsmSignalStrength(); int gsmSignalStrength = signalStrength.getGsmSignalStrength();
int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength); int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
@@ -1757,7 +1761,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_CARRIER_NETWORK_CHANGED) TelephonyCallback.EVENT_CARRIER_NETWORK_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onCarrierNetworkChange(active); r.callback.onCarrierNetworkChange(active);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -1789,7 +1793,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (validateEventAndUserLocked( if (validateEventAndUserLocked(
r, TelephonyCallback.EVENT_CELL_INFO_CHANGED) r, TelephonyCallback.EVENT_CELL_INFO_CHANGED)
&& idMatch(r.subId, subId, phoneId) && idMatch(r, subId, phoneId)
&& (checkCoarseLocationAccess(r, Build.VERSION_CODES.BASE) && (checkCoarseLocationAccess(r, Build.VERSION_CODES.BASE)
&& checkFineLocationAccess(r, Build.VERSION_CODES.Q))) { && checkFineLocationAccess(r, Build.VERSION_CODES.Q))) {
try { try {
@@ -1823,7 +1827,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_MESSAGE_WAITING_INDICATOR_CHANGED) TelephonyCallback.EVENT_MESSAGE_WAITING_INDICATOR_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onMessageWaitingIndicatorChanged(mwi); r.callback.onMessageWaitingIndicatorChanged(mwi);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -1850,7 +1854,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_USER_MOBILE_DATA_STATE_CHANGED) TelephonyCallback.EVENT_USER_MOBILE_DATA_STATE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onUserMobileDataStateChanged(state); r.callback.onUserMobileDataStateChanged(state);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -1889,7 +1893,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED) TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED)
&& idMatchWithoutDefaultPhoneCheck(r.subId, subId)) { && idMatch(r, subId, phoneId)) {
try { try {
if (!mConfigurationProvider.isDisplayInfoNrAdvancedSupported( if (!mConfigurationProvider.isDisplayInfoNrAdvancedSupported(
r.callingPackage, Binder.getCallingUserHandle())) { r.callingPackage, Binder.getCallingUserHandle())) {
@@ -1940,7 +1944,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_CALL_FORWARDING_INDICATOR_CHANGED) TelephonyCallback.EVENT_CALL_FORWARDING_INDICATOR_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onCallForwardingIndicatorChanged(cfi); r.callback.onCallForwardingIndicatorChanged(cfi);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -1969,7 +1973,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
// Notify by correct subId. // Notify by correct subId.
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_DATA_ACTIVITY_CHANGED) TelephonyCallback.EVENT_DATA_ACTIVITY_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onDataActivity(state); r.callback.onDataActivity(state);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -2017,7 +2021,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_DATA_CONNECTION_STATE_CHANGED) TelephonyCallback.EVENT_DATA_CONNECTION_STATE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
if (DBG) { if (DBG) {
log("Notify data connection state changed on sub: " + subId); log("Notify data connection state changed on sub: " + subId);
@@ -2042,7 +2046,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_PRECISE_DATA_CONNECTION_STATE_CHANGED) TelephonyCallback.EVENT_PRECISE_DATA_CONNECTION_STATE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onPreciseDataConnectionStateChanged(preciseState); r.callback.onPreciseDataConnectionStateChanged(preciseState);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -2089,7 +2093,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (validateEventAndUserLocked( if (validateEventAndUserLocked(
r, TelephonyCallback.EVENT_CELL_LOCATION_CHANGED) r, TelephonyCallback.EVENT_CELL_LOCATION_CHANGED)
&& idMatch(r.subId, subId, phoneId) && idMatch(r, subId, phoneId)
&& (checkCoarseLocationAccess(r, Build.VERSION_CODES.BASE) && (checkCoarseLocationAccess(r, Build.VERSION_CODES.BASE)
&& checkFineLocationAccess(r, Build.VERSION_CODES.Q))) { && checkFineLocationAccess(r, Build.VERSION_CODES.Q))) {
try { try {
@@ -2143,7 +2147,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_PRECISE_CALL_STATE_CHANGED) TelephonyCallback.EVENT_PRECISE_CALL_STATE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onPreciseCallStateChanged(mPreciseCallState[phoneId]); r.callback.onPreciseCallStateChanged(mPreciseCallState[phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -2152,7 +2156,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
if (notifyCallAttributes && r.matchTelephonyCallbackEvent( if (notifyCallAttributes && r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_CALL_ATTRIBUTES_CHANGED) TelephonyCallback.EVENT_CALL_ATTRIBUTES_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onCallAttributesChanged(mCallAttributes[phoneId]); r.callback.onCallAttributesChanged(mCallAttributes[phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -2177,7 +2181,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_CALL_DISCONNECT_CAUSE_CHANGED) TelephonyCallback.EVENT_CALL_DISCONNECT_CAUSE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause[phoneId], r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause[phoneId],
mCallPreciseDisconnectCause[phoneId]); mCallPreciseDisconnectCause[phoneId]);
@@ -2202,7 +2206,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_IMS_CALL_DISCONNECT_CAUSE_CHANGED) TelephonyCallback.EVENT_IMS_CALL_DISCONNECT_CAUSE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
if (DBG_LOC) { if (DBG_LOC) {
log("notifyImsCallDisconnectCause: mImsReasonInfo=" log("notifyImsCallDisconnectCause: mImsReasonInfo="
@@ -2234,7 +2238,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_SRVCC_STATE_CHANGED) TelephonyCallback.EVENT_SRVCC_STATE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
if (DBG_LOC) { if (DBG_LOC) {
log("notifySrvccStateChanged: mSrvccState=" + state + " r=" + r); log("notifySrvccStateChanged: mSrvccState=" + state + " r=" + r);
@@ -2263,7 +2267,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
if ((r.matchTelephonyCallbackEvent( if ((r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_OEM_HOOK_RAW)) TelephonyCallback.EVENT_OEM_HOOK_RAW))
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onOemHookRawEvent(rawData); r.callback.onOemHookRawEvent(rawData);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -2343,7 +2347,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_RADIO_POWER_STATE_CHANGED) TelephonyCallback.EVENT_RADIO_POWER_STATE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onRadioPowerStateChanged(state); r.callback.onRadioPowerStateChanged(state);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -2372,7 +2376,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_EMERGENCY_NUMBER_LIST_CHANGED) TelephonyCallback.EVENT_EMERGENCY_NUMBER_LIST_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onEmergencyNumberListChanged(mEmergencyNumberList); r.callback.onEmergencyNumberListChanged(mEmergencyNumberList);
if (VDBG) { if (VDBG) {
@@ -2459,7 +2463,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_CALL_ATTRIBUTES_CHANGED) TelephonyCallback.EVENT_CALL_ATTRIBUTES_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onCallAttributesChanged(mCallAttributes[phoneId]); r.callback.onCallAttributesChanged(mCallAttributes[phoneId]);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -2490,7 +2494,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_REGISTRATION_FAILURE) TelephonyCallback.EVENT_REGISTRATION_FAILURE)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onRegistrationFailed( r.callback.onRegistrationFailed(
checkFineLocationAccess(r, Build.VERSION_CODES.BASE) checkFineLocationAccess(r, Build.VERSION_CODES.BASE)
@@ -2533,7 +2537,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_BARRING_INFO_CHANGED) TelephonyCallback.EVENT_BARRING_INFO_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
if (DBG_LOC) { if (DBG_LOC) {
log("notifyBarringInfo: mBarringInfo=" log("notifyBarringInfo: mBarringInfo="
@@ -2578,7 +2582,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED) TelephonyCallback.EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
if (DBG_LOC) { if (DBG_LOC) {
log("notifyPhysicalChannelConfig: mPhysicalChannelConfigs=" log("notifyPhysicalChannelConfig: mPhysicalChannelConfigs="
@@ -2645,7 +2649,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_DATA_ENABLED_CHANGED) TelephonyCallback.EVENT_DATA_ENABLED_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onDataEnabledChanged(enabled, reason); r.callback.onDataEnabledChanged(enabled, reason);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -2680,7 +2684,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_ALLOWED_NETWORK_TYPE_LIST_CHANGED) TelephonyCallback.EVENT_ALLOWED_NETWORK_TYPE_LIST_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
if (VDBG) { if (VDBG) {
log("notifyAllowedNetworkTypesChanged: reason= " + reason log("notifyAllowedNetworkTypesChanged: reason= " + reason
@@ -2722,7 +2726,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
for (Record r : mRecords) { for (Record r : mRecords) {
if (r.matchTelephonyCallbackEvent( if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_LINK_CAPACITY_ESTIMATE_CHANGED) TelephonyCallback.EVENT_LINK_CAPACITY_ESTIMATE_CHANGED)
&& idMatch(r.subId, subId, phoneId)) { && idMatch(r, subId, phoneId)) {
try { try {
r.callback.onLinkCapacityEstimateChanged(linkCapacityEstimateList); r.callback.onLinkCapacityEstimateChanged(linkCapacityEstimateList);
} catch (RemoteException ex) { } catch (RemoteException ex) {
@@ -3172,33 +3176,24 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
/** /**
* If the registrant specified a subId, then we should only notify it if subIds match. * Match the sub id or phone id of the event to the record
* If the registrant registered with DEFAULT subId, we should notify only when the related subId
* is default subId (which could be INVALID if there's no default subId).
* *
* This should be the correct way to check record ID match. in idMatch the record's phoneId is * We follow the rules below:
* speculated based on subId passed by the registrant so it's not a good reference. * 1) If sub id of the event is invalid, phone id should be used.
* But to avoid triggering potential regression only replace idMatch with it when an issue with * 2) The event on default sub should be notified to the records
* idMatch is reported. Eventually this should replace all instances of idMatch. * which register the default sub id.
* 3) Sub id should be exactly matched for all other cases.
*/ */
private boolean idMatchWithoutDefaultPhoneCheck(int subIdInRecord, int subIdToNotify) { boolean idMatch(Record r, int subId, int phoneId) {
if (subIdInRecord == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
return (subIdToNotify == mDefaultSubId);
} else {
return (subIdInRecord == subIdToNotify);
}
}
boolean idMatch(int rSubId, int subId, int phoneId) { if (subId < 0) {
// Invalid case, we need compare phoneId.
if(subId < 0) { return (r.phoneId == phoneId);
// Invalid case, we need compare phoneId with default one.
return (mDefaultPhoneId == phoneId);
} }
if(rSubId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { if (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
return (subId == mDefaultSubId); return (subId == mDefaultSubId);
} else { } else {
return (rSubId == subId); return (r.subId == subId);
} }
} }