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

Commit 3a0c8759 authored by Xiaowen Lei's avatar Xiaowen Lei
Browse files

Only extract RON content model for RON style notifications.

Created Notification.RichOngoingStyle, which is currently empty. This
class is supposed to be the base class  for the various RON use cases.

The tests were performed with the desktop app modified to use the new
style for running timer notifications.

Flag: android.app.api_rich_ongoing
Flag: com.android.systemui.notification_row_content_binder_refactor
Bug: 337261753
Bug: 343942780
Test: Trigger running timer; observe notification from the content model.
Test: Miss timer; observe timer notification not from the content model.
Change-Id: I10983db618dc212562ff6c333d4f602a76aaf484
parent eea96688
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6844,6 +6844,9 @@ package android.app {
    method public android.app.Notification.MessagingStyle.Message setData(String, android.net.Uri);
  }
  @FlaggedApi("android.app.api_rich_ongoing") public abstract static class Notification.RichOngoingStyle extends android.app.Notification.Style {
  }
  public abstract static class Notification.Style {
    ctor @Deprecated public Notification.Style();
    method public android.app.Notification build();
+12 −0
Original line number Diff line number Diff line
@@ -10919,6 +10919,18 @@ public class Notification implements Parcelable
        }
    }
    /**
     * An object that can apply a rich ongoing notification style to a {@link Notification.Builder}
     * object.
     */
    @FlaggedApi(Flags.FLAG_API_RICH_ONGOING)
    public abstract static class RichOngoingStyle extends Notification.Style {
        /**
         * @hide
         */
        public RichOngoingStyle() {}
    }
    /**
     * Notification style for custom views that are decorated by the system
     *
+7 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.row

import android.app.Notification
import android.app.Notification.RichOngoingStyle
import android.app.PendingIntent
import android.content.Context
import android.util.Log
@@ -68,12 +69,14 @@ class RichOngoingNotificationContentExtractorImpl @Inject constructor() :
        builder: Notification.Builder,
        systemUIContext: Context,
        packageContext: Context
    ): RichOngoingContentModel? =
    ): RichOngoingContentModel? {
        if (builder.style !is RichOngoingStyle) return null

        try {
            val sbn = entry.sbn
            val notification = sbn.notification
            val icon = IconModel(notification.smallIcon)
            if (sbn.packageName == "com.google.android.deskclock") {
            return if (sbn.packageName == "com.google.android.deskclock") {
                when (notification.channelId) {
                    "Timers v2" -> {
                        parseTimerNotification(notification, icon)
@@ -90,7 +93,8 @@ class RichOngoingNotificationContentExtractorImpl @Inject constructor() :
            } else null
        } catch (e: Exception) {
            Log.e("RONs", "Error parsing RON", e)
            null
            return null
        }
    }

    /**