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

Commit 01a1ad51 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Fix notifications that are sent for USER_ALL." into nyc-dev

parents bc20320f 012bc7bb
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -1955,9 +1955,16 @@ public class Notification implements Parcelable
     * @hide
     */
    public static void addFieldsFromContext(Context context, Notification notification) {
        notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO,
                context.getApplicationInfo());
        notification.extras.putInt(EXTRA_ORIGINATING_USERID, context.getUserId());
        addFieldsFromContext(context.getApplicationInfo(), context.getUserId(), notification);
    }

    /**
     * @hide
     */
    public static void addFieldsFromContext(ApplicationInfo ai, int userId,
            Notification notification) {
        notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, ai);
        notification.extras.putInt(EXTRA_ORIGINATING_USERID, userId);
    }

    @Override
+4 −6
Original line number Diff line number Diff line
@@ -2459,12 +2459,10 @@ public class NotificationManagerService extends SystemService {

        // Fix the notification as best we can.
        try {
            if (!"android".equals(pkg) && !"system".equals(pkg)) {
                Notification.addFieldsFromContext(getContext().createApplicationContext(
                        getContext().getPackageManager().getApplicationInfoAsUser(
                                pkg, PackageManager.MATCH_UNINSTALLED_PACKAGES, userId),
                        Context.CONTEXT_RESTRICTED), notification);
            }
            final ApplicationInfo ai = getContext().getPackageManager().getApplicationInfoAsUser(
                    pkg, PackageManager.MATCH_DEBUG_TRIAGED_MISSING,
                    (userId == UserHandle.USER_ALL) ? UserHandle.USER_SYSTEM : userId);
            Notification.addFieldsFromContext(ai, userId, notification);
        } catch (NameNotFoundException e) {
            Slog.e(TAG, "Cannot create a context for sending app", e);
            return;