From 6b06a38e3aa602f879cd17432b08c45af343a222 Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Wed, 22 Jan 2020 15:54:47 -0800 Subject: [PATCH] Expose OPSTR_READ_DEVICE_IDENTIFIERS Expose the constant for use in Telephony. Also replace a usage of a hidden UserHandle API with a systemapi equivalent. Bug: 146834818 Test: atest SmsApplicationTests Change-Id: I569d921abf923c384d7e771e2fc28f54e0dbfdd1 --- api/system-current.txt | 1 + core/java/android/app/AppOpsManager.java | 1 + .../com/android/internal/telephony/SmsApplication.java | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index 66b779d516690..91240966ea6e4 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -388,6 +388,7 @@ package android.app { field public static final String OPSTR_POST_NOTIFICATION = "android:post_notification"; field public static final String OPSTR_PROJECT_MEDIA = "android:project_media"; field public static final String OPSTR_READ_CLIPBOARD = "android:read_clipboard"; + field public static final String OPSTR_READ_DEVICE_IDENTIFIERS = "android:read_device_identifiers"; field public static final String OPSTR_READ_ICC_SMS = "android:read_icc_sms"; field public static final String OPSTR_READ_MEDIA_AUDIO = "android:read_media_audio"; field public static final String OPSTR_READ_MEDIA_IMAGES = "android:read_media_images"; diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index bc7e1e5910213..46f86690a7535 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -1159,6 +1159,7 @@ public class AppOpsManager { @SystemApi public static final String OPSTR_ACCESS_ACCESSIBILITY = "android:access_accessibility"; /** @hide Read device identifiers */ + @SystemApi public static final String OPSTR_READ_DEVICE_IDENTIFIERS = "android:read_device_identifiers"; /** @hide Query all packages on device */ public static final String OPSTR_QUERY_ALL_PACKAGES = "android:query_all_packages"; diff --git a/telephony/common/com/android/internal/telephony/SmsApplication.java b/telephony/common/com/android/internal/telephony/SmsApplication.java index 9b8282806c3c7..ffb3cb151ae4a 100644 --- a/telephony/common/com/android/internal/telephony/SmsApplication.java +++ b/telephony/common/com/android/internal/telephony/SmsApplication.java @@ -205,7 +205,7 @@ public final class SmsApplication { < android.os.Process.FIRST_APPLICATION_UID) { return contextUserId; } else { - return UserHandle.getUserId(callingUid); + return UserHandle.getUserHandleForUid(callingUid).getIdentifier(); } } @@ -811,10 +811,10 @@ public final class SmsApplication { // This should never happen in prod -- unit tests will put the receiver into a // unusual state where the pending result is null, which produces a NPE when calling // getSendingUserId. Just pretend like it's the system user for testing. - userId = UserHandle.USER_SYSTEM; + userId = UserHandle.SYSTEM.getIdentifier(); } Context userContext = mContext; - if (userId != UserHandle.USER_SYSTEM) { + if (userId != UserHandle.SYSTEM.getIdentifier()) { try { userContext = mContext.createPackageContextAsUser(mContext.getPackageName(), 0, UserHandle.of(userId));