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

Commit 5dfd7f3e authored by Pavel Grafov's avatar Pavel Grafov Committed by Android (Google) Code Review
Browse files

Merge "Set broadcast policy for suspension and quiet mode" into udc-dev

parents d55c38e4 1d823047
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.app.BroadcastOptions;
import android.app.IActivityManager;
import android.app.admin.DevicePolicyManagerInternal;
import android.content.Intent;
@@ -620,12 +621,15 @@ public final class SuspendPackageHelper {
        extras.putStringArray(Intent.EXTRA_CHANGED_PACKAGE_LIST, pkgList);
        extras.putIntArray(Intent.EXTRA_CHANGED_UID_LIST, uidList);
        final int flags = Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND;
        final Bundle options = new BroadcastOptions()
                .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
                .toBundle();
        handler.post(() -> mBroadcastHelper.sendPackageBroadcast(intent, null /* pkg */,
                extras, flags, null /* targetPkg */, null /* finishedReceiver */,
                new int[]{userId}, null /* instantUserIds */, null /* broadcastAllowList */,
                (callingUid, intentExtras) -> BroadcastHelper.filterExtrasChangedPackageList(
                        mPm.snapshotComputer(), callingUid, intentExtras),
                null /* bOptions */));
                options));
    }

    /**
+9 −1
Original line number Diff line number Diff line
@@ -1276,7 +1276,15 @@ public class UserManagerService extends IUserManager.Stub {
        getDevicePolicyManagerInternal().broadcastIntentToManifestReceivers(
                intent, parentHandle, /* requiresPermission= */ true);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
        mContext.sendBroadcastAsUser(intent, parentHandle);
        final Bundle options = new BroadcastOptions()
                .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
                .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
                // Both actions use single namespace because only the final state matters.
                .setDeliveryGroupMatchingKey(
                        Intent.ACTION_MANAGED_PROFILE_AVAILABLE /* namespace */,
                        String.valueOf(profileHandle.getIdentifier()) /* key */)
                .toBundle();
        mContext.sendBroadcastAsUser(intent, parentHandle, /* receiverPermission= */ null, options);
    }

    @Override