fandreuz / TUI-ConsoleLauncher

Linux CLI Launcher for Android
Other
1.24k stars 257 forks source link

Adding the foreground permission #328

Open 4n4l1st-ch4rl3s opened 3 years ago

4n4l1st-ch4rl3s commented 3 years ago

when I was playing the music using the music -play the app crashed and on looking on the crash.txt fit this is what was shown:

java.lang.SecurityException: Permission Denial: startForeground from pid=32393, uid=10062 requires android.permission.FOREGROUND_SERVICE at android.os.Parcel.createException(Parcel.java:2071) at android.os.Parcel.readException(Parcel.java:2039) at android.os.Parcel.readException(Parcel.java:1987) at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6338) at android.app.Service.startForeground(Service.java:707) at ohi.andre.consolelauncher.managers.music.MusicService.onPrepared(Unknown Source:33) at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:3356) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:251) at android.app.ActivityThread.main(ActivityThread.java:7465) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980) Caused by: android.os.RemoteException: Remote stack trace: at com.android.server.am.ActivityManagerService.enforcePermission(ActivityManagerService.java:6442) at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:1332) at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:987) at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:14974) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2875)


I tried using adb to grant the permission but this is what I got: Security exception: Package ohi.andre.consolelauncher has not requested permission android.permission.FOREGROUND_SERVICE

java.lang.SecurityException: Package ohi.andre.consolelauncher has not requested permission android.permission.FOREGROUND_SERVICE at com.android.server.pm.permission.BasePermission.enforceDeclaredUsedAndRuntimeOrDevelopment(BasePermission.java:425) at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:2195) at com.android.server.pm.permission.PermissionManagerService.access$900(PermissionManagerService.java:125) at com.android.server.pm.permission.PermissionManagerService$PermissionManagerServiceInternalImpl.grantRuntimePermission(PermissionManagerService.java:3193) at com.android.server.pm.PackageManagerService.grantRuntimePermission(PackageManagerService.java:6170) at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:1955) at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:230) at android.os.ShellCommand.exec(ShellCommand.java:104) at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22672) at android.os.Binder.shellCommand(Binder.java:884) at android.os.Binder.onTransact(Binder.java:768) at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5104) at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4421) at android.os.Binder.execTransactInternal(Binder.java:1038) at android.os.Binder.execTransact(Binder.java:997)

4n4l1st-ch4rl3s commented 3 years ago

I also tried adding the permission in the manifest file but got this error: java.lang.SecurityException: Permission android.permission.FOREGROUND_SERVICE requested by ohi.andre.consolelauncher is not a changeable permission type at com.android.server.pm.permission.BasePermission.enforceDeclaredUsedAndRuntimeOrDevelopment(BasePermission.java:429) at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:2195) at com.android.server.pm.permission.PermissionManagerService.access$900(PermissionManagerService.java:125) at com.android.server.pm.permission.PermissionManagerService$PermissionManagerServiceInternalImpl.grantRuntimePermission(PermissionManagerService.java:3193) at com.android.server.pm.PackageManagerService.grantRuntimePermission(PackageManagerService.java:6170) at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:1955) at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:230) at android.os.ShellCommand.exec(ShellCommand.java:104) at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22672) at android.os.Binder.shellCommand(Binder.java:884) at android.os.Binder.onTransact(Binder.java:768) at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5104) at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4421) at android.os.Binder.execTransactInternal(Binder.java:1038) at android.os.Binder.execTransact(Binder.java:997)