androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.59k stars 377 forks source link

Since 34 - One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified #1674

Closed Tr736 closed 4 weeks ago

Tr736 commented 4 weeks ago

Version

Media3 main branch

More version details

1.4.0

Devices that reproduce the issue

pixel 5

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

Happens on Launch

Expected result

No error to show

Actual result

The following error is thrown

E/AndroidRuntime(27193):    at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1852)
E/AndroidRuntime(27193):    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1792)
E/AndroidRuntime(27193):    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1780)
E/AndroidRuntime(27193):    at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:755)
E/AndroidRuntime(27193):    at androidx.car.app.connection.CarConnectionTypeLiveData.onActive(CarConnectionTypeLiveData.java:63)
E/AndroidRuntime(27193):    at androidx.lifecycle.LiveData.changeActiveCounter(LiveData.java:405)
E/AndroidRuntime(27193):    at androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged(LiveData.java:481)
E/AndroidRuntime(27193):    at androidx.lifecycle.LiveData.observeForever(LiveData.java:234)
E/AndroidRuntime(27193):    at fm.fountain.audio.module.internal.CarConnectionManager.<init>(CarConnectionManager.kt:15)
E/AndroidRuntime(27193):    at fm.fountain.audio.module.internal.PlaybackService.carConnectionManger(PlaybackService.kt:55)
E/AndroidRuntime(27193):    at fm.fountain.audio.module.internal.PlaybackService.onCreate(PlaybackService.kt:46)
E/AndroidRuntime(27193):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4651)
E/AndroidRuntime(27193):    ... 9 more
E/AndroidRuntime(27193): Caused by: android.os.RemoteException: Remote stack trace:
E/AndroidRuntime(27193):    at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:13927)
E/AndroidRuntime(27193):    at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
E/AndroidRuntime(27193):    at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2720)
E/AndroidRuntime(27193):    at android.os.Binder.execTransactInternal(Binder.java:1339)
E/AndroidRuntime(27193):    at android.os.Binder.execTransact(Binder.java:1275)
E/AndroidRuntime(27193): 

Media

This is what part of my manifest looks like

        <service
            android:name="XXX.internal.PlaybackService"
            android:foregroundServiceType="mediaPlayback"
            android:exported="true" >

            <intent-filter>
                <action android:name="androidx.media3.session.MediaSessionService"/>
                <action android:name="androidx.media3.session.MediaLibraryService"/>
                <action android:name="android.media.browse.MediaBrowserService" />
            </intent-filter>
        </service> 

and its started like this..

    init {
         Log.d("MediaController", "onCreate")
        _playerListener = PlayerListener()
        val sessionToken =
            SessionToken(context, ComponentName(context, PlaybackService::class.java))
        initController(sessionToken)
        initBrowser(sessionToken)
    }

If I comment out either the code the manifest or session token then the app dosnt throw the message

Bug Report

Note: This was working until I set the targetSDK from 33 to 34

marcbaechinger commented 4 weeks ago

Thanks for your report.

I can't repro this with with the demo app on a Pixel 8 emulator with API 34 I'm afraid.

Some observations:

at androidx.car.app.connection.CarConnectionTypeLiveData.onActive(CarConnectionTypeLiveData.java:63)

It appears to me this bug report should be targeted to Automotive OS that doesn't set that flag. I can see to make the team know about to hear what they say.

I think if you want to verify my guess, then you can disable Automotive support or, in case fm.fountain.audio.module.internal.CarConnectionManager is your app, make sure to not call CarConnectionTypeLiveData.onActive. This should prevent that exception because the receiver isn't reported in that case.

We can't really help you with this I'm afraid, because I think we do the right thing when registering runtime receivers.

I leave this bug open until I hear back from Auto folks and can report here if that's possible. It may also be I just close after a while given we are not really involved. I hope I'll be able to help you by internally signaling and listening.

marcbaechinger commented 4 weeks ago

Side question: Can you give me the version number of the Android Auto app that is installed on your device and if it's not yet updated upgrade to the most recent version. I see in the internal source code that the Auto class from above is already updated.

An easy fix would then be you update that app on your test device to the newest version, try again, and if it works close this issue.

I'll wait with contacting the Auto team until I know that version number as this may be an important information.

Tr736 commented 4 weeks ago

Hey @marcbaechinger

Thanks for the rapid response!

I was using Android Auto 1.2.0 bumping it to 1.4.0 resolved the issue!