open-webrtc-toolkit / owt-client-android

Open WebRTC Toolkit client SDK for Android applications.
https://01.org/open-webrtc-toolkit
Apache License 2.0
195 stars 97 forks source link

Android Q Screen sharing #240

Open xuhaogan opened 4 years ago

xuhaogan commented 4 years ago

Process: owt.sample.conference, PID: 13532 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=100, result=-1, data=Intent { (has extras) }} to activity {owt.sample.conference/owt.sample.conference.MainActivity}: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION at android.app.ActivityThread.deliverResults(ActivityThread.java:4938) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4979) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7562) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) Caused by: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION at android.os.Parcel.createException(Parcel.java:2074) at android.os.Parcel.readException(Parcel.java:2042) at android.os.Parcel.readException(Parcel.java:1990) at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:231) at android.media.projection.MediaProjection.(MediaProjection.java:58) at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:104) at org.webrtc.ScreenCapturerAndroid.startCapture(ScreenCapturerAndroid.java:107) at owt.base.MediaStreamFactory.createMediaStream(MediaStreamFactory.java:52) at owt.base.LocalStream.(LocalStream.java:45) at owt.sample.conference.MainActivity.initDataResult(MainActivity.java:582) at owt.sample.conference.MainActivity.onActivityResult(MainActivity.java:571) at android.app.Activity.dispatchActivityResult(Activity.java:8249) at android.app.ActivityThread.deliverResults(ActivityThread.java:4931) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4979)  at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)  at android.os.Handler.dispatchMessage(Handler.java:107)  at android.os.Looper.loop(Looper.java:224)  at android.app.ActivityThread.main(ActivityThread.java:7562)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)  Caused by: android.os.RemoteException: Remote stack trace: at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:476) at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:135) at android.os.Binder.execTransactInternal(Binder.java:1021) at android.os.Binder.execTransact(Binder.java:994)

eric-tc commented 3 years ago

Hi i have the same problem. Have you found a solution? Thanks

chenzx commented 1 year ago

I've got the same problem when using OWT android client demo with M104 libwebrtc on Android 10+ emulator in Android Studio.

From the stack trace, seems i need to put new LocalStream call into a foreground service? But how can the local stream ref connected to other code?