1. The screen magnification feature was implemented entirely as a part of the accessibility manager. To achieve that the window manager had to implement a bunch of hooks for an external client to observe its internal state. This was problematic since it dilutes the window manager interface and allows code that is deeply coupled with the window manager to reside outside of it. Also the observer callbacks were IPCs which cannot be called with the window manager's lock held. To avoid that the window manager had to post messages requesting notification of interested parties which makes the code consuming the callbacks to run asynchronously of the window manager. This causes timing issues and adds unnecessary complexity. Now the magnification logic is split in two halves. The first half that is responsible to track the magnified portion of the screen and serve as a policy which windows can be magnified and it is a part of the window manager. This part exposes higher level APIs allowing interested parties with the right permissions to control the magnification of a given display. The APIs also allow a client to be registered for callbacks on interesting changes such as resize of the magnified region, etc. This part servers as a mediator between magnification controllers and the window manager. The second half is a controller that is responsible to drive the magnification state based on touch interactions. It also presents a highlight when magnified to suggest the magnified potion of the screen. The controller is responsible for auto zooming out in case the user context changes - rotation, new actitivity. The controller also auto pans if a dialog appears and it does not interesect the magnified frame. bug:7410464 2. By design screen magnification and touch exploration work separately and together. If magnification is enabled the user sees a larger version of the widgets and a sub section of the screen content. Accessibility services use the introspection APIs to "see" what is on the screen so they can speak it, navigate to the next item in response to a gesture, etc. Hence, the information returned to accessibility services has to reflect what a sighted user would see on the screen. Therefore, if the screen is magnified we need to adjust the bounds and position of the infos describing views in a magnified window such that the info bounds are equivalent to what the user sees. To improve performance we keep accessibility node info caches in the client process. However, when magnification state changes we have to clear these caches since the bounds of the cached infos no longer reflect the screen content which just got smaller or larger. This patch propagates not only the window scale as before but also the X/Y pan and the bounds of the magnified portion of the screen to the introspected app. This information is used to adjust the bounds of the node infos coming from this window such that the reported bounds are the same as the user sees not as the app thinks they are. Note that if magnification is enabled we zoom the content and pan it along the X and Y axis. Also recomputed is the isVisibleToUser property of the reported info since in a magnified state the user sees a subset of the window content and the views not in the magnified viewport should be reported as not visible to the user. bug:7344059 Change-Id: I6f7832c7a6a65c5368b390eb1f1518d0c7afd7d2
126 lines
4.5 KiB
Java
126 lines
4.5 KiB
Java
/*
|
|
* Copyright (C) 2012 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.android.server.wm;
|
|
|
|
import android.view.Display;
|
|
import android.view.DisplayInfo;
|
|
|
|
import java.io.PrintWriter;
|
|
import java.util.ArrayList;
|
|
|
|
class DisplayContentList extends ArrayList<DisplayContent> {
|
|
}
|
|
|
|
/**
|
|
* Utility class for keeping track of the WindowStates and other pertinent contents of a
|
|
* particular Display.
|
|
*
|
|
* IMPORTANT: No method from this class should ever be used without holding
|
|
* WindowManagerService.mWindowMap.
|
|
*/
|
|
class DisplayContent {
|
|
|
|
/** Unique identifier of this stack. */
|
|
private final int mDisplayId;
|
|
|
|
/** Z-ordered (bottom-most first) list of all Window objects. Assigned to an element
|
|
* from mDisplayWindows; */
|
|
private WindowList mWindows = new WindowList();
|
|
|
|
// This protects the following display size properties, so that
|
|
// getDisplaySize() doesn't need to acquire the global lock. This is
|
|
// needed because the window manager sometimes needs to use ActivityThread
|
|
// while it has its global state locked (for example to load animation
|
|
// resources), but the ActivityThread also needs get the current display
|
|
// size sometimes when it has its package lock held.
|
|
//
|
|
// These will only be modified with both mWindowMap and mDisplaySizeLock
|
|
// held (in that order) so the window manager doesn't need to acquire this
|
|
// lock when needing these values in its normal operation.
|
|
final Object mDisplaySizeLock = new Object();
|
|
int mInitialDisplayWidth = 0;
|
|
int mInitialDisplayHeight = 0;
|
|
int mInitialDisplayDensity = 0;
|
|
int mBaseDisplayWidth = 0;
|
|
int mBaseDisplayHeight = 0;
|
|
int mBaseDisplayDensity = 0;
|
|
private final DisplayInfo mDisplayInfo = new DisplayInfo();
|
|
private final Display mDisplay;
|
|
|
|
// Accessed directly by all users.
|
|
boolean layoutNeeded;
|
|
int pendingLayoutChanges;
|
|
final boolean isDefaultDisplay;
|
|
|
|
/**
|
|
* @param display May not be null.
|
|
*/
|
|
DisplayContent(Display display) {
|
|
mDisplay = display;
|
|
mDisplayId = display.getDisplayId();
|
|
display.getDisplayInfo(mDisplayInfo);
|
|
isDefaultDisplay = mDisplayId == Display.DEFAULT_DISPLAY;
|
|
}
|
|
|
|
int getDisplayId() {
|
|
return mDisplayId;
|
|
}
|
|
|
|
WindowList getWindowList() {
|
|
return mWindows;
|
|
}
|
|
|
|
Display getDisplay() {
|
|
return mDisplay;
|
|
}
|
|
|
|
DisplayInfo getDisplayInfo() {
|
|
return mDisplayInfo;
|
|
}
|
|
|
|
public void updateDisplayInfo() {
|
|
mDisplay.getDisplayInfo(mDisplayInfo);
|
|
}
|
|
|
|
public void dump(String prefix, PrintWriter pw) {
|
|
pw.print(prefix); pw.print("Display: mDisplayId="); pw.println(mDisplayId);
|
|
final String subPrefix = " " + prefix;
|
|
pw.print(subPrefix); pw.print("init="); pw.print(mInitialDisplayWidth); pw.print("x");
|
|
pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity);
|
|
pw.print("dpi");
|
|
if (mInitialDisplayWidth != mBaseDisplayWidth
|
|
|| mInitialDisplayHeight != mBaseDisplayHeight
|
|
|| mInitialDisplayDensity != mBaseDisplayDensity) {
|
|
pw.print(" base=");
|
|
pw.print(mBaseDisplayWidth); pw.print("x"); pw.print(mBaseDisplayHeight);
|
|
pw.print(" "); pw.print(mBaseDisplayDensity); pw.print("dpi");
|
|
}
|
|
pw.print(" cur=");
|
|
pw.print(mDisplayInfo.logicalWidth);
|
|
pw.print("x"); pw.print(mDisplayInfo.logicalHeight);
|
|
pw.print(" app=");
|
|
pw.print(mDisplayInfo.appWidth);
|
|
pw.print("x"); pw.print(mDisplayInfo.appHeight);
|
|
pw.print(" rng="); pw.print(mDisplayInfo.smallestNominalAppWidth);
|
|
pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
|
|
pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
|
|
pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
|
|
pw.print(subPrefix); pw.print("layoutNeeded="); pw.print(layoutNeeded);
|
|
pw.println();
|
|
}
|
|
}
|