diff options
| -rw-r--r-- | api/system-current.txt | 3 | ||||
| -rw-r--r-- | core/res/AndroidManifest.xml | 6 | ||||
| -rw-r--r-- | telephony/java/android/telephony/PhoneStateListener.java | 68 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl | 2 |
4 files changed, 76 insertions, 3 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 355f3fe3a97f..326ac9435bf3 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -139,6 +139,7 @@ package android { field public static final String PROVIDE_RESOLVER_RANKER_SERVICE = "android.permission.PROVIDE_RESOLVER_RANKER_SERVICE"; field public static final String PROVIDE_TRUST_AGENT = "android.permission.PROVIDE_TRUST_AGENT"; field public static final String QUERY_TIME_ZONE_RULES = "android.permission.QUERY_TIME_ZONE_RULES"; + field public static final String READ_ACTIVE_EMERGENCY_SESSION = "android.permission.READ_ACTIVE_EMERGENCY_SESSION"; field public static final String READ_CELL_BROADCASTS = "android.permission.READ_CELL_BROADCASTS"; field public static final String READ_CONTENT_RATING_SYSTEMS = "android.permission.READ_CONTENT_RATING_SYSTEMS"; field public static final String READ_DEVICE_CONFIG = "android.permission.READ_DEVICE_CONFIG"; @@ -7758,6 +7759,8 @@ package android.telephony { field public static final int LISTEN_CALL_ATTRIBUTES_CHANGED = 67108864; // 0x4000000 field @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public static final int LISTEN_CALL_DISCONNECT_CAUSES = 33554432; // 0x2000000 field @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public static final int LISTEN_IMS_CALL_DISCONNECT_CAUSES = 134217728; // 0x8000000 + field @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public static final int LISTEN_OUTGOING_CALL_EMERGENCY_NUMBER = 268435456; // 0x10000000 + field @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public static final int LISTEN_OUTGOING_SMS_EMERGENCY_NUMBER = 536870912; // 0x20000000 field @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public static final int LISTEN_PRECISE_CALL_STATE = 2048; // 0x800 field @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 4096; // 0x1000 field public static final int LISTEN_RADIO_POWER_STATE_CHANGED = 8388608; // 0x800000 diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index e7e20fc41eee..847cbc3665c9 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2016,6 +2016,12 @@ <permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" android:protectionLevel="signature|privileged" /> + <!-- @SystemApi Allows read access to emergency number information for ongoing calls or SMS + sessions. + @hide Used internally. --> + <permission android:name="android.permission.READ_ACTIVE_EMERGENCY_SESSION" + android:protectionLevel="signature" /> + <!-- @SystemApi Protects the ability to register any PhoneAccount with PhoneAccount#CAPABILITY_SIM_SUBSCRIPTION. This capability indicates that the PhoneAccount corresponds to a device SIM. diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index 271195b78c3e..fe882ea74e76 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -33,13 +33,13 @@ import android.telephony.ims.ImsReasonInfo; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.IPhoneStateListener; +import dalvik.system.VMRuntime; + import java.lang.ref.WeakReference; import java.util.List; import java.util.Map; import java.util.concurrent.Executor; -import dalvik.system.VMRuntime; - /** * A listener class for monitoring changes in specific telephony states * on the device, including service state, signal strength, message @@ -362,6 +362,30 @@ public class PhoneStateListener { @SystemApi public static final int LISTEN_IMS_CALL_DISCONNECT_CAUSES = 0x08000000; + /** + * Listen for the emergency number placed from an outgoing call. + * + * <p>Requires permission {@link android.Manifest.permission#READ_ACTIVE_EMERGENCY_SESSION} + * + * @see #onOutgoingEmergencyCall + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) + public static final int LISTEN_OUTGOING_CALL_EMERGENCY_NUMBER = 0x10000000; + + /** + * Listen for the emergency number placed from an outgoing SMS. + * + * <p>Requires permission {@link android.Manifest.permission#READ_ACTIVE_EMERGENCY_SESSION} + * + * @see #onOutgoingEmergencySms + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) + public static final int LISTEN_OUTGOING_SMS_EMERGENCY_NUMBER = 0x20000000; + /* * Subscription used to listen to the phone state changes * @hide @@ -844,6 +868,27 @@ public class PhoneStateListener { } /** + * Callback invoked when an outgoing call is placed to an emergency number. + * + * @param placedEmergencyNumber the emergency number {@link EmergencyNumber} the call is placed + * to. + * @hide + */ + public void onOutgoingEmergencyCall(@NonNull EmergencyNumber placedEmergencyNumber) { + // default implementation empty + } + + /** + * Callback invoked when an outgoing SMS is placed to an emergency number. + * + * @param sentEmergencyNumber the emergency number {@link EmergencyNumber} the SMS is sent to. + * @hide + */ + public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber) { + // default implementation empty + } + + /** * 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)}. @@ -1151,7 +1196,6 @@ public class PhoneStateListener { () -> psl.onPhysicalChannelConfigurationChanged(configs))); } - @Override public void onEmergencyNumberListChanged(Map emergencyNumberList) { PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); if (psl == null) return; @@ -1161,6 +1205,24 @@ public class PhoneStateListener { () -> psl.onEmergencyNumberListChanged(emergencyNumberList))); } + public void onOutgoingEmergencyCall(@NonNull EmergencyNumber placedEmergencyNumber) { + PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); + if (psl == null) return; + + Binder.withCleanCallingIdentity( + () -> mExecutor.execute( + () -> psl.onOutgoingEmergencyCall(placedEmergencyNumber))); + } + + public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber) { + PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); + if (psl == null) return; + + Binder.withCleanCallingIdentity( + () -> mExecutor.execute( + () -> psl.onOutgoingEmergencySms(sentEmergencyNumber))); + } + public void onPhoneCapabilityChanged(PhoneCapability capability) { PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); if (psl == null) return; diff --git a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl index 4a263f060ca5..90019eef62fd 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -58,6 +58,8 @@ oneway interface IPhoneStateListener { void onRadioPowerStateChanged(in int state); void onCallAttributesChanged(in CallAttributes callAttributes); void onEmergencyNumberListChanged(in Map emergencyNumberList); + void onOutgoingEmergencyCall(in EmergencyNumber placedEmergencyNumber); + void onOutgoingEmergencySms(in EmergencyNumber sentEmergencyNumber); void onCallDisconnectCauseChanged(in int disconnectCause, in int preciseDisconnectCause); void onImsCallDisconnectCauseChanged(in ImsReasonInfo imsReasonInfo); } |