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

Commit 0008bee5 authored by Kholoud Mohamed's avatar Kholoud Mohamed Committed by Android (Google) Code Review
Browse files

Merge "Fix bug in userControlDisabledPackages on reboot" into udc-dev

parents a8b0dcfa 3b366ef5
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -3575,8 +3575,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    void handleStartUser(int userId) {
        synchronized (getLockObject()) {
            pushScreenCapturePolicy(userId);
            if (!isPolicyEngineForFinanceFlagEnabled()) {
                pushUserControlDisabledPackagesLocked(userId);
            }
        }
        pushUserRestrictions(userId);
        // When system user is started (device boot), load cache for all users.
        // This is to mitigate the potential race between loading the cache and keyguard
@@ -10062,7 +10064,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        setNetworkLoggingActiveInternal(false);
        deleteTransferOwnershipBundleLocked(userId);
        toggleBackupServiceActive(UserHandle.USER_SYSTEM, true);
        if (!isPolicyEngineForFinanceFlagEnabled()) {
            pushUserControlDisabledPackagesLocked(userId);
        }
        setGlobalSettingDeviceOwnerType(DEVICE_OWNER_TYPE_DEFAULT);
        if (isPolicyEngineForFinanceFlagEnabled() || isPermissionCheckFlagEnabled()) {
+11 −5
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.app.admin.PackagePermissionPolicyKey;
import android.app.admin.PackagePolicyKey;
import android.app.admin.PolicyKey;
import android.app.admin.UserRestrictionPolicyKey;
import android.app.usage.UsageStatsManagerInternal;
import android.content.ComponentName;
import android.content.Context;
import android.content.IntentFilter;
@@ -38,6 +39,7 @@ import android.os.UserHandle;
import android.permission.AdminPermissionControlParams;
import android.permission.PermissionControllerManager;
import android.provider.Settings;
import android.util.ArraySet;
import android.util.Slog;

import com.android.server.LocalServices;
@@ -151,11 +153,15 @@ final class PolicyEnforcerCallbacks {

    static boolean setUserControlDisabledPackages(
            @Nullable Set<String> packages, int userId) {
        Binder.withCleanCallingIdentity(() ->
        Binder.withCleanCallingIdentity(() -> {
            LocalServices.getService(PackageManagerInternal.class)
                    .setOwnerProtectedPackages(
                            userId,
                                packages == null ? null : packages.stream().toList()));
                            packages == null ? null : packages.stream().toList());
            LocalServices.getService(UsageStatsManagerInternal.class)
                            .setAdminProtectedPackages(
                            packages == null ? null : new ArraySet(packages), userId);
        });
        return true;
    }