From 6cd260243aa735dc5201b765ab09fffe34c51ab0 Mon Sep 17 00:00:00 2001 From: sqian Date: Mon, 27 Jan 2020 14:18:02 -0800 Subject: Support always reporting signal strength phone state listener We should not allow other stack (such as Bluetooth) to directly control modem indication reporting. The hidden API TelephonyManager.setRadioIndicationUpdateMode added before do not support multiple clients and do not support the case when clients' process die. The new solution would be adding a new listener PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH and let telephony registry (which is running under system process) to tell telephony whether to always turn on signal strength update if any client is listening to this event. Introduce a new system API for TelephonyRegistry to tell Telephony module this listening mechanism. Introduce a new permision for this function Test: WIP (Have this CL out to try to catch up the API deadline) Bug: 147322848 Change-Id: Iaee832c75b29d89dbc9e5c6659e1a7e89c4a467f Merged-In: Iaee832c75b29d89dbc9e5c6659e1a7e89c4a467f (cherry picked from commit 93642d44330d5c124d20f4c00c09dc645987fda8) --- api/system-current.txt | 3 ++ .../java/android/telephony/PhoneStateListener.java | 10 ++++++ core/res/AndroidManifest.xml | 5 +++ .../java/com/android/server/TelephonyRegistry.java | 38 ++++++++++++++++++++++ .../java/android/telephony/TelephonyManager.java | 21 ++++++++++++ .../com/android/internal/telephony/ITelephony.aidl | 5 +++ 6 files changed, 82 insertions(+) diff --git a/api/system-current.txt b/api/system-current.txt index 44a1c0d79c13..e9eea1b79963 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -93,6 +93,7 @@ package android { field public static final String INTERNAL_SYSTEM_WINDOW = "android.permission.INTERNAL_SYSTEM_WINDOW"; field public static final String INVOKE_CARRIER_SETUP = "android.permission.INVOKE_CARRIER_SETUP"; field public static final String KILL_UID = "android.permission.KILL_UID"; + field public static final String LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH = "android.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH"; field public static final String LOCAL_MAC_ADDRESS = "android.permission.LOCAL_MAC_ADDRESS"; field public static final String LOCK_DEVICE = "android.permission.LOCK_DEVICE"; field public static final String LOOP_RADIO = "android.permission.LOOP_RADIO"; @@ -9083,6 +9084,7 @@ package android.telephony { method public void onRadioPowerStateChanged(int); method public void onSrvccStateChanged(int); method public void onVoiceActivationStateChanged(int); + field @RequiresPermission(android.Manifest.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH) public static final int LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH = 512; // 0x200 field @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public static final int LISTEN_CALL_ATTRIBUTES_CHANGED = 67108864; // 0x4000000 field @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public static final int LISTEN_OUTGOING_EMERGENCY_CALL = 268435456; // 0x10000000 field @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public static final int LISTEN_OUTGOING_EMERGENCY_SMS = 536870912; // 0x20000000 @@ -9534,6 +9536,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) public void resetSettings(); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int, java.util.List); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAllowedNetworkTypes(long); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setAlwaysReportSignalStrength(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int); diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java index f886cf58b850..03e7361159e1 100644 --- a/core/java/android/telephony/PhoneStateListener.java +++ b/core/java/android/telephony/PhoneStateListener.java @@ -167,6 +167,16 @@ public class PhoneStateListener { */ public static final int LISTEN_SIGNAL_STRENGTHS = 0x00000100; + /** + * Listen for always reported changes of the network signal strengths (cellular), + * even in some situations such as the screen of the device is off. + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH) + @SystemApi + public static final int LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH = 0x00000200; + /** * Listen for changes to observed cell info. * diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 5c204aba49a1..0c0493ba65aa 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2082,6 +2082,11 @@ + + +