am 41bfb75f: Merge "Only inject accessibility when speaking service enabled." into jb-mr1-dev
* commit '41bfb75f7c76588239ed5d2d4e38aeb1762ff348': Only inject accessibility when speaking service enabled.
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.webkit;
|
package android.webkit;
|
||||||
|
|
||||||
|
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.annotation.Widget;
|
import android.annotation.Widget;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
@@ -1738,8 +1739,21 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
|
|||||||
event.setMaxScrollY(Math.max(convertedContentHeight - adjustedViewHeight, 0));
|
event.setMaxScrollY(Math.max(convertedContentHeight - adjustedViewHeight, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAccessibilityEnabled() {
|
private boolean isAccessibilityInjectionEnabled() {
|
||||||
return AccessibilityManager.getInstance(mContext).isEnabled();
|
final AccessibilityManager manager = AccessibilityManager.getInstance(mContext);
|
||||||
|
if (!manager.isEnabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Accessibility scripts should be injected only when a speaking service
|
||||||
|
// is enabled. This may need to change later to accommodate Braille.
|
||||||
|
final List<AccessibilityServiceInfo> services = manager.getEnabledAccessibilityServiceList(
|
||||||
|
AccessibilityServiceInfo.FEEDBACK_SPOKEN);
|
||||||
|
if (services.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AccessibilityInjector getAccessibilityInjector() {
|
private AccessibilityInjector getAccessibilityInjector() {
|
||||||
@@ -3925,7 +3939,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
|
|||||||
|
|
||||||
// reset the flag since we set to true in if need after
|
// reset the flag since we set to true in if need after
|
||||||
// loading is see onPageFinished(Url)
|
// loading is see onPageFinished(Url)
|
||||||
if (isAccessibilityEnabled()) {
|
if (isAccessibilityInjectionEnabled()) {
|
||||||
getAccessibilityInjector().onPageStarted(url);
|
getAccessibilityInjector().onPageStarted(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3940,7 +3954,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
|
|||||||
/* package */ void onPageFinished(String url) {
|
/* package */ void onPageFinished(String url) {
|
||||||
mZoomManager.onPageFinished(url);
|
mZoomManager.onPageFinished(url);
|
||||||
|
|
||||||
if (isAccessibilityEnabled()) {
|
if (isAccessibilityInjectionEnabled()) {
|
||||||
getAccessibilityInjector().onPageFinished(url);
|
getAccessibilityInjector().onPageFinished(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4981,7 +4995,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// See if the accessibility injector needs to handle this event.
|
// See if the accessibility injector needs to handle this event.
|
||||||
if (isAccessibilityEnabled()
|
if (isAccessibilityInjectionEnabled()
|
||||||
&& getAccessibilityInjector().handleKeyEventIfNecessary(event)) {
|
&& getAccessibilityInjector().handleKeyEventIfNecessary(event)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -5088,7 +5102,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// See if the accessibility injector needs to handle this event.
|
// See if the accessibility injector needs to handle this event.
|
||||||
if (isAccessibilityEnabled()
|
if (isAccessibilityInjectionEnabled()
|
||||||
&& getAccessibilityInjector().handleKeyEventIfNecessary(event)) {
|
&& getAccessibilityInjector().handleKeyEventIfNecessary(event)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -5339,7 +5353,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
|
|||||||
public void onAttachedToWindow() {
|
public void onAttachedToWindow() {
|
||||||
if (mWebView.hasWindowFocus()) setActive(true);
|
if (mWebView.hasWindowFocus()) setActive(true);
|
||||||
|
|
||||||
if (isAccessibilityEnabled()) {
|
if (isAccessibilityInjectionEnabled()) {
|
||||||
getAccessibilityInjector().addAccessibilityApisIfNecessary();
|
getAccessibilityInjector().addAccessibilityApisIfNecessary();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5352,7 +5366,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
|
|||||||
mZoomManager.dismissZoomPicker();
|
mZoomManager.dismissZoomPicker();
|
||||||
if (mWebView.hasWindowFocus()) setActive(false);
|
if (mWebView.hasWindowFocus()) setActive(false);
|
||||||
|
|
||||||
if (isAccessibilityEnabled()) {
|
if (isAccessibilityInjectionEnabled()) {
|
||||||
getAccessibilityInjector().removeAccessibilityApisIfNecessary();
|
getAccessibilityInjector().removeAccessibilityApisIfNecessary();
|
||||||
} else {
|
} else {
|
||||||
// Ensure the injector is cleared if we're detaching from the window
|
// Ensure the injector is cleared if we're detaching from the window
|
||||||
@@ -7434,7 +7448,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SELECTION_STRING_CHANGED:
|
case SELECTION_STRING_CHANGED:
|
||||||
if (isAccessibilityEnabled()) {
|
if (isAccessibilityInjectionEnabled()) {
|
||||||
getAccessibilityInjector()
|
getAccessibilityInjector()
|
||||||
.handleSelectionChangedIfNecessary((String) msg.obj);
|
.handleSelectionChangedIfNecessary((String) msg.obj);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user