summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHall Liu <hallliu@google.com>2020-09-11 13:32:16 -0700
committerHall Liu <hallliu@google.com>2020-10-22 11:34:28 -0700
commitadfc80c4d5f0cb514c34e519032c4e61e4d90ad9 (patch)
tree5db852026fafdc29c14f3ca533388dfcf661d4fa
parent3a14c6bdcc973838660dd7eb89302e349b39daec (diff)
Update PhoneStateListener#onOutgoingEmergencySms
Update the callback for emergency SMS to follow the same pattern as for emergency calls for API consistency. Fixes: 168269065 Test: atest CtsTelephonyTestCases:PhoneStateListenerTest Change-Id: If27771aef1858ea92dd620b56368d1a6a4f61ab3 Merged-In: If27771aef1858ea92dd620b56368d1a6a4f61ab3
-rwxr-xr-xapi/system-current.txt3
-rw-r--r--api/test-current.txt2
-rw-r--r--core/java/android/telephony/PhoneStateListener.java33
-rw-r--r--core/java/com/android/internal/telephony/IPhoneStateListener.aidl2
-rw-r--r--non-updatable-api/system-current.txt3
-rw-r--r--services/core/java/com/android/server/TelephonyRegistry.java6
6 files changed, 41 insertions, 8 deletions
diff --git a/api/system-current.txt b/api/system-current.txt
index e81f6d4c031d..37ce4cfcfc3e 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -10816,7 +10816,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 @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onPreciseCallStateChanged(@NonNull android.telephony.PreciseCallState);
method public void onRadioPowerStateChanged(int);
method public void onSrvccStateChanged(int);
diff --git a/api/test-current.txt b/api/test-current.txt
index 6fac6c18746a..93f9e2c907d6 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -1629,6 +1629,8 @@ package android.telephony {
public class PhoneStateListener {
method public void onOutgoingEmergencyCall(@NonNull android.telephony.emergency.EmergencyNumber, int);
+ method @Deprecated public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber);
+ method public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber, int);
}
public final class PreciseDataConnectionState implements android.os.Parcelable {
diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java
index 1ef52e21d652..0896f574cc46 100644
--- a/core/java/android/telephony/PhoneStateListener.java
+++ b/core/java/android/telephony/PhoneStateListener.java
@@ -991,15 +991,43 @@ 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
* PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}.
@@ -1376,13 +1404,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 d41d30735d7d..d2dc7c283ff7 100644
--- a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl
+++ b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl
@@ -62,7 +62,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 e48195e47a29..b39527bba368 100644
--- a/non-updatable-api/system-current.txt
+++ b/non-updatable-api/system-current.txt
@@ -9698,7 +9698,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 @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onPreciseCallStateChanged(@NonNull android.telephony.PreciseCallState);
method public void onRadioPowerStateChanged(int);
method public void onSrvccStateChanged(int);
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 4851c5547f7e..8cc5feafb729 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -2127,11 +2127,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);
}