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

Commit 9e697764 authored by Ioana Alexandru's avatar Ioana Alexandru Committed by Android (Google) Code Review
Browse files

Merge "Add an extra for opting in to show the small icon" into main

parents bf552f1f 787a981e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1077,6 +1077,7 @@ package android.app {
    field public static final String CATEGORY_CAR_WARNING = "car_warning";
    field @RequiresPermission(android.Manifest.permission.NOTIFICATION_DURING_SETUP) public static final String EXTRA_ALLOW_DURING_SETUP = "android.allowDuringSetup";
    field @FlaggedApi("android.app.hide_status_bar_notification") @RequiresPermission("android.Manifest.permission.HIDE_STATUS_BAR_NOTIFICATION") public static final String EXTRA_HIDE_STATUS_BAR_NOTIFICATION = "android.hideStatusBarNotification";
    field @RequiresPermission(android.Manifest.permission.PACKAGE_VERIFICATION_AGENT) public static final String EXTRA_PREFER_SMALL_ICON = "android.app.preferSmallIcon";
    field @RequiresPermission(android.Manifest.permission.SUBSTITUTE_NOTIFICATION_APP_NAME) public static final String EXTRA_SUBSTITUTE_APP_NAME = "android.substName";
    field public static final int FLAG_AUTOGROUP_SUMMARY = 1024; // 0x400
  }
+2 −0
Original line number Diff line number Diff line
@@ -1987,6 +1987,8 @@ UnflaggedApi: android.app.ActivityManager#getExternalHistoricalProcessStartReaso
    New API must be flagged with @FlaggedApi: method android.app.ActivityManager.getExternalHistoricalProcessStartReasons(String,int)
UnflaggedApi: android.app.AppOpsManager#OPSTR_RECEIVE_SANDBOX_TRIGGER_AUDIO:
    New API must be flagged with @FlaggedApi: field android.app.AppOpsManager.OPSTR_RECEIVE_SANDBOX_TRIGGER_AUDIO
UnflaggedApi: android.app.Notification#EXTRA_PREFER_SMALL_ICON:
    New API must be flagged with @FlaggedApi: field android.app.Notification.EXTRA_PREFER_SMALL_ICON
UnflaggedApi: android.companion.virtual.VirtualDeviceManager.VirtualDevice#getPersistentDeviceId():
    New API must be flagged with @FlaggedApi: method android.companion.virtual.VirtualDeviceManager.VirtualDevice.getPersistentDeviceId()
UnflaggedApi: android.content.Context#THREAD_NETWORK_SERVICE:
+9 −0
Original line number Diff line number Diff line
@@ -315,6 +315,15 @@ public class Notification implements Parcelable
     */
    public static final String EXTRA_REMOTE_INPUT_DRAFT = "android.remoteInputDraft";
    /**
     * A boolean indicating that the notification card should show the small icon instead of the
     * launcher app icon.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.PACKAGE_VERIFICATION_AGENT)
    public static final String EXTRA_PREFER_SMALL_ICON = "android.app.preferSmallIcon";
    /**
     * The call to WearableExtender#setBackground(Bitmap) will have no effect and the passed
     * Bitmap will not be retained in memory.
+7 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.row.icon

import android.annotation.WorkerThread
import android.app.Flags
import android.app.Notification
import android.content.Context
import android.content.pm.ApplicationInfo
import android.os.UserManager
@@ -73,10 +74,15 @@ constructor(
    override fun shouldShowAppIcon(notification: StatusBarNotification, context: Context): Boolean {
        return cache.getOrFetch(notification.packageName) {
            val packageContext = notification.getPackageContext(context)
            !prefersSmallIcon(notification.notification) &&
                !belongsToHeadlessSystemApp(packageContext)
        }
    }

    private fun prefersSmallIcon(notification: Notification): Boolean {
        return notification.extras.getBoolean(Notification.EXTRA_PREFER_SMALL_ICON)
    }

    @WorkerThread
    private fun belongsToHeadlessSystemApp(context: Context): Boolean {
        val info = context.applicationInfo
+13 −0
Original line number Diff line number Diff line
@@ -9072,6 +9072,19 @@ public class NotificationManagerService extends SystemService {
            }
        }
        if (notification.extras.getBoolean(Notification.EXTRA_PREFER_SMALL_ICON, false)) {
            int hasPackageVerifierAgentPerm = getContext().checkPermission(
                    Manifest.permission.PACKAGE_VERIFICATION_AGENT, -1, notificationUid);
            if (hasPackageVerifierAgentPerm != PERMISSION_GRANTED) {
                notification.extras.remove(Notification.EXTRA_PREFER_SMALL_ICON);
                if (DBG) {
                    Slog.w(TAG, "warning: pkg " + pkg + " attempting to show small icon"
                            + " without holding perm "
                            + Manifest.permission.PACKAGE_VERIFICATION_AGENT);
                }
            }
        }
        notification.flags &= ~FLAG_FSI_REQUESTED_BUT_DENIED;
        // Apps cannot post notifications that are lifetime extended.
Loading