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

Commit 58e706d7 authored by Robin Lee's avatar Robin Lee Committed by Android (Google) Code Review
Browse files

Merge "Let device owners handle onChoosePrivateKey" into mnc-dev

parents 3ab6f9e6 deee7735
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -3231,15 +3231,21 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }

        final UserHandle caller = Binder.getCallingUserHandle();
        final ComponentName profileOwner = getProfileOwner(caller.getIdentifier());

        if (profileOwner == null) {
        // If there is a profile owner, redirect to that; otherwise query the device owner.
        ComponentName aliasChooser = getProfileOwner(caller.getIdentifier());
        if (aliasChooser == null && caller.isOwner()) {
            ActiveAdmin deviceOwnerAdmin = getDeviceOwnerAdmin();
            if (deviceOwnerAdmin != null) {
                aliasChooser = deviceOwnerAdmin.info.getComponent();
            }
        }
        if (aliasChooser == null) {
            sendPrivateKeyAliasResponse(null, response);
            return;
        }

        Intent intent = new Intent(DeviceAdminReceiver.ACTION_CHOOSE_PRIVATE_KEY_ALIAS);
        intent.setComponent(profileOwner);
        intent.setComponent(aliasChooser);
        intent.putExtra(DeviceAdminReceiver.EXTRA_CHOOSE_PRIVATE_KEY_SENDER_UID, uid);
        intent.putExtra(DeviceAdminReceiver.EXTRA_CHOOSE_PRIVATE_KEY_URI, uri);
        intent.putExtra(DeviceAdminReceiver.EXTRA_CHOOSE_PRIVATE_KEY_ALIAS, alias);