From b0948d4cecb37ce1a75dabc2550463e36c02fb4e Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Mon, 27 Jan 2020 15:20:07 -0800 Subject: [PATCH] Add new permission / appop for reading loader data Bug: 148374455 Test: Manual Test: Create three packages; 1) only request PACKAGE_USAGE_STATS, 2) only request LOADER_USAGE_STATS, 3) request both Test: Go to Settings -> Apps & Notifications -> Special app access Test: See that there is only a single entry for "Usage access" Test: Under "Usage access", see all three test apps appear Test: Disable access for each application and verify that only the appop for the declared permisson is flipped using Test: adb shell cmd appops get <> Test: atest CtsPermission2TestCases Change-Id: I7741a703fd4494832347e51e113adf974cc31d2b --- api/current.txt | 1 + api/system-current.txt | 1 + core/java/android/app/AppOpsManager.java | 18 ++++++++++++++++-- core/java/android/app/AsyncNotedAppOp.java | 4 ++-- core/res/AndroidManifest.xml | 9 +++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index a7367e8c49434..f6092e2d4facc 100644 --- a/api/current.txt +++ b/api/current.txt @@ -91,6 +91,7 @@ package android { field public static final String INTERACT_ACROSS_PROFILES = "android.permission.INTERACT_ACROSS_PROFILES"; field public static final String INTERNET = "android.permission.INTERNET"; field public static final String KILL_BACKGROUND_PROCESSES = "android.permission.KILL_BACKGROUND_PROCESSES"; + field public static final String LOADER_USAGE_STATS = "android.permission.LOADER_USAGE_STATS"; field public static final String LOCATION_HARDWARE = "android.permission.LOCATION_HARDWARE"; field public static final String MANAGE_DOCUMENTS = "android.permission.MANAGE_DOCUMENTS"; field public static final String MANAGE_EXTERNAL_STORAGE = "android.permission.MANAGE_EXTERNAL_STORAGE"; diff --git a/api/system-current.txt b/api/system-current.txt index 26abc64dfe9c1..73efac46a3dec 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -391,6 +391,7 @@ package android.app { field public static final String OPSTR_INSTANT_APP_START_FOREGROUND = "android:instant_app_start_foreground"; field public static final String OPSTR_INTERACT_ACROSS_PROFILES = "android:interact_across_profiles"; field public static final String OPSTR_LEGACY_STORAGE = "android:legacy_storage"; + field public static final String OPSTR_LOADER_USAGE_STATS = "android:loader_usage_stats"; field public static final String OPSTR_MANAGE_EXTERNAL_STORAGE = "android:manage_external_storage"; field public static final String OPSTR_MANAGE_IPSEC_TUNNELS = "android:manage_ipsec_tunnels"; field public static final String OPSTR_MUTE_MICROPHONE = "android:mute_microphone"; diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index fc37af9d213eb..367c2f235f5f9 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -924,10 +924,12 @@ public class AppOpsManager { * @hide */ public static final int OP_ACTIVATE_PLATFORM_VPN = 94; + /** @hide */ + public static final int OP_LOADER_USAGE_STATS = 95; /** @hide */ @UnsupportedAppUsage - public static final int _NUM_OP = 95; + public static final int _NUM_OP = 96; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = "android:coarse_location"; @@ -1224,6 +1226,9 @@ public class AppOpsManager { public static final String OPSTR_INTERACT_ACROSS_PROFILES = "android:interact_across_profiles"; /** @hide Start Platform VPN without user intervention */ public static final String OPSTR_ACTIVATE_PLATFORM_VPN = "android:activate_platform_vpn"; + /** @hide */ + @SystemApi + public static final String OPSTR_LOADER_USAGE_STATS = "android:loader_usage_stats"; /** {@link #sAppOpsToNote} not initialized yet for this op */ @@ -1302,7 +1307,8 @@ public class AppOpsManager { OP_MANAGE_IPSEC_TUNNELS, OP_INSTANT_APP_START_FOREGROUND, OP_MANAGE_EXTERNAL_STORAGE, - OP_INTERACT_ACROSS_PROFILES + OP_INTERACT_ACROSS_PROFILES, + OP_LOADER_USAGE_STATS, }; /** @@ -1409,6 +1415,7 @@ public class AppOpsManager { OP_MANAGE_EXTERNAL_STORAGE, // MANAGE_EXTERNAL_STORAGE OP_INTERACT_ACROSS_PROFILES, //INTERACT_ACROSS_PROFILES OP_ACTIVATE_PLATFORM_VPN, // ACTIVATE_PLATFORM_VPN + OP_LOADER_USAGE_STATS, // LOADER_USAGE_STATS }; /** @@ -1510,6 +1517,7 @@ public class AppOpsManager { OPSTR_MANAGE_EXTERNAL_STORAGE, OPSTR_INTERACT_ACROSS_PROFILES, OPSTR_ACTIVATE_PLATFORM_VPN, + OPSTR_LOADER_USAGE_STATS, }; /** @@ -1612,6 +1620,7 @@ public class AppOpsManager { "MANAGE_EXTERNAL_STORAGE", "INTERACT_ACROSS_PROFILES", "ACTIVATE_PLATFORM_VPN", + "LOADER_USAGE_STATS", }; /** @@ -1715,6 +1724,7 @@ public class AppOpsManager { Manifest.permission.MANAGE_EXTERNAL_STORAGE, android.Manifest.permission.INTERACT_ACROSS_PROFILES, null, // no permission for OP_ACTIVATE_PLATFORM_VPN + android.Manifest.permission.LOADER_USAGE_STATS, }; /** @@ -1818,6 +1828,7 @@ public class AppOpsManager { null, // MANAGE_EXTERNAL_STORAGE null, // INTERACT_ACROSS_PROFILES null, // ACTIVATE_PLATFORM_VPN + null, // LOADER_USAGE_STATS }; /** @@ -1920,6 +1931,7 @@ public class AppOpsManager { false, // MANAGE_EXTERNAL_STORAGE false, // INTERACT_ACROSS_PROFILES false, // ACTIVATE_PLATFORM_VPN + false, // LOADER_USAGE_STATS }; /** @@ -2021,6 +2033,7 @@ public class AppOpsManager { AppOpsManager.MODE_DEFAULT, // MANAGE_EXTERNAL_STORAGE AppOpsManager.MODE_DEFAULT, // INTERACT_ACROSS_PROFILES AppOpsManager.MODE_IGNORED, // ACTIVATE_PLATFORM_VPN + AppOpsManager.MODE_DEFAULT, // LOADER_USAGE_STATS }; /** @@ -2126,6 +2139,7 @@ public class AppOpsManager { false, // MANAGE_EXTERNAL_STORAGE false, // INTERACT_ACROSS_PROFILES false, // ACTIVATE_PLATFORM_VPN + false, // LOADER_USAGE_STATS }; /** diff --git a/core/java/android/app/AsyncNotedAppOp.java b/core/java/android/app/AsyncNotedAppOp.java index 3febf71668375..130e2ecdcc834 100644 --- a/core/java/android/app/AsyncNotedAppOp.java +++ b/core/java/android/app/AsyncNotedAppOp.java @@ -256,10 +256,10 @@ public final class AsyncNotedAppOp implements Parcelable { }; @DataClass.Generated( - time = 1578516519372L, + time = 1580158740502L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/app/AsyncNotedAppOp.java", - inputSignatures = "private final @android.annotation.IntRange(from=0L, to=94L) int mOpCode\nprivate final @android.annotation.IntRange(from=0L) int mNotingUid\nprivate final @android.annotation.Nullable java.lang.String mFeatureId\nprivate final @android.annotation.NonNull java.lang.String mMessage\nprivate final @android.annotation.IntRange(from=0L) long mTime\npublic @android.annotation.NonNull java.lang.String getOp()\nclass AsyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genAidl=true, genHiddenConstructor=true)") + inputSignatures = "private final @android.annotation.IntRange(from=0L, to=95L) int mOpCode\nprivate final @android.annotation.IntRange(from=0L) int mNotingUid\nprivate final @android.annotation.Nullable java.lang.String mFeatureId\nprivate final @android.annotation.NonNull java.lang.String mMessage\nprivate final @android.annotation.IntRange(from=0L) long mTime\npublic @android.annotation.NonNull java.lang.String getOp()\nclass AsyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genAidl=true, genHiddenConstructor=true)") @Deprecated private void __metadata() {} diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 71a42e454f303..34bad5f8f07a1 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -4032,6 +4032,15 @@ android:protectionLevel="signature|privileged|development|appop|retailDemo" /> + + + +