diff options
| author | 2024-12-17 14:33:18 -0800 | |
|---|---|---|
| committer | 2024-12-23 10:38:03 -0800 | |
| commit | 6e4a6a66c856f4bc8107a4707557f936ca859153 (patch) | |
| tree | b2989d9a145fd20b43eeb2c0ee73977bd6cf88d2 | |
| parent | 1225c7930cc7a780f79bf1ba19c8ce985f88c15b (diff) | |
Adding check in requestPermissions for pre M apps
The recent optimization introduced in ag/30469303 is
causing PermissionTest22#testNoRuntimePrompt test to
fail. The test is verifying that permission dialog
is not shown for pre M apps i.e. target sdk < 23.
Although these apps are not supposed to call
Activity#requestPermissions API, adding this
check for compatibility.
Fix: 384177995
Test: atest PermissionTest22
FLAG: EXEMPT test fix
Change-Id: I34aa955fc13a2c0758fe2726467fc5082d72d2c4
| -rw-r--r-- | core/java/android/app/Activity.java | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index c3ef104075f2..8614bde775ad 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -5770,6 +5770,11 @@ public class Activity extends ContextThemeWrapper @FlaggedApi(Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED) public final void requestPermissions(@NonNull String[] permissions, int requestCode, int deviceId) { + // Pre M apps shouldn't request permissions, as permissions are granted at install time. + if (getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.M) { + onRequestPermissionsResult(requestCode, new String[0], new int[0], deviceId); + } + if (requestCode < 0) { throw new IllegalArgumentException("requestCode should be >= 0"); } |