[Telephony] Remove the permission from TelephonyDisplayInfo
Bug: 183164979 Test: make Change-Id: I5b1b4fea5feef3ba53603f24d88246d40322e2ff
This commit is contained in:
@@ -42333,7 +42333,7 @@ package android.telephony {
|
||||
}
|
||||
|
||||
public static interface TelephonyCallback.DisplayInfoListener {
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public void onDisplayInfoChanged(@NonNull android.telephony.TelephonyDisplayInfo);
|
||||
method public void onDisplayInfoChanged(@NonNull android.telephony.TelephonyDisplayInfo);
|
||||
}
|
||||
|
||||
public static interface TelephonyCallback.EmergencyNumberListListener {
|
||||
|
||||
@@ -343,11 +343,14 @@ public class PhoneStateListener {
|
||||
/**
|
||||
* Listen for display info changed event.
|
||||
*
|
||||
* Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE
|
||||
* READ_PHONE_STATE} or that the calling app has carrier privileges (see
|
||||
* {@link TelephonyManager#hasCarrierPrivileges}).
|
||||
* For clients compiled on Android 11 SDK, requires permission:
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE} or that the calling app has carrier
|
||||
* privileges (see {@link TelephonyManager#hasCarrierPrivileges}).
|
||||
* For clients compiled on Android 12 SDK or newer,
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE} or carrier privileges is not required
|
||||
* anymore.
|
||||
*
|
||||
* @see #onDisplayInfoChanged
|
||||
* @see #onDisplayInfoChanged
|
||||
* @deprecated Use {@link TelephonyCallback.DisplayInfoListener} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -981,8 +984,12 @@ public class PhoneStateListener {
|
||||
* <p> The {@link TelephonyDisplayInfo} contains status information shown to the user based on
|
||||
* carrier policy.
|
||||
*
|
||||
* Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE} or that the calling
|
||||
* app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}).
|
||||
* For clients compiled on Android 11 SDK, requires permission:
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE} or that the calling app has carrier
|
||||
* privileges (see {@link TelephonyManager#hasCarrierPrivileges}).
|
||||
* For clients compiled on Android 12 SDK or newer,
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE} or carrier privileges is not required
|
||||
* anymore.
|
||||
*
|
||||
* @param telephonyDisplayInfo The display information.
|
||||
* @deprecated Use {@link TelephonyCallback.DisplayInfoListener} instead.
|
||||
|
||||
@@ -1057,7 +1057,6 @@ public class TelephonyCallback {
|
||||
*
|
||||
* @param telephonyDisplayInfo The display information.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||
public void onDisplayInfoChanged(@NonNull TelephonyDisplayInfo telephonyDisplayInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -366,11 +366,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
|| events.contains(TelephonyCallback.EVENT_BARRING_INFO_CHANGED);
|
||||
}
|
||||
|
||||
private boolean isPhoneStatePermissionRequired(Set<Integer> events) {
|
||||
private boolean isPhoneStatePermissionRequired(Set<Integer> events, int targetSdk) {
|
||||
return events.contains(TelephonyCallback.EVENT_CALL_FORWARDING_INDICATOR_CHANGED)
|
||||
|| events.contains(TelephonyCallback.EVENT_MESSAGE_WAITING_INDICATOR_CHANGED)
|
||||
|| events.contains(TelephonyCallback.EVENT_EMERGENCY_NUMBER_LIST_CHANGED)
|
||||
|| events.contains(TelephonyCallback.EVENT_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGED);
|
||||
|| events.contains(TelephonyCallback.EVENT_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGED)
|
||||
|| (targetSdk <= android.os.Build.VERSION_CODES.R ? events.contains(
|
||||
TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED) : false);
|
||||
}
|
||||
|
||||
private boolean isPrecisePhoneStatePermissionRequired(Set<Integer> events) {
|
||||
@@ -882,12 +884,12 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
remove(callback.asBinder());
|
||||
return;
|
||||
}
|
||||
|
||||
int callerTargetSdk = TelephonyPermissions.getTargetSdk(mContext, callingPackage);
|
||||
// Checks permission and throws SecurityException for disallowed operations. For pre-M
|
||||
// apps whose runtime permission has been revoked, we return immediately to skip sending
|
||||
// events to the app without crashing it.
|
||||
if (!checkListenerPermission(events, subId, callingPackage, callingFeatureId,
|
||||
"listen")) {
|
||||
"listen", callerTargetSdk)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -920,7 +922,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
r.phoneId = phoneId;
|
||||
r.eventList = events;
|
||||
r.targetSdk = TelephonyPermissions.getTargetSdk(mContext, callingPackage);
|
||||
r.targetSdk = callerTargetSdk;
|
||||
|
||||
if (DBG) {
|
||||
log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId);
|
||||
@@ -2876,7 +2878,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
|
||||
private boolean checkListenerPermission(Set<Integer> events, int subId, String callingPackage,
|
||||
@Nullable String callingFeatureId, String message) {
|
||||
@Nullable String callingFeatureId, String message, int targetSdk) {
|
||||
LocationAccessPolicy.LocationPermissionQuery.Builder locationQueryBuilder =
|
||||
new LocationAccessPolicy.LocationPermissionQuery.Builder()
|
||||
.setCallingPackage(callingPackage)
|
||||
@@ -2912,7 +2914,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
if (isPhoneStatePermissionRequired(events)) {
|
||||
if (isPhoneStatePermissionRequired(events, targetSdk)) {
|
||||
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
|
||||
mContext, subId, callingPackage, callingFeatureId, message)) {
|
||||
isPermissionCheckSuccessful = false;
|
||||
|
||||
Reference in New Issue
Block a user