Skip to content

Commit 939f2e4

Browse files
committed
Removing a workaround for incorrect window position on window move.
1. The window manager was not notifying a window when the latter has been moved. This was causing incorrect coordinates of the nodes reported to accessibility services. To workaround that we have carried the correct window location when making a call from the accessibility layer into a window. Now the window manager notifies the window when it is moved and the workaround is no longer needed. This change takes it out. 2. The left and right in the attach info were not updated properly after a report that the window has moved. 3. The accessibility manager service was calling directly methods on the window manager service without going through the interface of the latter. This leads to unnecessary coupling and in the long rung increases system complexity and reduces maintability. bug:6623031 Change-Id: Ibbf98afd29439783ba331a7a0cdce55d7f138922
1 parent dd0d0ba commit 939f2e4

File tree

18 files changed

+325
-252
lines changed

18 files changed

+325
-252
lines changed

Android.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ LOCAL_SRC_FILES += \
143143
core/java/android/view/accessibility/IAccessibilityManager.aidl \
144144
core/java/android/view/accessibility/IAccessibilityManagerClient.aidl \
145145
core/java/android/view/IApplicationToken.aidl \
146+
core/java/android/view/IInputFilter.aidl \
147+
core/java/android/view/IInputFilterHost.aidl \
146148
core/java/android/view/IOnKeyguardExitResult.aidl \
147149
core/java/android/view/IRotationWatcher.aidl \
148150
core/java/android/view/IWindow.aidl \

core/java/android/view/AccessibilityInteractionController.java

Lines changed: 14 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private boolean isShown(View view) {
141141
}
142142

143143
public void findAccessibilityNodeInfoByAccessibilityIdClientThread(
144-
long accessibilityNodeId, int windowLeft, int windowTop, int interactionId,
144+
long accessibilityNodeId, int interactionId,
145145
IAccessibilityInteractionConnectionCallback callback, int flags, int interrogatingPid,
146146
long interrogatingTid) {
147147
Message message = mHandler.obtainMessage();
@@ -153,12 +153,6 @@ public void findAccessibilityNodeInfoByAccessibilityIdClientThread(
153153
args.argi2 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
154154
args.argi3 = interactionId;
155155
args.arg1 = callback;
156-
157-
SomeArgs moreArgs = mPool.acquire();
158-
moreArgs.argi1 = windowLeft;
159-
moreArgs.argi2 = windowTop;
160-
args.arg2 = moreArgs;
161-
162156
message.obj = args;
163157

164158
// If the interrogation is performed by the same thread as the main UI
@@ -183,11 +177,6 @@ private void findAccessibilityNodeInfoByAccessibilityIdUiThread(Message message)
183177
final IAccessibilityInteractionConnectionCallback callback =
184178
(IAccessibilityInteractionConnectionCallback) args.arg1;
185179

186-
SomeArgs moreArgs = (SomeArgs) args.arg2;
187-
mViewRootImpl.mAttachInfo.mActualWindowLeft = moreArgs.argi1;
188-
mViewRootImpl.mAttachInfo.mActualWindowTop = moreArgs.argi2;
189-
190-
mPool.release(moreArgs);
191180
mPool.release(args);
192181

193182
List<AccessibilityNodeInfo> infos = mTempAccessibilityNodeInfoList;
@@ -220,9 +209,8 @@ private void findAccessibilityNodeInfoByAccessibilityIdUiThread(Message message)
220209
}
221210

222211
public void findAccessibilityNodeInfoByViewIdClientThread(long accessibilityNodeId,
223-
int viewId, int windowLeft, int windowTop, int interactionId,
224-
IAccessibilityInteractionConnectionCallback callback, int flags, int interrogatingPid,
225-
long interrogatingTid) {
212+
int viewId, int interactionId, IAccessibilityInteractionConnectionCallback callback,
213+
int flags, int interrogatingPid, long interrogatingTid) {
226214
Message message = mHandler.obtainMessage();
227215
message.what = PrivateHandler.MSG_FIND_ACCESSIBLITY_NODE_INFO_BY_VIEW_ID;
228216
message.arg1 = flags;
@@ -233,11 +221,6 @@ public void findAccessibilityNodeInfoByViewIdClientThread(long accessibilityNode
233221
args.argi2 = interactionId;
234222
args.arg1 = callback;
235223

236-
SomeArgs moreArgs = mPool.acquire();
237-
moreArgs.argi1 = windowLeft;
238-
moreArgs.argi2 = windowTop;
239-
args.arg2 = moreArgs;
240-
241224
message.obj = args;
242225

243226
// If the interrogation is performed by the same thread as the main UI
@@ -262,11 +245,6 @@ private void findAccessibilityNodeInfoByViewIdUiThread(Message message) {
262245
final IAccessibilityInteractionConnectionCallback callback =
263246
(IAccessibilityInteractionConnectionCallback) args.arg1;
264247

265-
SomeArgs moreArgs = (SomeArgs) args.arg2;
266-
mViewRootImpl.mAttachInfo.mActualWindowLeft = moreArgs.argi1;
267-
mViewRootImpl.mAttachInfo.mActualWindowTop = moreArgs.argi2;
268-
269-
mPool.release(moreArgs);
270248
mPool.release(args);
271249

272250
AccessibilityNodeInfo info = null;
@@ -300,25 +278,19 @@ private void findAccessibilityNodeInfoByViewIdUiThread(Message message) {
300278
}
301279

302280
public void findAccessibilityNodeInfosByTextClientThread(long accessibilityNodeId,
303-
String text, int windowLeft, int windowTop, int interactionId,
304-
IAccessibilityInteractionConnectionCallback callback, int flags,
305-
int interrogatingPid, long interrogatingTid) {
281+
String text, int interactionId, IAccessibilityInteractionConnectionCallback callback,
282+
int flags, int interrogatingPid, long interrogatingTid) {
306283
Message message = mHandler.obtainMessage();
307284
message.what = PrivateHandler.MSG_FIND_ACCESSIBLITY_NODE_INFO_BY_TEXT;
308285
message.arg1 = flags;
309286

310287
SomeArgs args = mPool.acquire();
311288
args.arg1 = text;
289+
args.arg2 = callback;
312290
args.argi1 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
313291
args.argi2 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
314292
args.argi3 = interactionId;
315293

316-
SomeArgs moreArgs = mPool.acquire();
317-
moreArgs.arg1 = callback;
318-
moreArgs.argi1 = windowLeft;
319-
moreArgs.argi2 = windowTop;
320-
args.arg2 = moreArgs;
321-
322294
message.obj = args;
323295

324296
// If the interrogation is performed by the same thread as the main UI
@@ -338,17 +310,11 @@ private void findAccessibilityNodeInfosByTextUiThread(Message message) {
338310

339311
SomeArgs args = (SomeArgs) message.obj;
340312
final String text = (String) args.arg1;
313+
final IAccessibilityInteractionConnectionCallback callback =
314+
(IAccessibilityInteractionConnectionCallback) args.arg2;
341315
final int accessibilityViewId = args.argi1;
342316
final int virtualDescendantId = args.argi2;
343317
final int interactionId = args.argi3;
344-
345-
SomeArgs moreArgs = (SomeArgs) args.arg2;
346-
final IAccessibilityInteractionConnectionCallback callback =
347-
(IAccessibilityInteractionConnectionCallback) moreArgs.arg1;
348-
mViewRootImpl.mAttachInfo.mActualWindowLeft = moreArgs.argi1;
349-
mViewRootImpl.mAttachInfo.mActualWindowTop = moreArgs.argi2;
350-
351-
mPool.release(moreArgs);
352318
mPool.release(args);
353319

354320
List<AccessibilityNodeInfo> infos = null;
@@ -409,9 +375,9 @@ private void findAccessibilityNodeInfosByTextUiThread(Message message) {
409375
}
410376
}
411377

412-
public void findFocusClientThread(long accessibilityNodeId, int focusType, int windowLeft,
413-
int windowTop, int interactionId, IAccessibilityInteractionConnectionCallback callback,
414-
int flags, int interogatingPid, long interrogatingTid) {
378+
public void findFocusClientThread(long accessibilityNodeId, int focusType, int interactionId,
379+
IAccessibilityInteractionConnectionCallback callback, int flags, int interogatingPid,
380+
long interrogatingTid) {
415381
Message message = mHandler.obtainMessage();
416382
message.what = PrivateHandler.MSG_FIND_FOCUS;
417383
message.arg1 = flags;
@@ -423,11 +389,6 @@ public void findFocusClientThread(long accessibilityNodeId, int focusType, int w
423389
args.argi3 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
424390
args.arg1 = callback;
425391

426-
SomeArgs moreArgs = mPool.acquire();
427-
moreArgs.argi1 = windowLeft;
428-
moreArgs.argi2 = windowTop;
429-
args.arg2 = moreArgs;
430-
431392
message.obj = args;
432393

433394
// If the interrogation is performed by the same thread as the main UI
@@ -453,11 +414,6 @@ private void findFocusUiThread(Message message) {
453414
final IAccessibilityInteractionConnectionCallback callback =
454415
(IAccessibilityInteractionConnectionCallback) args.arg1;
455416

456-
SomeArgs moreArgs = (SomeArgs) args.arg2;
457-
mViewRootImpl.mAttachInfo.mActualWindowLeft = moreArgs.argi1;
458-
mViewRootImpl.mAttachInfo.mActualWindowTop = moreArgs.argi2;
459-
460-
mPool.release(moreArgs);
461417
mPool.release(args);
462418

463419
AccessibilityNodeInfo focused = null;
@@ -516,9 +472,9 @@ private void findFocusUiThread(Message message) {
516472
}
517473
}
518474

519-
public void focusSearchClientThread(long accessibilityNodeId, int direction, int windowLeft,
520-
int windowTop, int interactionId, IAccessibilityInteractionConnectionCallback callback,
521-
int flags, int interogatingPid, long interrogatingTid) {
475+
public void focusSearchClientThread(long accessibilityNodeId, int direction, int interactionId,
476+
IAccessibilityInteractionConnectionCallback callback, int flags, int interogatingPid,
477+
long interrogatingTid) {
522478
Message message = mHandler.obtainMessage();
523479
message.what = PrivateHandler.MSG_FOCUS_SEARCH;
524480
message.arg1 = flags;
@@ -530,11 +486,6 @@ public void focusSearchClientThread(long accessibilityNodeId, int direction, int
530486
args.argi3 = interactionId;
531487
args.arg1 = callback;
532488

533-
SomeArgs moreArgs = mPool.acquire();
534-
moreArgs.argi1 = windowLeft;
535-
moreArgs.argi2 = windowTop;
536-
args.arg2 = moreArgs;
537-
538489
message.obj = args;
539490

540491
// If the interrogation is performed by the same thread as the main UI
@@ -560,11 +511,6 @@ private void focusSearchUiThread(Message message) {
560511
final IAccessibilityInteractionConnectionCallback callback =
561512
(IAccessibilityInteractionConnectionCallback) args.arg1;
562513

563-
SomeArgs moreArgs = (SomeArgs) args.arg2;
564-
mViewRootImpl.mAttachInfo.mActualWindowLeft = moreArgs.argi1;
565-
mViewRootImpl.mAttachInfo.mActualWindowTop = moreArgs.argi2;
566-
567-
mPool.release(moreArgs);
568514
mPool.release(args);
569515

570516
AccessibilityNodeInfo next = null;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) 2012, The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.view;
18+
19+
import android.view.IInputFilterHost;
20+
import android.view.InputEvent;
21+
22+
/**
23+
* Interface for implementing an filter which observes and
24+
* potentially transforms the input event stream in the system.
25+
*
26+
* @hide
27+
*/
28+
oneway interface IInputFilter {
29+
void install(IInputFilterHost host);
30+
void uninstall();
31+
void filterInputEvent(in InputEvent event, int policyFlags);
32+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (c) 2012, The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.view;
18+
19+
import android.view.InputEvent;
20+
21+
/**
22+
* Interface for calls from an input filter to its host.
23+
*
24+
* @hide
25+
*/
26+
oneway interface IInputFilterHost {
27+
void sendInputEvent(in InputEvent event, int policyFlags);
28+
}

core/java/android/view/IWindowManager.aidl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import android.content.res.CompatibilityInfo;
2323
import android.content.res.Configuration;
2424
import android.graphics.Bitmap;
2525
import android.graphics.Point;
26+
import android.graphics.Rect;
2627
import android.os.IRemoteCallback;
2728
import android.view.IApplicationToken;
2829
import android.view.IOnKeyguardExitResult;
@@ -33,6 +34,7 @@ import android.view.InputEvent;
3334
import android.view.MotionEvent;
3435
import android.view.InputChannel;
3536
import android.view.InputDevice;
37+
import android.view.IInputFilter;
3638

3739
/**
3840
* System private interface to the window manager.
@@ -208,4 +210,24 @@ interface IWindowManager
208210
* Lock the device immediately.
209211
*/
210212
void lockNow();
213+
214+
/**
215+
* Gets the token for the focused window.
216+
*/
217+
IBinder getFocusedWindowToken();
218+
219+
/**
220+
* Gets the frame on the screen of the window given its token.
221+
*/
222+
boolean getWindowFrame(IBinder token, out Rect outBounds);
223+
224+
/**
225+
* Gets the compatibility scale of e window given its token.
226+
*/
227+
float getWindowCompatibilityScale(IBinder windowToken);
228+
229+
/**
230+
* Sets an input filter for manipulating the input event stream.
231+
*/
232+
void setInputFilter(in IInputFilter filter);
211233
}

0 commit comments

Comments
 (0)