Merge "Match phoneId in the record if the subId is invalid" into sc-v2-dev

This commit is contained in:
Hui Wang
2021-09-29 16:46:15 +00:00
committed by Android (Google) Code Review

View File

@@ -1025,7 +1025,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();
@@ -1048,21 +1047,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)) {
@@ -1078,8 +1080,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));
@@ -1092,7 +1094,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);
} }
@@ -1101,7 +1103,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);
} }
@@ -1109,11 +1111,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);
@@ -1121,38 +1123,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);
@@ -1162,8 +1164,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);
@@ -1172,11 +1174,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);
@@ -1184,22 +1188,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);
} }
@@ -1208,7 +1212,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) {
@@ -1225,29 +1229,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);
@@ -1284,20 +1288,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);
@@ -1315,8 +1319,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);
} }
@@ -1325,7 +1329,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);
} }
@@ -1333,9 +1337,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);
@@ -1577,7 +1581,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;
@@ -1639,7 +1643,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
@@ -1650,7 +1654,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
@@ -1692,7 +1696,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
@@ -1706,7 +1710,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);
@@ -1753,7 +1757,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) {
@@ -1785,7 +1789,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 {
@@ -1819,7 +1823,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) {
@@ -1846,7 +1850,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) {
@@ -1885,7 +1889,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())) {
@@ -1937,7 +1941,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) {
@@ -1966,7 +1970,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) {
@@ -2014,7 +2018,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);
@@ -2039,7 +2043,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) {
@@ -2086,7 +2090,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 {
@@ -2140,7 +2144,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) {
@@ -2149,7 +2153,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) {
@@ -2174,7 +2178,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]);
@@ -2199,7 +2203,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="
@@ -2231,7 +2235,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);
@@ -2260,7 +2264,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) {
@@ -2340,7 +2344,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) {
@@ -2369,7 +2373,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) {
@@ -2456,7 +2460,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) {
@@ -2487,7 +2491,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)
@@ -2530,7 +2534,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="
@@ -2575,7 +2579,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="
@@ -2642,7 +2646,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) {
@@ -2677,7 +2681,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
@@ -2719,7 +2723,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) {
@@ -3169,33 +3173,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);
} }
} }