Answer tested on a OnePlus 6 running Android 9.0.
You can setup adb in your PC and try this command:
adb shell 'dumpsys audio | toybox grep -i "CallingPack" | toybox sed -e "s/$/\n/g"'
audio
is dump/log that is shown to the user using dumpsys utility. The rest of the command is just to filter out relevant information.
Example output:
10-15 18:14:19:273 requestAudioFocus() from uid/pid 10096/6373 clientId=android.media.AudioManager@a9ae24fqijaz221.github.io.musicplayer.audio_playback.AudioPlayerService@d009ddc callingPack=qijaz221.github.io.musicplayer req=1 flags=0x0 sdk=28
10-15 18:19:51:868 requestAudioFocus() from uid/pid 10133/3213 clientId=android.media.AudioManager@c20d259 callingPack=com.arlosoft.macrodroid req=3 flags=0x0 sdk=28
10-15 18:24:47:697 requestAudioFocus() from uid/pid 10019/1914 clientId=android.media.AudioManager@8f116ae callingPack=com.android.systemui req=3 flags=0x0 sdk=28
In the output, the bold highlighted text is the package name of the apps which had caused certain sound to be played in my device at the time noted at the beginning of each line. Here's what those apps did for me:
- qijaz221.github.io.musicplayer is the media player I used to play a song.
- com.arlosoft.macrodroid is an automation app I used to play a brief sound in the background without showing a notification.
- com.android.systemui is for a notification with a sound.
To find out which apps correspond to those package names, follow my answer here.
Note: if the package name corresponding to your time turns out to be com.android.systemui
, you may have to dig deep into the dump service media.metrics
. I couldn't make much sense of its output but your case may vary.