-
-
Notifications
You must be signed in to change notification settings - Fork 283
fix foreground service permission crash #5483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mahibi
wants to merge
1
commit into
master
Choose a base branch
from
bugfix/noid/fixForegroundServicePermissionCrash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
when record_audio permission was not granted, this crash appeared because foreground service must only be started with the granted permission: 2025-10-17 09:56:01.459 14445-14445 AndroidRuntime com.nextcloud.talk2 E FATAL EXCEPTION: main (Ask Gemini) Process: com.nextcloud.talk2, PID: 14445 java.lang.RuntimeException: Unable to start service com.nextcloud.talk.services.CallForegroundService@a9cff99 with Intent { cmp=com.nextcloud.talk2/com.nextcloud.talk.services.CallForegroundService (has extras) }: java.lang.SecurityException: Starting FGS with type microphone callerApp=ProcessRecord{1b5bf24 14445:com.nextcloud.talk2/u0a397} targetSDK=35 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_MICROPHONE] any of the permissions allOf=false [android.permission.CAPTURE_AUDIO_HOTWORD, android.permission.CAPTURE_AUDIO_OUTPUT, android.permission.CAPTURE_MEDIA_OUTPUT, android.permission.CAPTURE_TUNER_AUDIO_INPUT, android.permission.CAPTURE_VOICE_COMMUNICATION_OUTPUT, android.permission.RECORD_AUDIO] and the app must be in the eligible state/exemptions to access the foreground only permission at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5295) at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2580) at android.os.Handler.dispatchMessage(Handler.java:112) at android.os.Looper.loopOnce(Looper.java:268) at android.os.Looper.loop(Looper.java:384) at android.app.ActivityThread.main(ActivityThread.java:8921) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:907) Caused by: java.lang.SecurityException: Starting FGS with type microphone callerApp=ProcessRecord{1b5bf24 14445:com.nextcloud.talk2/u0a397} targetSDK=35 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_MICROPHONE] any of the permissions allOf=false [android.permission.CAPTURE_AUDIO_HOTWORD, android.permission.CAPTURE_AUDIO_OUTPUT, android.permission.CAPTURE_MEDIA_OUTPUT, android.permission.CAPTURE_TUNER_AUDIO_INPUT, android.permission.CAPTURE_VOICE_COMMUNICATION_OUTPUT, android.permission.RECORD_AUDIO] and the app must be in the eligible state/exemptions to access the foreground only permission at android.os.Parcel.createExceptionOrNull(Parcel.java:3242) at android.os.Parcel.createException(Parcel.java:3226) at android.os.Parcel.readException(Parcel.java:3209) at android.os.Parcel.readException(Parcel.java:3151) at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7326) at android.app.Service.startForeground(Service.java:863) at com.nextcloud.talk.services.CallForegroundService.onStartCommand(CallForegroundService.kt:38) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5277) at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2580) at android.os.Handler.dispatchMessage(Handler.java:112) at android.os.Looper.loopOnce(Looper.java:268) at android.os.Looper.loop(Looper.java:384) at android.app.ActivityThread.main(ActivityThread.java:8921) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:907) Caused by: android.os.RemoteException: Remote stack trace: at com.android.server.am.ActiveServices.validateForegroundServiceType(ActiveServices.java:2921) at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2605) at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1859) at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:14552) at android.app.IActivityManager$Stub.onTransact$setServiceForeground$(IActivityManager.java:12183) Signed-off-by: Marcel Hibbe <[email protected]>
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/5483.apk |
rapterjet2004
approved these changes
Oct 17, 2025
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.
when record_audio permission was not granted, this crash appeared because foreground service must only be started with the granted permission:
🖼️ Screenshots
🚧 TODO
🏁 Checklist
/backport to stable-xx.x