Merge "Treat accessibility gestures like physical ones." into nyc-dev
This commit is contained in:
@@ -600,11 +600,16 @@ public abstract class AccessibilityService extends Service {
|
|||||||
* Dispatch a gesture to the touch screen. Any gestures currently in progress, whether from
|
* Dispatch a gesture to the touch screen. Any gestures currently in progress, whether from
|
||||||
* the user, this service, or another service, will be cancelled.
|
* the user, this service, or another service, will be cancelled.
|
||||||
* <p>
|
* <p>
|
||||||
|
* The gesture will be dispatched as if it were performed directly on the screen by a user, so
|
||||||
|
* the events may be affected by features such as magnification and explore by touch.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
* <strong>Note:</strong> In order to dispatch gestures, your service
|
* <strong>Note:</strong> In order to dispatch gestures, your service
|
||||||
* must declare the capability by setting the
|
* must declare the capability by setting the
|
||||||
* {@link android.R.styleable#AccessibilityService_canPerformGestures}
|
* {@link android.R.styleable#AccessibilityService_canPerformGestures}
|
||||||
* property in its meta-data. For more information, see
|
* property in its meta-data. For more information, see
|
||||||
* {@link #SERVICE_META_DATA}.
|
* {@link #SERVICE_META_DATA}.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param gesture The gesture to dispatch
|
* @param gesture The gesture to dispatch
|
||||||
* @param callback The object to call back when the status of the gesture is known. If
|
* @param callback The object to call back when the status of the gesture is known. If
|
||||||
|
|||||||
@@ -363,12 +363,6 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
|||||||
private void enableFeatures() {
|
private void enableFeatures() {
|
||||||
resetStreamState();
|
resetStreamState();
|
||||||
|
|
||||||
if ((mEnabledFeatures & FLAG_FEATURE_INJECT_MOTION_EVENTS) != 0) {
|
|
||||||
mMotionEventInjector = new MotionEventInjector(mContext.getMainLooper());
|
|
||||||
addFirstEventHandler(mMotionEventInjector);
|
|
||||||
mAms.setMotionEventInjector(mMotionEventInjector);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mEnabledFeatures & FLAG_FEATURE_AUTOCLICK) != 0) {
|
if ((mEnabledFeatures & FLAG_FEATURE_AUTOCLICK) != 0) {
|
||||||
mAutoclickController = new AutoclickController(mContext, mUserId);
|
mAutoclickController = new AutoclickController(mContext, mUserId);
|
||||||
addFirstEventHandler(mAutoclickController);
|
addFirstEventHandler(mAutoclickController);
|
||||||
@@ -384,6 +378,12 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
|||||||
addFirstEventHandler(mMagnificationGestureHandler);
|
addFirstEventHandler(mMagnificationGestureHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((mEnabledFeatures & FLAG_FEATURE_INJECT_MOTION_EVENTS) != 0) {
|
||||||
|
mMotionEventInjector = new MotionEventInjector(mContext.getMainLooper());
|
||||||
|
addFirstEventHandler(mMotionEventInjector);
|
||||||
|
mAms.setMotionEventInjector(mMotionEventInjector);
|
||||||
|
}
|
||||||
|
|
||||||
if ((mEnabledFeatures & FLAG_FEATURE_FILTER_KEY_EVENTS) != 0) {
|
if ((mEnabledFeatures & FLAG_FEATURE_FILTER_KEY_EVENTS) != 0) {
|
||||||
mKeyboardInterceptor = new KeyboardInterceptor(mAms);
|
mKeyboardInterceptor = new KeyboardInterceptor(mAms);
|
||||||
addFirstEventHandler(mKeyboardInterceptor);
|
addFirstEventHandler(mKeyboardInterceptor);
|
||||||
|
|||||||
@@ -156,10 +156,10 @@ class MagnificationController {
|
|||||||
final float offsetY = sentSpec.offsetY;
|
final float offsetY = sentSpec.offsetY;
|
||||||
|
|
||||||
// Compute the new center and update spec as needed.
|
// Compute the new center and update spec as needed.
|
||||||
final float centerX = (mMagnifiedBounds.width() / 2.0f
|
final float centerX = (mMagnifiedBounds.width() / 2.0f - offsetX) / scale
|
||||||
+ mMagnifiedBounds.left - offsetX) / scale;
|
+ mMagnifiedBounds.left;
|
||||||
final float centerY = (mMagnifiedBounds.height() / 2.0f
|
final float centerY = (mMagnifiedBounds.height() / 2.0f - offsetY) / scale
|
||||||
+ mMagnifiedBounds.top - offsetY) / scale;
|
+ mMagnifiedBounds.top;
|
||||||
if (updateSpec) {
|
if (updateSpec) {
|
||||||
setScaleAndCenter(scale, centerX, centerY, false);
|
setScaleAndCenter(scale, centerX, centerY, false);
|
||||||
} else {
|
} else {
|
||||||
@@ -256,7 +256,7 @@ class MagnificationController {
|
|||||||
public float getCenterX() {
|
public float getCenterX() {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
return (mMagnifiedBounds.width() / 2.0f
|
return (mMagnifiedBounds.width() / 2.0f
|
||||||
+ mMagnifiedBounds.left - getOffsetX()) / getScale();
|
- getOffsetX()) / getScale() + mMagnifiedBounds.left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ class MagnificationController {
|
|||||||
public float getCenterY() {
|
public float getCenterY() {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
return (mMagnifiedBounds.height() / 2.0f
|
return (mMagnifiedBounds.height() / 2.0f
|
||||||
+ mMagnifiedBounds.top - getOffsetY()) / getScale();
|
- getOffsetY()) / getScale() + mMagnifiedBounds.top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user