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
This commit is contained in:
@@ -95,6 +95,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";
|
||||
@@ -10237,6 +10238,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 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
|
||||
@@ -10707,6 +10709,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<android.service.carrier.CarrierIdentifier>);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAlwaysAllowMmsData(boolean);
|
||||
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 boolean setCdmaRoamingMode(int);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -2090,6 +2090,11 @@
|
||||
<permission android:name="android.permission.READ_ACTIVE_EMERGENCY_SESSION"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<!-- @SystemApi Allows listen permission to always reported signal strength.
|
||||
@hide Used internally. -->
|
||||
<permission android:name="android.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH"
|
||||
android:protectionLevel="signature|telephony" />
|
||||
|
||||
<!-- @SystemApi Protects the ability to register any PhoneAccount with
|
||||
PhoneAccount#CAPABILITY_SIM_SUBSCRIPTION. This capability indicates that the PhoneAccount
|
||||
corresponds to a device SIM.
|
||||
|
||||
@@ -885,6 +885,10 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
remove(r.binder);
|
||||
}
|
||||
}
|
||||
if ((events & PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)
|
||||
!= 0) {
|
||||
updateReportSignalStrengthDecision(r.subId);
|
||||
}
|
||||
if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
|
||||
try {
|
||||
if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = "
|
||||
@@ -1021,6 +1025,27 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateReportSignalStrengthDecision(int subscriptionId) {
|
||||
synchronized (mRecords) {
|
||||
TelephonyManager telephonyManager = (TelephonyManager) mContext
|
||||
.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
for (Record r : mRecords) {
|
||||
// If any of the system clients wants to always listen to signal strength,
|
||||
// we need to set it on.
|
||||
if (r.matchPhoneStateListenerEvent(
|
||||
PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)) {
|
||||
telephonyManager.createForSubscriptionId(subscriptionId)
|
||||
.setAlwaysReportSignalStrength(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If none of the system clients wants to always listen to signal strength,
|
||||
// we need to set it off.
|
||||
telephonyManager.createForSubscriptionId(subscriptionId)
|
||||
.setAlwaysReportSignalStrength(false);
|
||||
}
|
||||
}
|
||||
|
||||
private String getCallIncomingNumber(Record record, int phoneId) {
|
||||
// Only reveal the incoming number if the record has read call log permission.
|
||||
return record.canReadCallLog() ? mCallIncomingNumber[phoneId] : "";
|
||||
@@ -1078,6 +1103,14 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
|
||||
mRecords.remove(i);
|
||||
|
||||
// Every time a client that is registrating to always receive the signal
|
||||
// strength is removed from registry records, we need to check if
|
||||
// the signal strength decision needs to update on its slot.
|
||||
if (r.matchPhoneStateListenerEvent(
|
||||
PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH)) {
|
||||
updateReportSignalStrengthDecision(r.subId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2525,6 +2558,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION, null);
|
||||
}
|
||||
|
||||
if ((events & PhoneStateListener.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH) != 0) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH, null);
|
||||
}
|
||||
|
||||
if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
|
||||
|
||||
@@ -10931,6 +10931,27 @@ public class TelephonyManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable signal strength changes from radio will always be reported in any
|
||||
* condition (e.g. screen is off). This is only allowed for System caller.
|
||||
*
|
||||
* @param isEnabled {@code true} for enabling; {@code false} for disabling.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public void setAlwaysReportSignalStrength(boolean isEnabled) {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
telephony.setAlwaysReportSignalStrength(getSubId(), isEnabled);
|
||||
}
|
||||
} catch (RemoteException ex) {
|
||||
Log.e(TAG, "setAlwaysReportSignalStrength RemoteException", ex);
|
||||
ex.rethrowAsRuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most recently available signal strength information.
|
||||
*
|
||||
|
||||
@@ -972,6 +972,11 @@ interface ITelephony {
|
||||
*/
|
||||
boolean isManualNetworkSelectionAllowed(int subId);
|
||||
|
||||
/**
|
||||
* Enable or disable always reporting signal strength changes from radio.
|
||||
*/
|
||||
void setAlwaysReportSignalStrength(int subId, boolean isEnable);
|
||||
|
||||
/**
|
||||
* Get P-CSCF address from PCO after data connection is established or modified.
|
||||
* @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN
|
||||
|
||||
Reference in New Issue
Block a user