Crashes After Removing Foreground Service Permissions From Manifest

Description
Hi,

We removed the FOREGROUND_SERVICE_MEDIA_PROJECTION and FOREGROUND_SERVICE_MEDIA_PLAYBACK permissions from our app as directed in this post. After doing that we began to see two crashes in our app relating to the foreground service permissions. Their stack traces are below in the additional context section. We have been unable to reproduce them on our own thus far.

A few notes about our app:

  • We disable screen sharing using the setHideShareButtonInMeetingToolbar method. However user’s may still be in a zoom meeting where screen sharing is being used if the person sharing the screen is using the desktop zoom app.

  • The exact XML changes we made were the same as what was described in the linked post but I’ll post them here as well for clarity

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" tools:node="remove" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" tools:node="remove" />
<application
        {some things here that don't need to show}
        >

    <service
            android:name="com.zipow.videobox.share.ScreenShareServiceForSDK"
            android:exported="false"
            android:foregroundServiceType="microphone|connectedDevice"
            tools:replace="android:foregroundServiceType"
            android:label="Zoom"/>

</application>

Which Android Meeting SDK version?
6.1.1

Smartphone (please complete the following information):

  • Device: Galaxy S23
  • OS: Android 14

Additional context
Stack traces for the two crashes:

Fatal Exception: java.lang.RuntimeException: Unable to create service com.zipow.videobox.share.ScreenShareServiceForSDK: java.lang.IllegalArgumentException: foregroundServiceType 0x00000002 is not a subset of foregroundServiceType attribute 0x00000090 in service element of manifest file
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:5111)
       at android.app.ActivityThread.-$$Nest$mhandleCreateService()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2506)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8919)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

Caused by java.lang.IllegalArgumentException: foregroundServiceType 0x00000002 is not a subset of foregroundServiceType attribute 0x00000090 in service element of manifest file
       at android.os.Parcel.createExceptionOrNull(Parcel.java:3073)
       at android.os.Parcel.createException(Parcel.java:3053)
       at android.os.Parcel.readException(Parcel.java:3036)
       at android.os.Parcel.readException(Parcel.java:2978)
       at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7234)
       at android.app.Service.startForeground(Service.java:862)
       at us.zoom.proguard.dn$$ExternalSyntheticApiModelOutline0.m(D8$$SyntheticClass)
       at us.zoom.sdk.SDKNotificationMgr.showConfNotificationForSDK(SDKNotificationMgr.java:128)
       at us.zoom.sdk.SDKNotificationMgr.showConfNotificationForSDK(SDKNotificationMgr.java:4)
       at com.zipow.videobox.share.ScreenShareServiceForSDK.onCreate(ScreenShareServiceForSDK.java:7)
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:5098)
       at android.app.ActivityThread.-$$Nest$mhandleCreateService()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2506)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8919)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Fatal Exception: java.lang.RuntimeException: Unable to create service com.zipow.videobox.share.ScreenShareServiceForSDK: java.lang.SecurityException: Starting FGS with type microphone callerApp=ProcessRecord{64db24d 402:com.blank.event/u0a734} targetSDK=34 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.handleCreateService(ActivityThread.java:5111)
       at android.app.ActivityThread.-$$Nest$mhandleCreateService()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2506)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8919)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

Caused by java.lang.SecurityException: Starting FGS with type microphone callerApp=ProcessRecord{64db24d 402:com.blank.event/u0a734} targetSDK=34 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:3069)
       at android.os.Parcel.createException(Parcel.java:3053)
       at android.os.Parcel.readException(Parcel.java:3036)
       at android.os.Parcel.readException(Parcel.java:2978)
       at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7234)
       at android.app.Service.startForeground(Service.java:862)
       at us.zoom.proguard.dn$$ExternalSyntheticApiModelOutline0.m(D8$$SyntheticClass)
       at us.zoom.sdk.SDKNotificationMgr.showConfNotificationForSDK(SDKNotificationMgr.java:128)
       at us.zoom.sdk.SDKNotificationMgr.showConfNotificationForSDK(SDKNotificationMgr.java:4)
       at com.zipow.videobox.share.ScreenShareServiceForSDK.onCreate(ScreenShareServiceForSDK.java:7)
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:5098)
       at android.app.ActivityThread.-$$Nest$mhandleCreateService()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2506)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8919)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

@elaine.ku @donte.zoom @carson.zoom We would really appreciate any insight you might have on this. Thanks a lot!

Hi @elaine.ku @donte.zoom @carson.zoom ,

Just wanted to follow up on this one as we have been to reproduce the crashes now. There are three ways we have been able to reproduce them consistently and they specifically happen in webinars and when using a device with android 14 or 15. We can send the sdk logs for the crashes upon request if it would be helpful.

Below are three ways we’ve found for reproducing them:

First

  1. Clear storage and cache of app
  2. Uninstall and reinstall app
  3. Enter webinar
  4. Deny notification permission when prompted
  5. Accept find, connect, and determine relative position of nearby devices permission when prompted
  6. Accept phone call permission when prompted
  7. Crash

Second

  1. Enter webinar
  2. Connect bluetooth headphones
  3. Crash

Third

  1. Connect bluetooth headphones
  2. Enter webinar
  3. Crash

Thanks again for any assistance you can provide!

Hi @dan1994 ,

Seems like you’re using our Zoom UI instead of custom UI. Our Zoom UI will request the RECORD_AUDIO permission after you join the meeting which will cause the issue here. Please try to request for RECORD_AUDIO before you join the meeting and check whether the crash still exists.
Thank you,

cc: @Guangda since you’re facing the same issue here.

Elaine

Hi @elaine.ku ,

Thanks for your suggestion! I’m actually Dan’s colleague and we are working on solving the issue for the same app.

As I mentioned in another thread. We were able to prevent the crashes by prompting users the permissions requests before initiating the Zoom meeting.

From our testing, only prompting the RECORD_AUDIO permission before Zoom is initialized can only prevent one of the crashes. We have to also prompt the Manifest.permission_group.NEARBY_DEVICES and Manifest.permission_group.PHONE to prevent all crashes. Though this is a bit hacky and we are wondering if there is any better way to address this? Or if Zoom developers have any plans to fix these crashes in a new SDK version?

Thanks for the help!

Guangda

Hi @Guangda ,

Our Zoom default UI is the same as our Zoom client and we follow Zoom client’s behavior. We’ll only request the user’s audio permission once the user joins the meeting and connects to the audio device.
Removing the screen share service in the application is more of a customized feature for your application. We suggest you add the workaround to solve this case when using the Zoom UI or use the custom UI to design the whole application behavior.
Thank you.

Elaine

Hi @elaine.ku
We already have RECORD_AUDIO permission but app crashes after upgrading SDK to 6.2.3, earlier it was not crashing.
When a user click on audio icon to start audio, it gives two options/popups.
a) use WiFi or mobile data
b) dial in audio
When select the option a) WiFi or mobile data the app gets crashed.