From 92b0e4b08452e368bdaf16d62d8814c1b0ceeee3 Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Tue, 9 Feb 2021 13:57:30 -0800 Subject: [PATCH] Update docs for getServiceState Update docs for getServiceState to reflect the degrading behavior depending on the location permissions the caller holds, and to make it clear that an appops usage will be logged against the caller if they hold location permissions. Fixes: 179390723 Test: NA Change-Id: Icd541ab9bd265eec9065041486574953f9bee0b1 --- core/api/current.txt | 2 +- .../java/android/telephony/TelephonyManager.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index a9458897dc4f3..bf5b125271ad8 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -42050,7 +42050,7 @@ package android.telephony { method @Deprecated public int getPhoneCount(); method public int getPhoneType(); method @RequiresPermission(anyOf={"android.permission.READ_PRIVILEGED_PHONE_STATE", android.Manifest.permission.READ_PHONE_STATE}) public int getPreferredOpportunisticDataSubscription(); - method @Nullable @RequiresPermission(allOf={android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.ACCESS_COARSE_LOCATION}) public android.telephony.ServiceState getServiceState(); + method @Nullable @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public android.telephony.ServiceState getServiceState(); method @Nullable public android.telephony.SignalStrength getSignalStrength(); method public int getSimCarrierId(); method @Nullable public CharSequence getSimCarrierIdName(); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 65b8de2b22168..d4f677c01f56f 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -11255,16 +11255,21 @@ public class TelephonyManager { * *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}) - * and {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}. + * Additionally, depending on the level of location permissions the caller holds (i.e. no + * location permissions, {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}, or + * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}), location-sensitive fields will + * be cleared from the return value. + * + *

Note also that if the caller holds any sort of location permission, a usage event for the + * {@link android.app.AppOpsManager#OPSTR_FINE_LOCATION} or + * {@link android.app.AppOpsManager#OPSTR_FINE_LOCATION} + * will be logged against the caller when calling this method. * * May return {@code null} when the subscription is inactive or when there was an error * communicating with the phone process. */ @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges - @RequiresPermission(allOf = { - Manifest.permission.READ_PHONE_STATE, - Manifest.permission.ACCESS_COARSE_LOCATION - }) + @RequiresPermission(Manifest.permission.READ_PHONE_STATE) public @Nullable ServiceState getServiceState() { return getServiceStateForSubscriber(getSubId()); }