Skip to content

Commit 964629a

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Occasionally triple tap on the keyboard toggles screen magnification." into jb-mr1-dev
2 parents 8db45f0 + 55468c6 commit 964629a

File tree

3 files changed

+61
-22
lines changed

3 files changed

+61
-22
lines changed

core/java/android/view/IDisplayContentChangeListener.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ import android.graphics.Rect;
2828
oneway interface IDisplayContentChangeListener {
2929
void onWindowTransition(int displayId, int transition, in WindowInfo info);
3030
void onRectangleOnScreenRequested(int displayId, in Rect rectangle, boolean immediate);
31+
void onWindowLayersChanged(int displayId);
3132
void onRotationChanged(int rotation);
3233
}

services/java/com/android/server/accessibility/ScreenMagnifier.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ private static final class DisplayContentObserver {
850850
private static final int MESSAGE_ON_RECTANGLE_ON_SCREEN_REQUESTED = 3;
851851
private static final int MESSAGE_ON_WINDOW_TRANSITION = 4;
852852
private static final int MESSAGE_ON_ROTATION_CHANGED = 5;
853+
private static final int MESSAGE_ON_WINDOW_LAYERS_CHANGED = 6;
853854

854855
private final Handler mHandler = new MyHandler();
855856

@@ -880,24 +881,8 @@ public DisplayContentObserver(Context context, Viewport viewport,
880881
mDisplayContentChangeListener = new IDisplayContentChangeListener.Stub() {
881882
@Override
882883
public void onWindowTransition(int displayId, int transition, WindowInfo info) {
883-
Message message = mHandler.obtainMessage(MESSAGE_ON_WINDOW_TRANSITION,
884-
transition, 0, WindowInfo.obtain(info));
885-
// TODO: This makes me quite unhappy but for the time being the
886-
// least risky fix for cases where the keyguard is removed but
887-
// the windows it force hides are not made visible yet. Hence,
888-
// we would compute the magnified frame before we have a stable
889-
// state. One more reason to move the magnified frame computation
890-
// in the window manager!
891-
if (info.type == WindowManager.LayoutParams.TYPE_KEYGUARD
892-
|| info.type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG
893-
&& (transition == WindowManagerPolicy.TRANSIT_EXIT
894-
|| transition == WindowManagerPolicy.TRANSIT_HIDE)) {
895-
final long delay = (long) (2 * mLongAnimationDuration
896-
* mWindowAnimationScale);
897-
mHandler.sendMessageDelayed(message, delay);
898-
} else {
899-
message.sendToTarget();
900-
}
884+
mHandler.obtainMessage(MESSAGE_ON_WINDOW_TRANSITION,
885+
transition, 0, WindowInfo.obtain(info)).sendToTarget();
901886
}
902887

903888
@Override
@@ -917,6 +902,11 @@ public void onRotationChanged(int rotation) throws RemoteException {
917902
mHandler.obtainMessage(MESSAGE_ON_ROTATION_CHANGED, rotation, 0)
918903
.sendToTarget();
919904
}
905+
906+
@Override
907+
public void onWindowLayersChanged(int displayId) throws RemoteException {
908+
mHandler.sendEmptyMessage(MESSAGE_ON_WINDOW_LAYERS_CHANGED);
909+
}
920910
};
921911

922912
try {
@@ -1192,6 +1182,9 @@ public void handleMessage(Message message) {
11921182
final int rotation = message.arg1;
11931183
handleOnRotationChanged(rotation);
11941184
} break;
1185+
case MESSAGE_ON_WINDOW_LAYERS_CHANGED: {
1186+
mViewport.recomputeBounds(mMagnificationController.isMagnifying());
1187+
} break;
11951188
default: {
11961189
throw new IllegalArgumentException("Unknown message: " + action);
11971190
}

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6569,6 +6569,36 @@ private void handleNotifyRotationChanged(int displayId, int rotation) {
65696569
}
65706570
}
65716571

6572+
private void scheduleNotifyWindowLayersChangedIfNeededLocked(DisplayContent displayContent) {
6573+
if (displayContent.mDisplayContentChangeListeners != null
6574+
&& displayContent.mDisplayContentChangeListeners.getRegisteredCallbackCount() > 0) {
6575+
mH.obtainMessage(H.NOTIFY_WINDOW_LAYERS_CHANGED, displayContent) .sendToTarget();
6576+
}
6577+
}
6578+
6579+
private void handleNotifyWindowLayersChanged(DisplayContent displayContent) {
6580+
RemoteCallbackList<IDisplayContentChangeListener> callbacks = null;
6581+
synchronized (mWindowMap) {
6582+
callbacks = displayContent.mDisplayContentChangeListeners;
6583+
if (callbacks == null) {
6584+
return;
6585+
}
6586+
}
6587+
try {
6588+
final int watcherCount = callbacks.beginBroadcast();
6589+
for (int i = 0; i < watcherCount; i++) {
6590+
try {
6591+
callbacks.getBroadcastItem(i).onWindowLayersChanged(
6592+
displayContent.getDisplayId());
6593+
} catch (RemoteException re) {
6594+
/* ignore */
6595+
}
6596+
}
6597+
} finally {
6598+
callbacks.finishBroadcast();
6599+
}
6600+
}
6601+
65726602
public void addWindowChangeListener(WindowChangeListener listener) {
65736603
synchronized(mWindowMap) {
65746604
mWindowChangeListeners.add(listener);
@@ -7215,12 +7245,13 @@ final class H extends Handler {
72157245
public static final int NOTIFY_ROTATION_CHANGED = 28;
72167246
public static final int NOTIFY_WINDOW_TRANSITION = 29;
72177247
public static final int NOTIFY_RECTANGLE_ON_SCREEN_REQUESTED = 30;
7248+
public static final int NOTIFY_WINDOW_LAYERS_CHANGED = 31;
72187249

7219-
public static final int DO_DISPLAY_ADDED = 31;
7220-
public static final int DO_DISPLAY_REMOVED = 32;
7221-
public static final int DO_DISPLAY_CHANGED = 33;
7250+
public static final int DO_DISPLAY_ADDED = 32;
7251+
public static final int DO_DISPLAY_REMOVED = 33;
7252+
public static final int DO_DISPLAY_CHANGED = 34;
72227253

7223-
public static final int CLIENT_FREEZE_TIMEOUT = 34;
7254+
public static final int CLIENT_FREEZE_TIMEOUT = 35;
72247255

72257256
public static final int ANIMATOR_WHAT_OFFSET = 100000;
72267257
public static final int SET_TRANSPARENT_REGION = ANIMATOR_WHAT_OFFSET + 1;
@@ -7692,6 +7723,12 @@ public void handleMessage(Message msg) {
76927723
break;
76937724
}
76947725

7726+
case NOTIFY_WINDOW_LAYERS_CHANGED: {
7727+
DisplayContent displayContent = (DisplayContent) msg.obj;
7728+
handleNotifyWindowLayersChanged(displayContent);
7729+
break;
7730+
}
7731+
76957732
case DO_DISPLAY_ADDED:
76967733
synchronized (mWindowMap) {
76977734
handleDisplayAddedLocked(msg.arg1);
@@ -8068,6 +8105,8 @@ private final void assignLayersLocked(WindowList windows) {
80688105
Slog.v(TAG, "Assigning layers", here);
80698106
}
80708107

8108+
boolean anyLayerChanged = false;
8109+
80718110
for (i=0; i<N; i++) {
80728111
final WindowState w = windows.get(i);
80738112
final WindowStateAnimator winAnimator = w.mWinAnimator;
@@ -8083,6 +8122,7 @@ private final void assignLayersLocked(WindowList windows) {
80838122
}
80848123
if (w.mLayer != oldLayer) {
80858124
layerChanged = true;
8125+
anyLayerChanged = true;
80868126
}
80878127
oldLayer = winAnimator.mAnimLayer;
80888128
if (w.mTargetAppToken != null) {
@@ -8101,6 +8141,7 @@ private final void assignLayersLocked(WindowList windows) {
81018141
}
81028142
if (winAnimator.mAnimLayer != oldLayer) {
81038143
layerChanged = true;
8144+
anyLayerChanged = true;
81048145
}
81058146
if (layerChanged && mAnimator.isDimmingLocked(winAnimator)) {
81068147
// Force an animation pass just to update the mDimAnimator layer.
@@ -8115,6 +8156,10 @@ private final void assignLayersLocked(WindowList windows) {
81158156
//System.out.println(
81168157
// "Assigned layer " + curLayer + " to " + w.mClient.asBinder());
81178158
}
8159+
8160+
if (anyLayerChanged) {
8161+
scheduleNotifyWindowLayersChangedIfNeededLocked(getDefaultDisplayContentLocked());
8162+
}
81188163
}
81198164

81208165
private final void performLayoutAndPlaceSurfacesLocked() {

0 commit comments

Comments
 (0)