diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-10-11 17:12:22 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-11 17:14:34 -0700 |
commit | 3003bada607b64ecf3a405b48da3528c4331e7c6 (patch) | |
tree | 723aaeeaa76760749a0e20e6a61556e38161b472 /core/java | |
parent | 87c6f9a528aa921520da596805607caad76143b4 (diff) | |
parent | d8faf74662f738e25fdb42f75153112ea9c9f1ce (diff) | |
download | frameworks_base-3003bada607b64ecf3a405b48da3528c4331e7c6.zip frameworks_base-3003bada607b64ecf3a405b48da3528c4331e7c6.tar.gz frameworks_base-3003bada607b64ecf3a405b48da3528c4331e7c6.tar.bz2 |
Merge "Check whether ChromeVox is ready before attempting to call it." into jb-mr1-dev
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/webkit/AccessibilityInjector.java | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/core/java/android/webkit/AccessibilityInjector.java b/core/java/android/webkit/AccessibilityInjector.java index d6576e1..357a16e 100644 --- a/core/java/android/webkit/AccessibilityInjector.java +++ b/core/java/android/webkit/AccessibilityInjector.java @@ -96,11 +96,26 @@ class AccessibilityInjector { // Template for JavaScript that performs AndroidVox actions. private static final String ACCESSIBILITY_ANDROIDVOX_TEMPLATE = - "cvox.AndroidVox.performAction('%1s')"; + "(function() {" + + " if ((typeof(cvox) != 'undefined')"+ + " && (typeof(cvox.ChromeVox) != 'undefined')" + + " && (typeof(cvox.AndroidVox) != 'undefined')" + + " && cvox.ChromeVox.isActive) {" + + " return cvox.AndroidVox.performAction('%1s');" + + " } else {" + + " return false;" + + " }" + + "})()"; // JS code used to shut down an active AndroidVox instance. private static final String TOGGLE_CVOX_TEMPLATE = - "javascript:(function() { cvox.ChromeVox.host.activateOrDeactivateChromeVox(%b); })();"; + "javascript:(function() {" + + " if ((typeof(cvox) != 'undefined')"+ + " && (typeof(cvox.ChromeVox) != 'undefined')" + + " && (typeof(cvox.ChromeVox.host) != 'undefined')) {" + + " cvox.ChromeVox.host.activateOrDeactivateChromeVox(%b);" + + " }" + + "})();"; /** * Creates an instance of the AccessibilityInjector based on @@ -776,20 +791,26 @@ class AccessibilityInjector { while (true) { try { if (mResultId == resultId) { + if (DEBUG) + Log.w(TAG, "Received CVOX result"); return true; } if (mResultId > resultId) { + if (DEBUG) + Log.w(TAG, "Obsolete CVOX result"); return false; } final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis; waitTimeMillis = RESULT_TIMEOUT - elapsedTimeMillis; if (waitTimeMillis <= 0) { + if (DEBUG) + Log.w(TAG, "Timed out while waiting for CVOX result"); return false; } mResultLock.wait(waitTimeMillis); } catch (InterruptedException ie) { if (DEBUG) - Log.w(TAG, "Timed out while waiting for CVOX result"); + Log.w(TAG, "Interrupted while waiting for CVOX result"); /* ignore */ } } @@ -805,6 +826,8 @@ class AccessibilityInjector { @JavascriptInterface @SuppressWarnings("unused") public void onResult(String id, String result) { + if (DEBUG) + Log.w(TAG, "Saw CVOX result of '" + result + "'"); final long resultId; try { |