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

Commit 90f331ad authored by Chad Brubaker's avatar Chad Brubaker Committed by Android (Google) Code Review
Browse files

Merge "Add asUser version of sendBroadcast(Intent, String, Bundle)"

parents d2114efe 52c8edc2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -8449,6 +8449,7 @@ package android.content {
    method public abstract void sendBroadcast(android.content.Intent, java.lang.String, android.os.Bundle);
    method public abstract void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle);
    method public abstract void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle, java.lang.String);
    method public abstract void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle, java.lang.String, android.os.Bundle);
    method public abstract void sendOrderedBroadcast(android.content.Intent, java.lang.String);
    method public abstract void sendOrderedBroadcast(android.content.Intent, java.lang.String, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public abstract void sendOrderedBroadcast(android.content.Intent, java.lang.String, android.os.Bundle, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
@@ -8642,6 +8643,7 @@ package android.content {
    method public void sendBroadcast(android.content.Intent, java.lang.String, android.os.Bundle);
    method public void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle);
    method public void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle, java.lang.String);
    method public void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle, java.lang.String, android.os.Bundle);
    method public void sendOrderedBroadcast(android.content.Intent, java.lang.String);
    method public void sendOrderedBroadcast(android.content.Intent, java.lang.String, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public void sendOrderedBroadcast(android.content.Intent, java.lang.String, android.os.Bundle, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
@@ -41183,6 +41185,7 @@ package android.test.mock {
    method public void sendBroadcast(android.content.Intent, java.lang.String, android.os.Bundle);
    method public void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle);
    method public void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle, java.lang.String);
    method public void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle, java.lang.String, android.os.Bundle);
    method public void sendOrderedBroadcast(android.content.Intent, java.lang.String);
    method public void sendOrderedBroadcast(android.content.Intent, java.lang.String, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    method public void sendOrderedBroadcast(android.content.Intent, java.lang.String, android.os.Bundle, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
+17 −0
Original line number Diff line number Diff line
@@ -1052,6 +1052,23 @@ class ContextImpl extends Context {
        sendBroadcastAsUser(intent, user, receiverPermission, AppOpsManager.OP_NONE);
    }

    @Override
    public void sendBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission,
            Bundle options) {
        String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
        String[] receiverPermissions = receiverPermission == null ? null
                : new String[] {receiverPermission};
        try {
            intent.prepareToLeaveProcess(this);
            ActivityManagerNative.getDefault().broadcastIntent(
                    mMainThread.getApplicationThread(), intent, resolvedType, null,
                    Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE,
                    options, false, false, user.getIdentifier());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    @Override
    public void sendBroadcastAsUser(Intent intent, UserHandle user,
            String receiverPermission, int appOp) {
+21 −0
Original line number Diff line number Diff line
@@ -2028,6 +2028,27 @@ public abstract class Context {
    public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent,
            UserHandle user, @Nullable String receiverPermission);

    /**
     * Version of {@link #sendBroadcast(Intent, String, Bundle)} that allows you to specify the
     * user the broadcast will be sent to.  This is not available to applications
     * that are not pre-installed on the system image.  Using it requires holding
     * the INTERACT_ACROSS_USERS permission.
     *
     * @param intent The Intent to broadcast; all receivers matching this
     *               Intent will receive the broadcast.
     * @param user UserHandle to send the intent to.
     * @param receiverPermission (optional) String naming a permission that
     *               a receiver must hold in order to receive your broadcast.
     *               If null, no permission is required.
     * @param options (optional) Additional sending options, generated from a
     * {@link android.app.BroadcastOptions}.
     *
     * @see #sendBroadcast(Intent, String, Bundle)
     * @hide
     */
    @SystemApi
    public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent,
            UserHandle user, @Nullable String receiverPermission, @Nullable Bundle options);

    /**
     * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the
+7 −0
Original line number Diff line number Diff line
@@ -495,6 +495,13 @@ public class ContextWrapper extends Context {
        mBase.sendBroadcastAsUser(intent, user, receiverPermission);
    }

    /** @hide */
    @Override
    public void sendBroadcastAsUser(Intent intent, UserHandle user,
            String receiverPermission, Bundle options) {
        mBase.sendBroadcastAsUser(intent, user, receiverPermission, options);
    }

    /** @hide */
    @Override
    public void sendBroadcastAsUser(Intent intent, UserHandle user,
+8 −0
Original line number Diff line number Diff line
@@ -403,6 +403,14 @@ public class MockContext extends Context {
        throw new UnsupportedOperationException();
    }

    /** @hide */
    @SystemApi
    @Override
    public void sendBroadcastAsUser(Intent intent, UserHandle user,
            String receiverPermission, Bundle options) {
        throw new UnsupportedOperationException();
    }

    /** @hide */
    @Override
    public void sendBroadcastAsUser(Intent intent, UserHandle user,