Call onOutgoingEmergencyCall only once.

For backwards compatibility, instead of calling both the old and new
versions of onOutgoingEmergencyCall, only call the new version, and call
the old version from the default impl of the new version instead.

Change suggested by API council.

Bug: 166230518
Test: atest CtsTelecomTestCases:OutgoingCallTest
Change-Id: Ifa9276cc615d0e33d37ebc702dbc0cd155e0d489
This commit is contained in:
Hall Liu
2020-08-25 16:59:50 -07:00
parent e182543791
commit 486ef8978d

View File

@@ -948,10 +948,6 @@ public class PhoneStateListener {
* This method will be called when an emergency call is placed on any subscription (including * This method will be called when an emergency call is placed on any subscription (including
* the no-SIM case), regardless of which subscription this listener was registered on. * the no-SIM case), regardless of which subscription this listener was registered on.
* *
* This method is deprecated. Both this method and the new
* {@link #onOutgoingEmergencyCall(EmergencyNumber, int)} will be called when an outgoing
* emergency call is placed.
*
* @param placedEmergencyNumber The {@link EmergencyNumber} the emergency call was placed to. * @param placedEmergencyNumber The {@link EmergencyNumber} the emergency call was placed to.
* *
* @deprecated Use {@link #onOutgoingEmergencyCall(EmergencyNumber, int)}. * @deprecated Use {@link #onOutgoingEmergencyCall(EmergencyNumber, int)}.
@@ -969,22 +965,24 @@ public class PhoneStateListener {
* This method will be called when an emergency call is placed on any subscription (including * This method will be called when an emergency call is placed on any subscription (including
* the no-SIM case), regardless of which subscription this listener was registered on. * the no-SIM case), regardless of which subscription this listener was registered on.
* *
* Both this method and the deprecated {@link #onOutgoingEmergencyCall(EmergencyNumber)} will be * The default implementation of this method calls
* called when an outgoing emergency call is placed. You should only implement one of these * {@link #onOutgoingEmergencyCall(EmergencyNumber)} for backwards compatibility purposes. Do
* methods. * not call {@code super(...)} from within your implementation unless you want
* {@link #onOutgoingEmergencyCall(EmergencyNumber)} to be called as well.
* *
* @param placedEmergencyNumber The {@link EmergencyNumber} the emergency call was placed to. * @param placedEmergencyNumber The {@link EmergencyNumber} the emergency call was placed to.
* @param subscriptionId The subscription ID used to place the emergency call. If the * @param subscriptionId The subscription ID used to place the emergency call. If the
* emergency call was placed without a valid subscription (e.g. when there * emergency call was placed without a valid subscription (e.g. when there
* are no SIM cards in the device), this will be equal to * are no SIM cards in the device), this will be equal to
* {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}. * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}.
*
* @hide * @hide
*/ */
@SystemApi @SystemApi
@TestApi @TestApi
public void onOutgoingEmergencyCall(@NonNull EmergencyNumber placedEmergencyNumber, public void onOutgoingEmergencyCall(@NonNull EmergencyNumber placedEmergencyNumber,
int subscriptionId) { int subscriptionId) {
// Default implementation for backwards compatibility
onOutgoingEmergencyCall(placedEmergencyNumber);
} }
/** /**
@@ -1369,10 +1367,6 @@ public class PhoneStateListener {
PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); PhoneStateListener psl = mPhoneStateListenerWeakRef.get();
if (psl == null) return; if (psl == null) return;
Binder.withCleanCallingIdentity(
() -> mExecutor.execute(
() -> psl.onOutgoingEmergencyCall(placedEmergencyNumber)));
Binder.withCleanCallingIdentity( Binder.withCleanCallingIdentity(
() -> mExecutor.execute( () -> mExecutor.execute(
() -> psl.onOutgoingEmergencyCall(placedEmergencyNumber, () -> psl.onOutgoingEmergencyCall(placedEmergencyNumber,