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

Commit 71a89ee2 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Ask for PIN when granting permissions in front of

lock screen

When the user makes any permanent decision in front of the lock screen,
the system should as her/him for authentification. Permanent decisions
are granting of permissions and permanently denying permissions.

As the autentification flow unlocks the device the system asks only once
per permission-request session.

Test: - Revoked all permissions from camer
      - Set lock screen PIN
      - Opened camera app -> Camera app asks for permissions
      - Locked screen
      - Granted permission from in front of lock screen
Bug: 68777217, 65337954
Change-Id: I8358f1eba436786b25b2c2b0c12ac7dcfd334fec
parent 3d916f4d
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import static com.android.packageinstaller.permission.ui.GrantPermissionsViewHan
import static com.android.packageinstaller.permission.utils.Utils.getRequestMessage;

import android.app.Activity;
import android.app.KeyguardManager;
import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.content.pm.PackageInfo;
@@ -613,6 +614,35 @@ public class GrantPermissionsActivity extends Activity
        GroupState foregroundGroupState = getForegroundGroupState(name);
        GroupState backgroundGroupState = getBackgroundGroupState(name);

        if (result == GRANTED_ALWAYS || result == GRANTED_FOREGROUND_ONLY
                || result == DENIED_DO_NOT_ASK_AGAIN) {
            KeyguardManager kgm = getSystemService(KeyguardManager.class);

            if (kgm.isDeviceLocked()) {
                kgm.requestDismissKeyguard(this, new KeyguardManager.KeyguardDismissCallback() {
                            @Override
                            public void onDismissError() {
                                Log.e(LOG_TAG, "Cannot dismiss keyguard perm=" + name + " result="
                                        + result);
                            }

                            @Override
                            public void onDismissCancelled() {
                                // do nothing (i.e. stay at the current permission group)
                            }

                            @Override
                            public void onDismissSucceeded() {
                                // Now the keyguard is dismissed, hence the device is not locked
                                // anymore
                                onPermissionGrantResult(name, result);
                            }
                        });

                return;
            }
        }

        switch (result) {
            case GRANTED_ALWAYS :
                if (foregroundGroupState != null) {