Skip to content
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

refactor(android): webview permission/storage handling #12105

Merged
merged 7 commits into from Oct 8, 2020

Conversation

jquick-axway
Copy link
Contributor

@jquick-axway jquick-axway commented Sep 19, 2020

JIRA:

Summary:

  • TIMOB-28057, TIMOB-27138 Modified WebView HTML <input/> handling:
    • Only supported on Android 5.0 and higher. (This is a limitation on Google's end. The old openFileChooser() method hack does not work on Android 4.4.)
    • Added "capture" attribute support to capture photos/videos via camera.
    • Honors Android 10 "scoped storage". (Replaced usage of getExternalStoragePublicDir() with MediaStore.)
    • No longer requires WRITE_EXTERNAL_STORAGE permission.
    • Now automatically prompts user for CAMERA permission if needed.
  • TIMOB-25854 Added audio/video WebRTC support to WebView.
    • Will automatically prompt for CAMERA or RECORD_AUDIO permission if needed.
  • TIMOB-28140 HTML Geolocation API now prompts for ACCESS_FINE_LOCATION permission if needed.

WebView Photo Selection Test:
(This test won't work on Android 4.4.)

  1. Set up project's "tiapp.xml" as shown below.
  2. Use "WebViewSelectImageTest.js" attached to TIMOB-28057 as your "app.js".
  3. Build and run on Android 11.
  4. Tap on the "Select Image" button.
  5. Choose a photo.
  6. Verify Titanium app's WebView shows selected photo.
  7. Repeat steps 4-6 on Android 5.0.
<ti:app>
	<android>
		<manifest>
			<uses-sdk android:targetSdkVersion="30"/>
			<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
		</manifest>
	</android>
</ti:app>

WebView Video Selection Test:
(This test won't work on Android 4.4.)

  1. Set up project's "tiapp.xml" as shown below.
  2. Use "WebViewSelectVideoTest.js" attached to TIMOB-28057 as your "app.js".
  3. Build and run on Android 11.
  4. Tap on the "Select Video" button.
  5. Choose a video.
  6. Verify Titanium app's WebView shows a video player.
  7. Tap on the video to play it.
  8. Repeat steps 4-7 on Android 5.0.
<ti:app>
	<android>
		<manifest>
			<uses-sdk android:targetSdkVersion="30"/>
			<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
		</manifest>
	</android>
</ti:app>

WebView Photo Capture Test:
(This test won't work on Android 4.4.)

  1. Set up project's "tiapp.xml" as shown below.
  2. Use "WebViewCaptureImageTest.js" attached to TIMOB-27138 as your "app.js".
  3. Build and run on Android 11.
  4. Tap on the "Capture Image" button.
  5. If the app requests permission, then grant it.
  6. Verify the camera appears and take a picture.
  7. Verify Titanium app's WebView shows the picture taken.
  8. Repeat steps 4-7 on Android 5.0.
<ti:app>
	<android>
		<manifest>
			<uses-sdk android:targetSdkVersion="30"/>
			<uses-permission android:name="android.permission.CAMERA"/>
			<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
		</manifest>
	</android>
</ti:app>

WebView Video Capture Test:
(This test won't work on Android 4.4.)

  1. Set up project's "tiapp.xml" as shown below.
  2. Use "WebViewCaptureVideoTest.js" attached to TIMOB-27138 as your "app.js".
  3. Build and run on Android 11.
  4. Tap on the "Capture Video" button.
  5. If the app requests permission, then grant it.
  6. Verify the camera appears and record video.
  7. Verify Titanium app's WebView shows a video player.
  8. Tap on the video to play it.
  9. Repeat steps 4-8 on Android 5.0.
<ti:app>
	<android>
		<manifest>
			<uses-sdk android:targetSdkVersion="30"/>
			<uses-permission android:name="android.permission.CAMERA"/>
			<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
		</manifest>
	</android>
</ti:app>

WebView Geolocation Permission Test:

  1. Set up project's "tiapp.xml" as shown below.
  2. Set up "app.js" with the below code.
  3. Build and run on Android 6.0 or higher.
  4. Verify Google Maps appears.
  5. Tap on the "Your Location" button in the map.
  6. Verify a dialog appears asking you for permission. (This is the feature we're adding.)
  7. Grant permission.
  8. Verify map shows your current location.
<ti:app>
	<android>
		<manifest>
			<uses-sdk android:targetSdkVersion="30"/>
			<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
			<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
		</manifest>
	</android>
</ti:app>
var window = Ti.UI.createWindow();
window.add(Ti.UI.createWebView({
	url: 'https://maps.google.com',
	borderRadius: 1,
}));
window.open();

WebRTC Test:

  1. Set up project's "tiapp.xml" as shown below.
  2. Set up "app.js" with the below code.
  3. Build and run on Android 6.0 or higher.
  4. Tap on the webpage's "Camera" button.
  5. Verify a permission dialog appears and grant permission. (This is new.)
  6. Verify that a camera feed appears in the webpage.
  7. Tap on the "Stop" button.
  8. Tap on the "Microphone" button.
  9. Verify a permission dialog appears and grant permission. (This is new.)
  10. Talk to the phone and verify it repeats your voice. (You might need to raise the volume and use headphones.)
  11. Back out of the app.
  12. Tap and hold the app icon.
  13. Tap on the "App info" popup option.
  14. Tap on "Permissions".
  15. Deny all "Allowed" permissions.
  16. Restart the app.
  17. Tap on the webpage's "Camera & Microphone" button.
  18. Verify it prompts you for "video" and "record audio" permissions. (Will likely display 2 dialogs.)
  19. Grant permissions to both.
  20. Uncheck the "Volume Mute" checkbox.
  21. Verify you see a video.
  22. Talk to the phone and verify it repeats what you say.
    (Note: The "Screen Capture" option is not supported on Android.)
<ti:app>
	<android>
		<manifest>
			<uses-sdk android:targetSdkVersion="30"/>
			<uses-permission android:name="android.permission.CAMERA"/>
			<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
			<uses-permission android:name="android.permission.RECORD_AUDIO"/>
			<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
		</manifest>
	</android>
</ti:app>
var window = Ti.UI.createWindow();
window.add(Ti.UI.createWebView({
	url: 'https://mozilla.github.io/webrtc-landing/gum_test.html',
}));
window.open();

- Modified HTML <input/> handling:
  * Only supported on Android 5.0 and higher. (This is a limitation on Google's end.)
  * Added "capture" attribute support to capture photos/videos.
  * Honors Android 10 "scoped storage".
  * No longer requires WRITE_EXTERNAL_STORAGE permission.
  * Now automatically prompts for CAMERA permission if needed.
- Added audio/video WebRTC support to WebView.
  * Will automatically prompt for CAMERA or RECORD_AUDIO permission if needed.
- HTML Geolocation API now automatically prompts user for ACCESS_FINE_LOCATION permission if needed.

Fixes TIMOB-28057, TIMOB-25854, TIMOB-28140, TIMOB-27138
@build
Copy link
Contributor

build commented Sep 19, 2020

Messages
📖

💾 Here's the generated SDK zipfile.

📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.
📖

✅ All tests are passing
Nice one! All 9817 tests are passing.
(There are 984 skipped tests not included in that total)

Generated by 🚫 dangerJS against 3a5fda7

Copy link
Contributor

@garymathews garymathews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: PASS

@ssaddique
Copy link
Contributor

FR: Pass

Test Environment
SDK Ver: 9.2.1.GA, this PR
OS Ver: 10.15.6
Xcode Ver: Xcode 12.0.1
Appc NPM: 5.0.0
Appc CLI: 8.1.1
Node Ver: 10.17.0
NPM Ver: 6.13.6
Java Ver: 1.8.0_162
Devices: Pixel 3a (11.0)
Emulator: Pixel 2 (4.4, 6.0)

@ssaddique ssaddique merged commit a206387 into tidev:master Oct 8, 2020
drauggres pushed a commit to NetrisTV/titanium_mobile that referenced this pull request Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants