My users are facing a crash which I cannot replicate myself - here is the crash log
java.lang.SecurityException:
at android.os.Parcel.createException (Parcel.java:1950)
at android.os.Parcel.readException (Parcel.java:1918)
at android.os.Parcel.readException (Parcel.java:1868)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground (IActivityManager.java:5198)
at android.app.Service.startForeground (Service.java:695)
at com.guichaguri.trackplayer.service.metadata.MetadataManager.updateNotification (MetadataManager.java:298)
at com.guichaguri.trackplayer.service.metadata.MetadataManager.setActive (MetadataManager.java:286)
at com.guichaguri.trackplayer.service.MusicManager.onPlay (MusicManager.java:149)
at com.guichaguri.trackplayer.service.player.ExoPlayback.onPlayerStateChanged (ExoPlayback.java:263)
at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.notifyListeners (ExoPlayerImpl.java:794)
at com.google.android.exoplayer2.ExoPlayerImpl.updatePlaybackInfo (ExoPlayerImpl.java:708)
at com.google.android.exoplayer2.ExoPlayerImpl.setPlayWhenReady (ExoPlayerImpl.java:240)
at com.google.android.exoplayer2.SimpleExoPlayer.updatePlayWhenReady (SimpleExoPlayer.java:1183)
at com.google.android.exoplayer2.SimpleExoPlayer.setPlayWhenReady (SimpleExoPlayer.java:891)
at com.guichaguri.trackplayer.service.player.ExoPlayback.play (ExoPlayback.java:118)
at com.guichaguri.trackplayer.module.MusicModule.lambda$play$9 (MusicModule.java:278)
at com.guichaguri.trackplayer.module.-$$Lambda$MusicModule$D1eTyp9ZHxuIrhqVlEnqzXQTfwY.run (Unknown Source:4)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:193)
at android.app.ActivityThread.main (ActivityThread.java:6680)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
Caused by: android.os.RemoteException:
at com.android.server.am.ActivityManagerService.enforcePermission (ActivityManagerService.java:9203)
at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked (ActiveServices.java:1189)
at com.android.server.am.ActiveServices.setServiceForegroundLocked (ActiveServices.java:870)
at com.android.server.am.ActivityManagerService.setServiceForeground (ActivityManagerService.java:20472)
at android.app.IActivityManager$Stub.onTransact (IActivityManager.java:976)
* Also, the line numbers for ExoPlayback.java will not match up with your latest dev, as I've forked w/ my own code to get audio levels. This is so I could display a live average volume level in my app. This is completely unrelated, but below's some of my code if you're interested in adding this as a feature in your package! (Android only at the moment) *
public String getLevels() {
if (!initializedLevels) {
if (player.getAudioComponent().getAudioSessionId() == 0) {
return null;
}
this.visualizer = new Visualizer(player.getAudioComponent().getAudioSessionId());
this.visualizer.setEnabled(true);
this.captureSize = visualizer.getCaptureSize();
initializedLevels = true;
}
byte[] fft = new byte[captureSize];
this.visualizer.getFft(fft);
String byteData = "";
for(byte b: fft){
byteData = byteData + (int) b + ",";
}
return byteData;
}
May be related to this: https://stackoverflow.com/questions/52382710/permission-denial-startforeground-requires-android-permission-foreground-servic
Will report back soon
That should be it. You must be targeting API 28, right?
Yep targeting 28.
My users reported that the issue has been fixed and their app isn't crashing anymore after I added the FOREGROUND_SERVICE permission to my own app. Thanks for the commit and your work, again! =]
You did all the work on this one, all props to you! Thanks
Most helpful comment
That should be it. You must be targeting API 28, right?