Android 4.3 and above allows access to a list of historical notifications using the Settings widget. The scope of "historical" is limited to current session of Android and the list is populated with new entries once the system is rebooted.
(Click image to enlarge)
So, where does this notification log is stored in Android?
I had no luck finding anything good named "notification". I already did a system-wide search with nothing positive to report here.
find / -iname "*notification*"
I watched the real-time output of
adb logcat -v long
(tried with explicit root access as well) but there was no common event when a notification popped up in notification drawer. I was monitoring the ping request (shows up as a notification) to KDE Connect sent from my Slackware Linux, for the test case.The entries that are visible in Notification drawer can be traced back to the output of
notification
service,adb shell dumpsys notification
As said, you get the current ones but not the historical ones.
The real name or codename (I suppose) of
notification
service isandroid.app.INotificationManager
. I attempted to dive into its source code and there is nothing positive to report. It is very likely that being not a programmer, I might have missed a thing or two of importance.I, while being reluctant for being illogical, did peek into the data directory of Settings (
com.android.settings
) and Settings Storage (com.android.providers.settings
) apps. Nothing interesting there.
I presume that either the log is managed in the memory by a program or at some location in storage where the logs are frequently flushed after current Android session ends. I've no idea what I'm talking here.
Edit:
I've the Notification access to Tasker under Settings → Notification manager already enabled. So that's definitely not the roadblock here.
(Asked by Lucky) The intent associated with that Notification log window accessible through Settings widget has the following things:
- Action:
android.intent.action.MAIN
- Category:
com.android.settings.SHORTCUT
- Flag:
0x10200000
- Component:
com.android.settings/.Settings$NotificationStationActivity
Note
- I've a rooted OnePlus One running COS12 (Xposed Framework installed) and many Android 5.1 ROMs.
- I'm absolutely aware about many apps which can record notifications and lets you see them. But as you would've guessed by now, I'm not interested in futuristic past but the past related to present moment. In short, I want access to native raw files or logs to see both the historical and current notifications without depending on third-party apps.
My goal
When a secondary user is in focus, Tasker (running under Primary user) misses any profile which depends upon an incoming notification. Google has noted the fact here:
Notifications for other users do not appear until they are active.
But you can still see those new notifications in the output of adb shell dumpsys notification
. So I want to access the logs directly to make my task(s) work, thereby removing the dependence on notifications showing up in Notification drawer.
dumpsys notification
. Ultimately, I asked for a file because I can set file modification event so the task would execute immediately. Your function ornotification
service's output has to be periodically checked for differences.