Fix ghost notifications on Android 10; fix MediaBrowser exposed#12412
Merged
Stypox merged 1 commit intoTeamNewPipe:devfrom Jul 14, 2025
Merged
Fix ghost notifications on Android 10; fix MediaBrowser exposed#12412Stypox merged 1 commit intoTeamNewPipe:devfrom
Stypox merged 1 commit intoTeamNewPipe:devfrom
Conversation
Fixes TeamNewPipe#12400, see there for explanation. Citing from there: So apparently the problem is onGetRoot always returning a BrowserRoot instance. Making it return null solved the issue (but again, breaks Android Auto compatibility). It turns out (see https://stackoverflow.com/q/63818988/) that onGetRoot is also used for media resumption https://developer.android.com/media/implement/surfaces/mobile#mediabrowserservice_implementation, which causes a new notification to pop up (in this case a useless notification because our onGetRoot does not return something that can be used for resumption). So what needs to be done is to check if rootHints?.getBoolean(EXTRA_RECENT) == true and if that's the case not return anything (as EXTRA_RECENT is used by the system for resumption). The PackageValidator file is taken from https://github.com/android/uamp/blob/329a21b63c247e9bd35f6858d4fc0e448fa38603/common/src/main/java/com/example/android/uamp/media/PackageValidator.kt .
This was referenced Jul 6, 2025
AudricV
approved these changes
Jul 7, 2025
7 tasks
Member
|
Unable to reproduce this bug on Android 10 emulator, but I can on Android 11 emulator. I can confirm this fix works for Android 11. |
absurdlylongusername
approved these changes
Jul 9, 2025
Member
Author
|
Merging for now, we can always revert it if people report issues on Android Auto. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is it?
Description of the changes in your PR
This PR resolves a security-related TODO from #12044: making sure only packages with the right permissions can access NewPipe's MediaBrowser through
onGetRoot(). ThePackageValidatorfile is taken from https://github.com/android/uamp/blob/329a21b63c247e9bd35f6858d4fc0e448fa38603/common/src/main/java/com/example/android/uamp/media/PackageValidator.kt, as suggested in the Android docs here.Furthermore, this PR fixes #12400, which was caused by an invalid media resumption notification being created by the system after closing the player. The notification was being created because the system was querying
onGetRoot()to get information about resumption, and our code returned aBrowserRootinstead of returningnull, indicating that we supported media resumption as described here. Now the code only returns aBrowserRootifrootHints?.getBoolean(EXTRA_RECENT) != true, since theEXTRA_RECENThint is what identifies a media resumption request. This is also how UAMP and the Android docs identify it.I tested the fix for #12400 on an Android 10 emulator, and while I could reproduce before this commit, now I can't anymore. I also tested the Android Auto implementation with android-head-unit and it still works (i.e. the Android Auto app passes the
PackageValidatortests).For reference, VLC's implementation is quite different (no validation checks, package check to identify Android Auto), though I think it's buggy as I get ghost notifications with VLC too: https://github.com/videolan/vlc-android/blob/13567cd0ddc3ae93b853229a532694eee25a526d/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt#L1909
I've learned something about MediaBrowser tonight ;-)
Fixes the following issue(s)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.
Due diligence