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

fix(android): Catch WebView exceptions and prompt user to install WebView #13140

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

darcywong00
Copy link
Contributor

Replaces #13101
Fixes: #11560
Fixes: KEYMAN-ANDROID-5E9
Fixes: KEYMAN-ANDROID-6MA

KMManager.KMKeyboard extends WebView. On systems where the system WebView is missing or disabled, this causes the constructor to throw an AndroidRuntimeException.

This PR updates the areas where WebViews are used, and catches those missing WebView exceptions. Also, the "Update Chrome" banner is refactored to prompt the user to install/enable WebView or Chrome accordingly.
Since KMManager doesn't initialize, the Keyman app is in degraded functionality (no keyboard displayed)

Screenshots
Install WebView
Note: this was generated with temporary test code to make WebViewUtils.getSystemWebViewStatus report webView not installed

API 31 install webview

Enable WebView
WebView installed but has been disabled
API 31 enable webview

Update Chrome
same as before
API 21 update Chrome

Additional Info on the Changes

KMManager and friends

  • KMKeyboard constructor throws AndroidRuntimeException when WebView not installed and enabled. This is now caught in KMManager
  • Since KMManager isn't properly initialized, add additional error handling downstream

MainActivity

  • Refactor checkChromeVersion to prompt the user to: install WebView, enable WebView, or install Chrome

SystemKeyboard

  • The guidance on #13101 when the SystemKeyboard fails to initialize was show the IME picker instead of a temporary Toast notification.
    I tried, but the IME picker gets hidden by the front application. So I opted to keep the Toast notification that WebView needs to be installed

User Testing

Setup - For each test, install the PR build of Keyman for Android on an Android device/emulator.
System navigation on a modern Android device/emulator (API 31+) to enable/disable the system WebView:

  • Go to system Settings --> Apps --> All apps --> Android System WebView
  • On the Android SystemWebView page, click "Enable" or "Disable" as directed and exit Settings

  • TEST_INSTALL_CHROME - Verifies user prompted to install/update Chrome
  1. Install Keyman for Android on an Android emulator of API 21 (Android 5.1). This emulator has an old version of Chrome
  2. When Keyman launches, dismiss the "Get Started" window.
  3. Verify keyboard not displayed (KMManager not initalized). Ignore keyboard Toast error which is a Javascript error involving the old Chrome version.
  4. Verify the Keyman app has a prompt for the user to install Chrome
  5. Click the "Install Chrome" button
  6. Verify the device goes to the Play Store page for Chrome
  • TEST_ENABLE_WEBVIEW - Verifies user prompted to enable Android WebView
  1. On a modern Android device/emulator (API 31+), follow the setup steps to disable the system WebView
  2. Install the PR build of Keyman for Android
  3. When Keyman launches, dismiss the "Get Started" window
  4. Verify keyboard not displayed (KMManager not initialized)
  5. Verify the Keymann app has a prompt for the user to enable WebView
  6. Click the "Enable WebView" button
  7. Verify the device goes to the system Settings page for Android System WebView
  8. Click "Enable" to enable WebView
  9. Close and relaunch Keyman for Android
  10. When Keyman launches, dismiss the "Get Started" window
  11. Verify keyboard is now displayed
  12. Verify keyboard and suggestion banner function fine.
  • TEST_SYSTEM_KEYBOARD - Verifies system keyboard is handled when WebView disabled
  1. On a modern Android device/emulator (API 31)+, follow the setup steps to disable the system WebView
  2. Install the PR build of Keyman for Android
  3. From the "Get Started" menu, enable Keyman as a system keyboard and set as the default keyboard.
  4. Browse to a separate app (e.g. Contacts) and select a text area
  5. With the keyboard switcher on the navigation bar, switch to Keyman
  6. Verify Toast notification "Keyman requires WebView to be installed" is displayed

@darcywong00 darcywong00 added this to the B18S1 milestone Feb 6, 2025
@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed labels Feb 6, 2025
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Feb 6, 2025

User Test Results

Test specification and instructions

Retesting Template
@keymanapp-test-bot retest TEST_SYSTEM_KEYBOARD

Test Artifacts

@dinakaranr
Copy link

Test Results

I tested this issue with the attached keyman "18.0.186-alpha-test-13140" build(06/02/2025) on Android 14(Samsung A23 Physical device). I'm sharing my observation here.

  • TEST_INSTALL_CHROME (Passed):
  1. Open the Android studio and Open the Android emulator of API 21 (Android 5.1)
  2. Installed the Keyman-18.0.186-alpha-test-13140.apk
  3. When Keyman launches, dismiss the "Get Started" window.
  4. Verified that the keyboard does not display. (Ignore the keyboard Toast error which is a Javascript error )
  5. Verified that the Keyman app has a prompt for the user to "Update Chrome"
  6. Click the "Update Chrome" button
  7. Verified that the device goes to the Play Store page for Chrome
    It works well. Thank you.
  • TEST_ENABLE_WEBVIEW (Passed):
  1. Open the Android device.
  2. Go to System Settings --> Apps --> All apps --> Android System WebView
  3. Follow the setup steps to disable the system WebView app.
  4. Install the "Keyman-18.0.186-alpha-test-13140" PR build for android
  5. When Keyman launches, dismiss the "Get Started" window
  6. Verified that the keyboard does not display.
  7. Verified that the Keyman app has a prompt for the user to "Update Chrome"
  8. Click the "Enable WebView" button
  9. Verified that the device goes to the System Settings page for Android System WebView
  10. Click "Enable" to enable WebView
  11. Close and relaunch Keyman for Android
  12. When Keyman launches, dismiss the "Get Started" window
  13. Verified that the keyboard is now displayed
  14. Verified that the keyboard and suggestion banner function fine.
    It works well. Thank you.
  • TEST_SYSTEM_KEYBOARD (Failed):
  1. Open the Android device.
  2. Go to System Settings --> Apps --> All apps --> Android System WebView
  3. Follow the setup steps to disable the system WebView app.
  4. Install the "Keyman-18.0.186-alpha-test-13140" PR build for android
  5. Open the keyman app.
  6. The "Get Started" menu appears, enable Keyman as a system keyboard and set as the default keyboard.
  7. Open the Keep Note app and select a test area.
  8. Verified that the keyboard does not appear
  9. Select the Google keyboard by clicking the navigation bar.
  10. Verified that the Gboard appear
  11. Select the keyman keyboard by clicking the navigation bar.
  12. Verified that the blank screen appear.
  13. Verified that the Toast notification "Keyman requires WebView to be installed" is not displayed.
  14. Actual Results: It is not showing the toast notification. but the Android emulator is working fine and showing the toast message.
    Please take a look at the video file for the above scenario. (https://github.com/user-attachments/assets/e8db3a51-f9df-47a5-98e5-46e1f5c94f8e)
    Another scenario(https://github.com/user-attachments/assets/42cd206d-54b4-4ef3-ac72-03ecfdbff30c)

@keymanapp-test-bot keymanapp-test-bot bot added user-test-failed and removed user-test-required User tests have not been completed labels Feb 6, 2025
@darcywong00
Copy link
Contributor Author

back to draft to rework the system keyboard notification.

@darcywong00 darcywong00 marked this pull request as draft February 7, 2025 03:02
…/android/check-webview

# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

bug(android): lack of handling when WebView provider unavailable
2 participants