Fatal Exception Neither user nor current process has android.permission.WAKE_LOCK
Hello, I am experiencing an odd error with Exoplayer and specifically Galaxy S20 and S21 devices running Android 12.
I have been getting crashlytics reports that the user / process don't have wake lock permissions:
I have WAKE_LOCK in my permissions:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
And I am using setWakeMode to handle the locks and am not handling them myself:
private fun initPlayer() {
mCurrentPlayer = mContext?.let { ExoPlayer.Builder(it).build() }
mCurrentPlayer?.playWhenReady = true
mCurrentPlayer?.repeatMode = Player.REPEAT_MODE_ALL
val mediaSource = createMediaSource()
if (mediaSource != null) {
mCurrentPlayer?.setMediaSource(mediaSource)
mCurrentPlayer?.addListener(playerListener)
mCurrentPlayer?.setWakeMode(C.WAKE_MODE_NETWORK)
mCurrentPlayer?.volume = sound.volume.toFloat()
mCurrentPlayer?.prepare()
}
}
In my specific use cases, there might be multiple instances of players set up in the same manner as the previous example, all running at the same time. The Service is a MediaBrowserService and the app is used to play sounds in the background for long periods of time.
I have not experienced this issue personally, and cannot reproduce it on my Pixel 5a running 12, and was curious if anyone had seen this or might know if I'm doing something wrong.
Devices Affected:
- Samsung S21 5G - Android 12
- Samsung S20 Ultra - Android 12
Exoplayer Version: 2.16.1 App's Target API: 30
Thank you!
EDIT:
additional part of trace:
Caused by android.os.RemoteException
Remote stack trace: at android.app.ContextImpl.enforce(ContextImpl.java:2273) at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2301) at com.android.server.power.PowerManagerService$BinderService.acquireWakeLock(PowerManagerService.java:8202) at android.os.IPowerManager$Stub.onTransact(IPowerManager.java:588) at android.os.Binder.execTransactInternal(Binder.java:1215)
Source: google/ExoPlayer