diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 746c3eec3ef35..534fd99339115 100755
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -132,10 +132,24 @@ public class Build {
* key attestation to obtain
* proof of the device's original identifiers.
*
- *
Requires Permission: READ_PRIVILEGED_PHONE_STATE, or for the calling package to be the
- * device or profile owner and have the READ_PHONE_STATE permission. Profile owner access is
- * deprecated and will be removed in a future release.
+ *
Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
+ * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
+ * privileges (see {@link android.telephony.TelephonyManager#hasCarrierPrivileges}). The profile
+ * owner is an app that owns a managed profile on the device; for more details see Work profiles. Profile owner
+ * access is deprecated and will be removed in a future release.
*
+ *
If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then {@link Build#UNKNOWN} is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
+ * *
* @return The serial number if specified.
*/
@SuppressAutoDoc // No support for device / profile owner.
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 088dd3d69f74e..586e8dd7d1138 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -93,6 +93,8 @@ import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyProperties;
+import dalvik.system.VMRuntime;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.annotation.Retention;
@@ -108,8 +110,6 @@ import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import dalvik.system.VMRuntime;
-
/**
* Provides access to information about the telephony services on
* the device. Applications can use the methods in this class to
@@ -1551,6 +1551,17 @@ public class TelephonyManager {
* href="https://developer.android.com/work/managed-profiles">Work profiles. Profile owner
* access is deprecated and will be removed in a future release.
*
+ * If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then null is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
+ *
* @deprecated Use (@link getImei} which returns IMEI for GSM or (@link getMeid} which returns
* MEID for CDMA.
*/
@@ -1581,6 +1592,17 @@ public class TelephonyManager {
* href="https://developer.android.com/work/managed-profiles">Work profiles. Profile owner
* access is deprecated and will be removed in a future release.
*
+ * If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then null is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
+ *
* @param slotIndex of which deviceID is returned
*
* @deprecated Use (@link getImei} which returns IMEI for GSM or (@link getMeid} which returns
@@ -1613,6 +1635,17 @@ public class TelephonyManager {
* managed profile on the device; for more details see Work profiles. Profile owner
* access is deprecated and will be removed in a future release.
+ *
+ * If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then null is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
*/
@SuppressAutoDoc // No support for device / profile owner or carrier privileges (b/72967236).
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@@ -1631,6 +1664,17 @@ public class TelephonyManager {
* href="https://developer.android.com/work/managed-profiles">Work profiles. Profile owner
* access is deprecated and will be removed in a future release.
*
+ * If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then null is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
+ *
* @param slotIndex of which IMEI is returned
*/
@SuppressAutoDoc // No support for device / profile owner or carrier privileges (b/72967236).
@@ -1686,6 +1730,17 @@ public class TelephonyManager {
* managed profile on the device; for more details see Work profiles. Profile owner
* access is deprecated and will be removed in a future release.
+ *
+ * If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then null is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
*/
@SuppressAutoDoc // No support for device / profile owner or carrier privileges (b/72967236).
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@@ -1703,6 +1758,17 @@ public class TelephonyManager {
* href="https://developer.android.com/work/managed-profiles">Work profiles. Profile owner
* access is deprecated and will be removed in a future release.
*
+ * If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then null is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
+ *
* @param slotIndex of which MEID is returned
*/
@SuppressAutoDoc // No support for device / profile owner or carrier privileges (b/72967236).
@@ -3209,6 +3275,17 @@ public class TelephonyManager {
* managed profile on the device; for more details see Work profiles. Profile owner
* access is deprecated and will be removed in a future release.
+ *
+ * If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then null is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
*/
@SuppressAutoDoc // No support for device / profile owner or carrier privileges (b/72967236).
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@@ -3227,6 +3304,17 @@ public class TelephonyManager {
* href="https://developer.android.com/work/managed-profiles">Work profiles. Profile owner
* access is deprecated and will be removed in a future release.
*
+ * If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then null is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
+ *
* @param subId for which Sim Serial number is returned
* @hide
*/
@@ -3458,6 +3546,17 @@ public class TelephonyManager {
* managed profile on the device; for more details see Work profiles. Profile owner
* access is deprecated and will be removed in a future release.
+ *
+ * If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then null is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
*/
@SuppressAutoDoc // No support for device / profile owner or carrier privileges (b/72967236).
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@@ -3477,6 +3576,17 @@ public class TelephonyManager {
* href="https://developer.android.com/work/managed-profiles">Work profiles. Profile owner
* access is deprecated and will be removed in a future release.
*
+ * If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
+ *
+ *
+ * - If the calling app's target SDK is API level 28 or lower and the app has the
+ * READ_PHONE_STATE permission then null is returned.
+ * - If the calling app's target SDK is API level 28 or lower and the app does not have
+ * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
+ * higher, then a SecurityException is thrown.
+ *
+ *
* @param subId whose subscriber id is returned
* @hide
*/