diff options
Diffstat (limited to 'telecomm/java/android/telecom/TelecomManager.java')
-rw-r--r-- | telecomm/java/android/telecom/TelecomManager.java | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 1677c8c1f08e..48867895bd5c 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -25,6 +25,8 @@ import android.annotation.SuppressAutoDoc; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemService; +import android.compat.annotation.ChangeId; +import android.compat.annotation.EnabledSince; import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.content.Context; @@ -1004,6 +1006,17 @@ public class TelecomManager { PRESENTATION_PAYPHONE}) public @interface Presentation {} + + /** + * Enable READ_PHONE_STATE protection on APIs querying and notifying call state, such as + * {@code TelecomManager#getCallState}, {@link TelephonyManager#getCallStateForSubscription()}, + * and {@link android.telephony.TelephonyCallback.CallStateListener}. + */ + @ChangeId + @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S) + // this magic number is a bug ID + public static final long ENABLE_GET_CALL_STATE_PERMISSION_PROTECTION = 157233955L; + private static final String TAG = "TelecomManager"; @@ -1758,21 +1771,23 @@ public class TelecomManager { * {@link TelephonyManager#CALL_STATE_OFFHOOK} * {@link TelephonyManager#CALL_STATE_IDLE} * - * Note that this API does not require the - * {@link android.Manifest.permission#READ_PHONE_STATE} permission. This is intentional, to - * preserve the behavior of {@link TelephonyManager#getCallState()}, which also did not require - * the permission. - * * Takes into consideration both managed and self-managed calls. + * <p> + * Requires Permission: + * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} for applications + * targeting API level 31+. * * @hide */ + @RequiresPermission(anyOf = {READ_PRIVILEGED_PHONE_STATE, + android.Manifest.permission.READ_PHONE_STATE}, conditional = true) @SystemApi public @CallState int getCallState() { ITelecomService service = getTelecomService(); if (service != null) { try { - return service.getCallState(); + return service.getCallStateUsingPackage(mContext.getPackageName(), + mContext.getAttributionTag()); } catch (RemoteException e) { Log.d(TAG, "RemoteException calling getCallState().", e); } |