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

Commit 0b651a00 authored by Paul Miller's avatar Paul Miller Committed by Android (Google) Code Review
Browse files

Merge "Fail nicely in Activity.requestPermissions when requestCode < 0"

parents e2073c76 77a0e13b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -4100,11 +4100,16 @@ public class Activity extends ContextThemeWrapper
     *    reported to {@link #onRequestPermissionsResult(int, String[], int[])}.
     *    Should be >= 0.
     *
     * @throws IllegalArgumentException if requestCode is negative.
     *
     * @see #onRequestPermissionsResult(int, String[], int[])
     * @see #checkSelfPermission(String)
     * @see #shouldShowRequestPermissionRationale(String)
     */
    public final void requestPermissions(@NonNull String[] permissions, int requestCode) {
        if (requestCode < 0) {
            throw new IllegalArgumentException("requestCode should be >= 0");
        }
        if (mHasCurrentPermissionsRequest) {
            Log.w(TAG, "Can reqeust only one set of permissions at a time");
            // Dispatch the callback with empty arrays which means a cancellation.