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

Commit 1a2292b9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add NotificationDelegate API to rebundle notification" into main

parents 08ac8ffe e82e8a5e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -239,4 +239,7 @@ interface IStatusBarService

    /** Unbundle a categorized notification */
    void unbundleNotification(String key);

    /** Rebundle an (un)categorized notification */
    void rebundleNotification(String key);
}
+2 −0
Original line number Diff line number Diff line
@@ -435,6 +435,8 @@ class FakeStatusBarService : IStatusBarService.Stub() {

    override fun unbundleNotification(key: String) {}

    override fun rebundleNotification(key: String) {}

    companion object {
        const val DEFAULT_DISPLAY_ID = Display.DEFAULT_DISPLAY
        const val SECONDARY_DISPLAY_ID = 2
+5 −0
Original line number Diff line number Diff line
@@ -107,4 +107,9 @@ public interface NotificationDelegate {
     * @param key the notification key
     */
    void unbundleNotification(String key);
    /**
     *  Called when the notification should be rebundled.
     * @param key the notification key
     */
    void rebundleNotification(String key);
}
+31 −0
Original line number Diff line number Diff line
@@ -1888,6 +1888,36 @@ public class NotificationManagerService extends SystemService {
                }
            }
        }
        @Override
        public void rebundleNotification(String key) {
            if (!(notificationClassification() && notificationRegroupOnClassification())) {
                return;
            }
            synchronized (mNotificationLock) {
                NotificationRecord r = mNotificationsByKey.get(key);
                if (r == null) {
                    return;
                }
                if (DBG) {
                    Slog.v(TAG, "rebundleNotification: " + r);
                }
                if (r.getBundleType() != Adjustment.TYPE_OTHER) {
                    final Bundle classifBundle = new Bundle();
                    classifBundle.putInt(KEY_TYPE, r.getBundleType());
                    Adjustment adj = new Adjustment(r.getSbn().getPackageName(), r.getKey(),
                            classifBundle, "rebundle", r.getUserId());
                    applyAdjustmentLocked(r, adj, /* isPosted= */ true);
                    mRankingHandler.requestSort();
                } else {
                    if (DBG) {
                        Slog.w(TAG, "Can't rebundle. No valid bundle type for: " + r);
                    }
                }
            }
        }
    };
    NotificationManagerPrivate mNotificationManagerPrivate = new NotificationManagerPrivate() {
@@ -7134,6 +7164,7 @@ public class NotificationManagerService extends SystemService {
                    adjustments.putParcelable(KEY_TYPE, newChannel);
                    logClassificationChannelAdjustmentReceived(r, isPosted, classification);
                    r.setBundleType(classification);
                }
            }
            r.addAdjustment(adjustment);
+15 −0
Original line number Diff line number Diff line
@@ -222,6 +222,9 @@ public final class NotificationRecord {
    // lifetime extended.
    private boolean mCanceledAfterLifetimeExtension = false;

    // type of the bundle if the notification was classified
    private @Adjustment.Types int mBundleType = Adjustment.TYPE_OTHER;

    public NotificationRecord(Context context, StatusBarNotification sbn,
            NotificationChannel channel) {
        this.sbn = sbn;
@@ -467,6 +470,10 @@ public final class NotificationRecord {
            }
        }

        if (android.service.notification.Flags.notificationClassification()) {
            mBundleType = previous.mBundleType;
        }

        // Don't copy importance information or mGlobalSortKey, recompute them.
    }

@@ -1629,6 +1636,14 @@ public final class NotificationRecord {
        mCanceledAfterLifetimeExtension = canceledAfterLifetimeExtension;
    }

    public @Adjustment.Types int getBundleType() {
        return mBundleType;
    }

    public void setBundleType(@Adjustment.Types int bundleType) {
        mBundleType = bundleType;
    }

    /**
     * Whether this notification is a conversation notification.
     */
Loading