Can not Show notification on status bar

186 views
Skip to first unread message

ekrem şahin

unread,
Sep 29, 2021, 9:27:07 AM9/29/21
to Android Automotive OS Discussion Group
Hello,

I have created a foreground service for an Application with UserHandle.USER_SYSTEM (user 0) under /product/priv-app/ folder on aosp 11  for Automotive. Currently, I can not show notifications on statusbar for UserHandle.USER_SYSTEM (user 0) since it is blocked by CarNotificationListener class (packages/apps/Car/Notification/src/com/android /car/notification/CarNotificationListener.java) on onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) function.

In the function , We return from the following if check and not showing any notifications for user 0 on statusbar:

        if (!isNotificationForCurrentUser(sbn)) {
            Log.d(TAG, "onNotificationPosted do not show: " + sbn);
            return;
        }

The isNotificationForCurrentUser function checks that StatusBarNotification user id is matching with Activity Manager's current user or if it equals to UserHandle.USER_ALL.Since My service is UserHandle.USER_SYSTEM , it is blocked by CarNotificationListener class.

"Notifications that do not appear in the Notification Center
*Foreground service notifications for system privileged apps and apps that are signed with the platform key that have an importance level lower than IMPORTANCE_DEFAULT."

but I already use NotificationManager.IMPORTANCE_DEFAULT while creating  Notification Channel.

So For test purposes, I have added a patch to by-pass the isNotificationForCurrentUser function and after that my service notification is shown on status bar but After reboot there is a violation and can not open status bar again because of by-passing the isNotificationForCurrentUser function.

Is there any idea what I am missing ?

Best Regards

Reply all
Reply to author
Forward
0 new messages