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

Commit d2f1511f authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Don't get extras from the Intent

When handling Intents in the system process, we need to be careful
to not cause the extras bundle to be unparcelled. If the extra is
unparcelled, any custom class added to the extras will throw a
ClassCastException during the unparcel. For legacy reasons, we
would get the "seq" extra from the Intent for broadcast debugging.
This violates our requirement to not unparcel extras in the system
server process.

Bug: 19068243
Change-Id: I6cac426a0ef8648a05ded69ee4ac244017d9b5d1
parent e1f183d0
Loading
Loading
Loading
Loading
+7 −8
Original line number Original line Diff line number Diff line
@@ -7051,7 +7051,6 @@ public final class ActivityManagerService extends ActivityManagerNative
                return;
                return;
            }
            }
            final IPackageManager pm = AppGlobals.getPackageManager();
            final String authority = uri.getAuthority();
            final String authority = uri.getAuthority();
            final ProviderInfo pi = getProviderInfoLocked(authority, userId);
            final ProviderInfo pi = getProviderInfoLocked(authority, userId);
            if (pi == null) {
            if (pi == null) {
@@ -15733,13 +15732,13 @@ public final class ActivityManagerService extends ActivityManagerNative
                    callerPackage, callingPid, callingUid, resolvedType,
                    callerPackage, callingPid, callingUid, resolvedType,
                    requiredPermission, appOp, receivers, resultTo, resultCode,
                    requiredPermission, appOp, receivers, resultTo, resultCode,
                    resultData, map, ordered, sticky, false, userId);
                    resultData, map, ordered, sticky, false, userId);
            if (DEBUG_BROADCAST) Slog.v(
            if (DEBUG_BROADCAST) Slog.v(
                    TAG, "Enqueueing ordered broadcast " + r
                    TAG, "Enqueueing ordered broadcast " + r
                    + ": prev had " + queue.mOrderedBroadcasts.size());
                    + ": prev had " + queue.mOrderedBroadcasts.size());
            if (DEBUG_BROADCAST) {
            if (DEBUG_BROADCAST) Slog.i(
                int seq = r.intent.getIntExtra("seq", -1);
                    TAG, "Enqueueing broadcast " + r.intent.getAction());
                Slog.i(TAG, "Enqueueing broadcast " + r.intent.getAction() + " seq=" + seq);
            }
            boolean replaced = replacePending && queue.replaceOrderedBroadcastLocked(r);
            boolean replaced = replacePending && queue.replaceOrderedBroadcastLocked(r);
            if (!replaced) {
            if (!replaced) {
                queue.enqueueOrderedBroadcastLocked(r);
                queue.enqueueOrderedBroadcastLocked(r);
@@ -18289,8 +18288,8 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
        }
    }
    }
    private Set getProfileIdsLocked(int userId) {
    private Set<Integer> getProfileIdsLocked(int userId) {
        Set userIds = new HashSet<Integer>();
        Set<Integer> userIds = new HashSet<Integer>();
        final List<UserInfo> profiles = getUserManagerLocked().getProfiles(
        final List<UserInfo> profiles = getUserManagerLocked().getProfiles(
                userId, false /* enabledOnly */);
                userId, false /* enabledOnly */);
        for (UserInfo user : profiles) {
        for (UserInfo user : profiles) {
+4 −11
Original line number Original line Diff line number Diff line
@@ -513,11 +513,7 @@ public final class BroadcastQueue {
                }
                }
            }
            }
            try {
            try {
                if (DEBUG_BROADCAST_LIGHT) {
                if (DEBUG_BROADCAST_LIGHT) Slog.i(TAG, "Delivering to " + filter + " : " + r);
                    int seq = r.intent.getIntExtra("seq", -1);
                    Slog.i(TAG, "Delivering to " + filter
                            + " (seq=" + seq + "): " + r);
                }
                performReceiveLocked(filter.receiverList.app, filter.receiverList.receiver,
                performReceiveLocked(filter.receiverList.app, filter.receiverList.receiver,
                    new Intent(r.intent), r.resultCode, r.resultData,
                    new Intent(r.intent), r.resultCode, r.resultData,
                    r.resultExtras, r.ordered, r.initialSticky, r.userId);
                    r.resultExtras, r.ordered, r.initialSticky, r.userId);
@@ -662,12 +658,9 @@ public final class BroadcastQueue {
                    // result if requested...
                    // result if requested...
                    if (r.resultTo != null) {
                    if (r.resultTo != null) {
                        try {
                        try {
                            if (DEBUG_BROADCAST) {
                            if (DEBUG_BROADCAST) Slog.i(TAG,
                                int seq = r.intent.getIntExtra("seq", -1);
                                    "Finishing broadcast [" + mQueueName + "] "
                                Slog.i(TAG, "Finishing broadcast ["
                                    + r.intent.getAction() + " app=" + r.callerApp);
                                        + mQueueName + "] " + r.intent.getAction()
                                        + " seq=" + seq + " app=" + r.callerApp);
                            }
                            performReceiveLocked(r.callerApp, r.resultTo,
                            performReceiveLocked(r.callerApp, r.resultTo,
                                new Intent(r.intent), r.resultCode,
                                new Intent(r.intent), r.resultCode,
                                r.resultData, r.resultExtras, false, false, r.userId);
                                r.resultData, r.resultExtras, false, false, r.userId);