calvinckho / capacitor-jitsi-meet

This plugin is used to make video calls using Jitsi video platform (https://meet.jit.si) on iOS and Android using Ionic Capacitor.
84 stars 40 forks source link

Android 14 Permissions #115

Open viking2917 opened 1 month ago

viking2917 commented 1 month ago

As described in

https://github.com/calvinckho/capacitor-jitsi-meet/issues/109,

If you leave the manifest entries for

  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

in the app, you need to provide a video of the features used in order to pass app review, but it is difficult to do so.

As with #109, I removed those permissions with

<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" />

in my AndroidManifest.xml.

But with that, the app crashes with the error: 07-24 08:53:14.830 13882 13882 E AndroidRuntime: Caused by: java.lang.SecurityException: Starting FGS with type mediaPlayback callerApp=ProcessRecord{625e8af 13882:com.ionicframework.bookship/u0a529} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK]

Full log below:

Is there a way to make these permissions optional but not have the app crash?

--------- beginning of crash
07-24 08:53:14.830 13882 13882 E AndroidRuntime: FATAL EXCEPTION: main
07-24 08:53:14.830 13882 13882 E AndroidRuntime: Process: com.ionicframework.bookship, PID: 13882
07-24 08:53:14.830 13882 13882 E AndroidRuntime: java.lang.RuntimeException: Unable to create service org.jitsi.meet.sdk.JitsiMeetOngoingConferenceService: java.lang.SecurityException: Starting FGS with type mediaPlayback callerApp=ProcessRecord{625e8af 13882:com.ionicframework.bookship/u0a529} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK] 
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.app.ActivityThread.handleCreateService(ActivityThread.java:5111)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2506)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:230)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:319)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8919)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
07-24 08:53:14.830 13882 13882 E AndroidRuntime: Caused by: java.lang.SecurityException: Starting FGS with type mediaPlayback callerApp=ProcessRecord{625e8af 13882:com.ionicframework.bookship/u0a529} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK] 
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.os.Parcel.createExceptionOrNull(Parcel.java:3069)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.os.Parcel.createException(Parcel.java:3053)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:3036)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:2978)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7234)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.app.Service.startForeground(Service.java:862)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at org.jitsi.meet.sdk.JitsiMeetOngoingConferenceService.onCreate(JitsiMeetOngoingConferenceService.java:136)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.app.ActivityThread.handleCreateService(ActivityThread.java:5098)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    ... 9 more
07-24 08:53:14.830 13882 13882 E AndroidRuntime: Caused by: android.os.RemoteException: Remote stack trace:
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at com.android.server.am.ActiveServices.validateForegroundServiceType(ActiveServices.java:2741)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2452)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1797)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:15948)
07-24 08:53:14.830 13882 13882 E AndroidRuntime:    at android.app.IActivityManager$Stub.onTransact$setServiceForeground$(IActivityManager.java:11974)
07-24 08:53:14.830 13882 13882 E AndroidRuntime: 
calvinckho commented 1 month ago

See https://github.com/calvinckho/capacitor-jitsi-meet/issues/109

viking2917 commented 1 month ago

@calvinckho thanks, yes, I had read #109 before filing this. When I followed the recommendations there (removing the permissions in AndroidManifest.xml), the app crashed, complaining per the above about required permission. So it seems that, (at least on a Samsung S22 / Android 14), one cannot remove the permissions, at least that was my experience.

I did have an interesting learning on the submissions however. I decided to add the permissions back and record the explanatory video. Which took a bit of time but I did. Then I was going to submit, and it requires a video for the _PROJECTION permission as well, and after much experimentation I could not get PIP to work, which is what I think that permission is for. So I tried removing the _PROJECTION permission, but leaving the _PLAYBACK permission. That seems to run JITSI OK, then when I submitted the app, it no longer asked me for a video documenting the permission! I do not know if that will continue or whether I just got lucky somehow, but for the moment, this is working for me:

  1. add <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" tools:node="remove" /> to manifest to remove that permission.
  2. leave the FOREGROUND_SERVICE_MEDIA_PLAYBACK permission the app.
  3. submit and run

and then Jitsi (mostly) runs OK.

I guess the fact that my app crashes if I remove the permissions is not strictly a bug with your plugin, so probably this can be closed, I just wanted to document that removing the permissions does not seem to work, at least for me.

(I am still having trouble with JITSI periodically loading the video window with the video muted, and then not allowing the user to turn on video - user is stuck in "avatar" mode - but I think that has nothing to do with your plugin. I am finding JITSI increasingly erratic and unreliable, it's frustrating (for example, this video muted problem, sometimes, if I close the app and restart, the problem just goes away. (FWIW I use the paid version of JITSI server at 8x8.vc, not the meet.jitsi.com).)

calvinckho commented 1 month ago

I forgot to ask, @viking2917, which version of the plugin are you using?

viking2917 commented 1 month ago

@calvinckho 6.0.0 and Capacitor 6. Thank you!

viking2917 commented 1 month ago

BTW FWIW the "video muted" thing is a bug in JITSI, I am told by their support people, to be fixed in the next two weeks. https://github.com/jitsi/jitsi-meet-sdk-samples/issues/239

viking2917 commented 4 weeks ago

@calvinckho I was going to do a PR for the new SDK 10 that was just released (https://github.com/jitsi/jitsi-meet-release-notes/blob/master/CHANGELOG-MOBILE-SDKS.md#1000-2024-08-07), but I came here and found out you'd already integrated it :) Thank you.

I have integrated the beta version into my app, and it and the new SDK appear to be working normally, except perhaps the following:

On iOS, I had to manually edit my Podfile.lock file to change SDK 9.2.2 to 10.0.0. The plugin install did not seem to do that. I do not know if that is expected or not. After some pod gymnastics everything built and ran ok.

On Android, if you open the video chat, and go to Settings, then look at "SDK version" at the bottom of the screen, the version # is blank, so I cannot tell for certain that I have the right SDK built into my app - is there another way to check that? (on iOS the version number shows correctly as 10.0.0). I assume that is some kind of a bug in the SDK. (I was on Galaxy S22 with Android 14)

calvinckho commented 4 weeks ago

@viking2917 thanks for testing the beta version. I will release 6.1.0 shortly after incorporating your feedbacks...

For the iOS deployment, I always see this warning when I run npx cap update:

You have either:

Inside /ios/App, I would then update the source repos using 'pod repo update', and then run 'pod update JitsiMeetSDK'. This will then update the JitsiMeetSDK version correctly each time I do it. Do you have a better suggestion which can avoid this hassle?

I do not see the version number 10.0.0 on the SDK settings page for iOS and Android. Can you show me a screenshot of your iOS settings page?

calvinckho commented 4 weeks ago

My iOS setting page looks like this:

Screenshot 2024-08-09 at 1 43 30 AM
viking2917 commented 4 weeks ago

@calvinckho I deleted the old production plugin, installed the beta plugin, and had more or less the same error you got:

You have either:
* out-of-date source ...

I did a bunch of pod update, pod repo update, pod install, etc, and none of it really solved the problem until I hand-edited my Podfile.lock to remove references to Jitsi SDK 9.2.2 and replace them with references to 10.0.0. Then more pod repo update etc, and once that settled down, I have not had to do it any more.

ChatGPT claims (😆) that pod install --repo-update should update the podfile.lock file. I did not have that experience, but I may have done something out of order. You might try that and see if it sorts things out. I am not very experienced with iOS development so I am not really sure the proper way to do this.

Attached are screenshots of the JITSI component menu and settings page. The iOS one shows the correct info, the Android one has the SDK version as blank. (My app's build version is 10.1.5, which you can see on the settings page, not to be confused with the SDK version). The fact that your screenshot does not have settings at all is confusing to me, and perhaps means you don't have SDK 10 installed?

iOS: IMG_0575 IMG_0576

Android:

Screenshot_20240809-161840_Bookship Screenshot_20240809-161949_Bookship

viking2917 commented 4 weeks ago

One additional comment, for others who might encounter it. I have maintained my strategy of removing the android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION from the Android manifest and keeping the FOREGROUND_SERVICE_MEDIA_PLAYBACK permission. Last time when I submitted, I was not required to upload a video demonstrating the feature. This time, however, I was forced to. I have added a video and am awaiting a review to see if I get past that hurdle.