[TIMOB-25854] Android: Grant WebView permissions for Audio/Video WebRTC streams
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-11-25T15:26:08.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.3.0 |
Components | Android |
Labels | audio, engTriage, permissions, video, webview |
Reporter | Michael Gangolf |
Assignee | Joshua Quick |
Created | 2018-03-11T18:33:18.000+0000 |
Updated | 2020-11-25T15:26:08.000+0000 |
Description
*Problem*
When opening a WebRTC streaming page in an Android Webview the camera won't be visible since the permissions are not granted in the Webview itself.
*How to/Example*
* Go to https://palava.tv/ and click "secret conference"
* use this url for the webview
[PALAVA_URL]
* App will connect to this conference room
var win = Ti.UI.createWindow({
title: 'Form',
backgroundColor: 'blue'
});
var www = Ti.UI.createWebView({
url: "[PALAVA URL]"
});
win.add(www);
var btn = Ti.UI.createButton({
title:"refresh",
bottom:10
})
btn.addEventListener("click",function(){
www.url = "[PALAVA_URL]";
})
win.add(btn);
win.open();
Add the permissions to tiapp.xml
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest >
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.CAMERA"/>
</manifest>
</android>
*Current status*
* Not working with 7.0.2.GA and 7.1.0 (master)
*Test env*
* Android 7
* HTC A9
*Solution*
* Grand permission in Webview
Attachments
File | Date | Size |
---|---|---|
webrtc.mp4 | 2018-03-11T18:43:23.000+0000 | 244306 |
PR: https://github.com/appcelerator/titanium_mobile/pull/9928 webrtc.mp4 shows a Chromium browser with my phone connected using a webview
Hello, I was able to verify the issue in Android 8.0.0 With SDK 7.0.2.GA. Need Audio/Video permission. Thanks.
PR put on hold during more API design required. See details in the linked PR.
This applies also to pages using User gets only the file picker, no dialog to select camera or gallery and no user prompt to grant external storage and camera permissions. If those permissions are manually enabled by device's App Settings everything works ok
[~nipoul] if you can enable them in the app settings you could also use the normal camera/file permissions dialog (Ti.Android.requestPermissions) to enable them.
You can use request permissions and then it would be ok, but you don't want to do that before the user is about to use the camera and there is no clean way to figure out that the user clicked on . This should be handled by TiWebChromeClient
Thats true. But at least you can use the workaround before. For the WebRTC part there is no workaround because you can't enable that permission by hand. But you are right, it should be taken into consideration when creating a new PR
@Joshua Quick Do you think I should make another ticket for camera/storage permissions or do you plan to include those as well?
I've just come up against this issue trying to do something simple with webRTC in a webView. Could this be part of a solution? https://developer.android.com/reference/android/webkit/WebChromeClient.html#onPermissionRequest(android.webkit.PermissionRequest)
public void onPermissionRequest (PermissionRequest request)
Notify the host application that web content is requesting permission to access the specified resources and the permission currently isn't granted or denied. The host application must invoke PermissionRequest#grant(String[]) or PermissionRequest#deny(). If this method isn't overridden, the permission is denied.@kosso: see the PR for more details: https://github.com/appcelerator/titanium_mobile/pull/9928 There I was using
onPermissionRequest
which "solves" the problem but it will allow all permissions and doesn't ask the user. A better system with a user-permission needs to be addedThis can also be tested with...
Mozilla's webpage will test WebRTC for video-only, audio-only, and video+audio. Their webpage also has a test for WebRTC screensharing, but there doesn't appear to be a way of supporting this via Google's Java
WebView
.PR (master): https://github.com/appcelerator/titanium_mobile/pull/12105
FR passed for this part of the PR
*Closing ticket*. Fix verified in SDK version
9.3.0.v20201125050632
. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/12105