Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e4a6a66 authored by mrulhania's avatar mrulhania
Browse files

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
parent 1225c793
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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");
        }