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

Commit 83b6ef01 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Inform PendingIntent sender if broadcast was not queued.

If the broadcast could not be queued due to a stopped user, the
party trying to send a PendingIntent should be notified right away.
Otherwise, for instance, AlarmManager could be waiting forever to
be called back after the broadcast is delivered.

This is a potential fix for:
Bug: 18290018

Change-Id: I07c0751e80f11e69dfa2be5c96a033aecb298b81
parent 14638d76
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -212,6 +212,13 @@ public class ActivityManager {
     */
    public static final int BROADCAST_STICKY_CANT_HAVE_PERMISSION = -1;

    /**
     * Result for IActivityManager.broadcastIntent: trying to send a broadcast
     * to a stopped user. Fail.
     * @hide
     */
    public static final int BROADCAST_FAILED_USER_STOPPED = -2;

    /**
     * Type for IActivityManaqer.getIntentSender: this PendingIntent is
     * for a sendBroadcast operation.
+1 −1
Original line number Diff line number Diff line
@@ -15576,7 +15576,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                    & Intent.FLAG_RECEIVER_BOOT_UPGRADE) == 0) {
                Slog.w(TAG, "Skipping broadcast of " + intent
                        + ": user " + userId + " is stopped");
                return ActivityManager.BROADCAST_SUCCESS;
                return ActivityManager.BROADCAST_FAILED_USER_STOPPED;
            }
        }
+4 −2
Original line number Diff line number Diff line
@@ -269,11 +269,13 @@ final class PendingIntentRecord extends IIntentSender.Stub {
                        try {
                            // If a completion callback has been requested, require
                            // that the broadcast be delivered synchronously
                            owner.broadcastIntentInPackage(key.packageName, uid,
                            int sent = owner.broadcastIntentInPackage(key.packageName, uid,
                                    finalIntent, resolvedType,
                                    finishedReceiver, code, null, null,
                                requiredPermission, (finishedReceiver != null), false, userId);
                            if (sent == ActivityManager.BROADCAST_SUCCESS) {
                                sendFinish = false;
                            }
                        } catch (RuntimeException e) {
                            Slog.w(ActivityManagerService.TAG,
                                    "Unable to send startActivity intent", e);