diff --git a/api/system-current.txt b/api/system-current.txt index 4134711035e5d..5ea77ed930e24 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -10902,7 +10902,8 @@ package android.telephony { method public void onCallAttributesChanged(@NonNull android.telephony.CallAttributes); method @Deprecated public void onOutgoingEmergencyCall(@NonNull android.telephony.emergency.EmergencyNumber); method public void onOutgoingEmergencyCall(@NonNull android.telephony.emergency.EmergencyNumber, int); - method public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber); + method @Deprecated public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber); + method public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber, int); method public void onPhysicalChannelConfigurationChanged(@NonNull java.util.List); method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onPreciseCallStateChanged(@NonNull android.telephony.PreciseCallState); method public void onRadioPowerStateChanged(int); diff --git a/api/test-current.txt b/api/test-current.txt index de2919b8936a4..46d8e41527189 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -4137,7 +4137,8 @@ package android.telephony { public class PhoneStateListener { method @Deprecated public void onOutgoingEmergencyCall(@NonNull android.telephony.emergency.EmergencyNumber); method public void onOutgoingEmergencyCall(@NonNull android.telephony.emergency.EmergencyNumber, int); - method public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber); + method @Deprecated public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber); + method public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber, int); field @RequiresPermission("android.permission.READ_ACTIVE_EMERGENCY_SESSION") public static final int LISTEN_OUTGOING_EMERGENCY_CALL = 268435456; // 0x10000000 field @RequiresPermission("android.permission.READ_ACTIVE_EMERGENCY_SESSION") public static final int LISTEN_OUTGOING_EMERGENCY_SMS = 536870912; // 0x20000000 } diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java index 8f31d77ac1800..16826865987e5 100644 --- a/core/java/android/telephony/PhoneStateListener.java +++ b/core/java/android/telephony/PhoneStateListener.java @@ -1001,15 +1001,42 @@ public class PhoneStateListener { /** * Callback invoked when an outgoing SMS is placed to an emergency number. * + * This method will be called when an emergency sms is sent on any subscription. * @param sentEmergencyNumber the emergency number {@link EmergencyNumber} the SMS is sent to. + * + * @deprecated Use {@link #onOutgoingEmergencySms(EmergencyNumber, int)}. * @hide */ @SystemApi @TestApi + @Deprecated public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber) { // default implementation empty } + /** + * Smsback invoked when an outgoing sms is sent to an emergency number. + * + * This method will be called when an emergency sms is sent on any subscription, + * regardless of which subscription this listener was registered on. + * + * The default implementation of this method calls + * {@link #onOutgoingEmergencySms(EmergencyNumber)} for backwards compatibility purposes. Do + * not call {@code super(...)} from within your implementation unless you want + * {@link #onOutgoingEmergencySms(EmergencyNumber)} to be called as well. + * + * @param sentEmergencyNumber The {@link EmergencyNumber} the emergency sms was sent to. + * @param subscriptionId The subscription ID used to send the emergency sms. + * @hide + */ + @SystemApi + @TestApi + public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber, + int subscriptionId) { + // Default implementation for backwards compatibility + onOutgoingEmergencySms(sentEmergencyNumber); + } + /** * Callback invoked when OEM hook raw event is received on the registered subscription. * Note, the registration subId comes from {@link TelephonyManager} object which registers @@ -1399,13 +1426,14 @@ public class PhoneStateListener { subscriptionId))); } - public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber) { + public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber, + int subscriptionId) { PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); if (psl == null) return; Binder.withCleanCallingIdentity( () -> mExecutor.execute( - () -> psl.onOutgoingEmergencySms(sentEmergencyNumber))); + () -> psl.onOutgoingEmergencySms(sentEmergencyNumber, subscriptionId))); } public void onPhoneCapabilityChanged(PhoneCapability capability) { diff --git a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl index 25d1ae699aa63..44dca9bae3dab 100644 --- a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -63,7 +63,7 @@ oneway interface IPhoneStateListener { void onCallAttributesChanged(in CallAttributes callAttributes); void onEmergencyNumberListChanged(in Map emergencyNumberList); void onOutgoingEmergencyCall(in EmergencyNumber placedEmergencyNumber, int subscriptionId); - void onOutgoingEmergencySms(in EmergencyNumber sentEmergencyNumber); + void onOutgoingEmergencySms(in EmergencyNumber sentEmergencyNumber, int subscriptionId); void onCallDisconnectCauseChanged(in int disconnectCause, in int preciseDisconnectCause); void onImsCallDisconnectCauseChanged(in ImsReasonInfo imsReasonInfo); void onRegistrationFailed(in CellIdentity cellIdentity, diff --git a/non-updatable-api/system-current.txt b/non-updatable-api/system-current.txt index 8fae240a95b43..14366a43ab638 100644 --- a/non-updatable-api/system-current.txt +++ b/non-updatable-api/system-current.txt @@ -9766,7 +9766,8 @@ package android.telephony { method public void onCallAttributesChanged(@NonNull android.telephony.CallAttributes); method @Deprecated public void onOutgoingEmergencyCall(@NonNull android.telephony.emergency.EmergencyNumber); method public void onOutgoingEmergencyCall(@NonNull android.telephony.emergency.EmergencyNumber, int); - method public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber); + method @Deprecated public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber); + method public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber, int); method public void onPhysicalChannelConfigurationChanged(@NonNull java.util.List); method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onPreciseCallStateChanged(@NonNull android.telephony.PreciseCallState); method public void onRadioPowerStateChanged(int); diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index e433fbd94d4f0..930eea0de32c9 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -2149,11 +2149,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { if (validatePhoneId(phoneId)) { mOutgoingSmsEmergencyNumber[phoneId] = emergencyNumber; for (Record r : mRecords) { + // Send to all listeners regardless of subscription if (r.matchPhoneStateListenerEvent( - PhoneStateListener.LISTEN_OUTGOING_EMERGENCY_SMS) - && idMatch(r.subId, subId, phoneId)) { + PhoneStateListener.LISTEN_OUTGOING_EMERGENCY_SMS)) { try { - r.callback.onOutgoingEmergencySms(emergencyNumber); + r.callback.onOutgoingEmergencySms(emergencyNumber, subId); } catch (RemoteException ex) { mRemoveList.add(r.binder); }