With the help of Andrew I launched the command:
adb shell "pm list packages -f"
to get the list of packages and then scanned for their properties (Bash script):
list='com.google.android.youtube com.viber.voip'
mkdir -p dump
for i in $list; do
adb.exe shell appops get $i |& tee -a dump/$i.txt
done
Then I searched for the keyword TOAST_WINDOW
. for Youtube app it was:
Uid mode: COARSE_LOCATION: ignore
LEGACY_STORAGE: allow
VIBRATE: allow; time=+7h31m46s232ms ago; duration=+27ms
TAKE_AUDIO_FOCUS: allow; time=+28m45s847ms ago
WAKE_LOCK: allow; time=+1h13m24s504ms ago; duration=+9s138ms
TOAST_WINDOW: allow; time=+1h12m25s632ms ago; duration=-24855d3h14m7s312ms
START_FOREGROUND: allow; time=+82d1h9m54s814ms ago; duration=+2m34s513ms
USE_BIOMETRIC: allow; time=+40d0h55m4s406ms ago
The line:
WAKE_LOCK: allow; time=+1h13m24s504ms ago; duration=+9s138ms
probably tells that last toast was 1h ago with duration of 9s. It looks like what we experienced!
So I disabled the privilege:
# adb shell appops set com.google.android.youtube TOAST_WINDOW deny
# adb shell appops get com.google.android.youtube
...
TOAST_WINDOW: deny; time=+1h23m2s506ms ago; duration=-24855d3h14m7s312ms
I hope this solves the problem. IDK if an app upgrade resets user settings...
UPDATE this UI element is called Toast.
Seems the duration of a toast is hard-coded in Android sources: