From ccd59411aaa82354a8d9d97783de564da911c91c Mon Sep 17 00:00:00 2001 From: Jing Ji Date: Tue, 29 Nov 2022 00:09:26 -0800 Subject: [PATCH] Update the FGS special use permission to normal|appop So it'll get granted by default on install. Bug: 254662522 Bug: 246792057 Test: atest CtsAppFgsTestCases Change-Id: I8e496115655a44f480cccd1bfa41b11da60fadd1 --- core/java/android/app/ForegroundServiceTypePolicy.java | 4 +++- core/res/AndroidManifest.xml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/ForegroundServiceTypePolicy.java b/core/java/android/app/ForegroundServiceTypePolicy.java index 9bf8550df6d04..63fdc2e1b6862 100644 --- a/core/java/android/app/ForegroundServiceTypePolicy.java +++ b/core/java/android/app/ForegroundServiceTypePolicy.java @@ -48,6 +48,7 @@ import android.compat.annotation.Disabled; import android.compat.annotation.EnabledAfter; import android.compat.annotation.Overridable; import android.content.Context; +import android.content.PermissionChecker; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo.ForegroundServiceType; @@ -879,7 +880,8 @@ public abstract class ForegroundServiceTypePolicy { int checkPermission(@NonNull Context context, @NonNull String name, int callerUid, int callerPid, String packageName, boolean allowWhileInUse) { // Simple case, check if it's already granted. - if (context.checkPermission(name, callerPid, callerUid) == PERMISSION_GRANTED) { + if (PermissionChecker.checkPermissionForPreflight(context, name, + callerPid, callerUid, packageName) == PERMISSION_GRANTED) { return PERMISSION_GRANTED; } if (allowWhileInUse) { diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 5a7abcce6b751..fcf283a6dee70 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -6286,12 +6286,12 @@ + android:protectionLevel="normal|appop|instant" />