summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authoralanv <alanv@google.com>2012-10-11 16:48:32 -0700
committeralanv <alanv@google.com>2012-10-11 16:48:32 -0700
commitd8faf74662f738e25fdb42f75153112ea9c9f1ce (patch)
tree1e31823b575c78be1685be0124b99ba7c70a9068 /core/java
parent4574df0c1561609785b3ce994c0135276e4d1b4b (diff)
downloadframeworks_base-d8faf74662f738e25fdb42f75153112ea9c9f1ce.zip
frameworks_base-d8faf74662f738e25fdb42f75153112ea9c9f1ce.tar.gz
frameworks_base-d8faf74662f738e25fdb42f75153112ea9c9f1ce.tar.bz2
Check whether ChromeVox is ready before attempting to call it.
Calls to performAction will immediately return false if ChromeVox is not loaded. Also adds additional debugging output. Bug: 7328657 Change-Id: I5bd7c69ccc9500cebaa4a8c1bf023794f4eebe2e
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/webkit/AccessibilityInjector.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/core/java/android/webkit/AccessibilityInjector.java b/core/java/android/webkit/AccessibilityInjector.java
index 37d84b3..2e62807 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
@@ -787,20 +802,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 */
}
}
@@ -816,6 +837,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 {