summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/WindowInfo.java
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2012-10-12 20:15:29 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2012-12-03 10:38:48 -0800
commit152e9bb81aa5b2ab4637f4b2dae04b3ce89fa891 (patch)
tree8e955c6db3279776dc6795e125513c4f2877ea44 /core/java/android/view/WindowInfo.java
parent4d58730ff587645778636e87312b1b17846fcac9 (diff)
downloadframeworks_base-152e9bb81aa5b2ab4637f4b2dae04b3ce89fa891.zip
frameworks_base-152e9bb81aa5b2ab4637f4b2dae04b3ce89fa891.tar.gz
frameworks_base-152e9bb81aa5b2ab4637f4b2dae04b3ce89fa891.tar.bz2
Refactoring of the screen magnification feature.
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
Diffstat (limited to 'core/java/android/view/WindowInfo.java')
-rw-r--r--core/java/android/view/WindowInfo.java175
1 files changed, 0 insertions, 175 deletions
diff --git a/core/java/android/view/WindowInfo.java b/core/java/android/view/WindowInfo.java
deleted file mode 100644
index 7d16e14..0000000
--- a/core/java/android/view/WindowInfo.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * 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 android.view;
-
-import android.graphics.Rect;
-import android.os.IBinder;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Information the state of a window.
- *
- * @hide
- */
-public class WindowInfo implements Parcelable {
-
- private static final int MAX_POOL_SIZE = 20;
-
- private static int UNDEFINED = -1;
-
- private static Object sPoolLock = new Object();
- private static WindowInfo sPool;
- private static int sPoolSize;
-
- private WindowInfo mNext;
- private boolean mInPool;
-
- public IBinder token;
-
- public final Rect frame = new Rect();
-
- public final Rect touchableRegion = new Rect();
-
- public int type = UNDEFINED;
-
- public float compatibilityScale = UNDEFINED;
-
- public boolean visible;
-
- public int displayId = UNDEFINED;
-
- public int layer = UNDEFINED;
-
- private WindowInfo() {
- /* do nothing - reduce visibility */
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel parcel, int flags) {
- parcel.writeStrongBinder(token);
- parcel.writeParcelable(frame, 0);
- parcel.writeParcelable(touchableRegion, 0);
- parcel.writeInt(type);
- parcel.writeFloat(compatibilityScale);
- parcel.writeInt(visible ? 1 : 0);
- parcel.writeInt(displayId);
- parcel.writeInt(layer);
- recycle();
- }
-
- private void initFromParcel(Parcel parcel) {
- token = parcel.readStrongBinder();
- frame.set((Rect) parcel.readParcelable(null));
- touchableRegion.set((Rect) parcel.readParcelable(null));
- type = parcel.readInt();
- compatibilityScale = parcel.readFloat();
- visible = (parcel.readInt() == 1);
- displayId = parcel.readInt();
- layer = parcel.readInt();
- }
-
- public static WindowInfo obtain(WindowInfo other) {
- WindowInfo info = obtain();
- info.token = other.token;
- info.frame.set(other.frame);
- info.touchableRegion.set(other.touchableRegion);
- info.type = other.type;
- info.compatibilityScale = other.compatibilityScale;
- info.visible = other.visible;
- info.displayId = other.displayId;
- info.layer = other.layer;
- return info;
- }
-
- public static WindowInfo obtain() {
- synchronized (sPoolLock) {
- if (sPoolSize > 0) {
- WindowInfo info = sPool;
- sPool = info.mNext;
- info.mNext = null;
- info.mInPool = false;
- sPoolSize--;
- return info;
- } else {
- return new WindowInfo();
- }
- }
- }
-
- public void recycle() {
- if (mInPool) {
- throw new IllegalStateException("Already recycled.");
- }
- clear();
- synchronized (sPoolLock) {
- if (sPoolSize < MAX_POOL_SIZE) {
- mNext = sPool;
- sPool = this;
- mInPool = true;
- sPoolSize++;
- }
- }
- }
-
- private void clear() {
- token = null;
- frame.setEmpty();
- touchableRegion.setEmpty();
- type = UNDEFINED;
- compatibilityScale = UNDEFINED;
- visible = false;
- displayId = UNDEFINED;
- layer = UNDEFINED;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("Window [token:").append((token != null) ? token.hashCode() : null);
- builder.append(", displayId:").append(displayId);
- builder.append(", type:").append(type);
- builder.append(", visible:").append(visible);
- builder.append(", layer:").append(layer);
- builder.append(", compatibilityScale:").append(compatibilityScale);
- builder.append(", frame:").append(frame);
- builder.append(", touchableRegion:").append(touchableRegion);
- builder.append("]");
- return builder.toString();
- }
-
- /**
- * @see Parcelable.Creator
- */
- public static final Parcelable.Creator<WindowInfo> CREATOR =
- new Parcelable.Creator<WindowInfo>() {
- public WindowInfo createFromParcel(Parcel parcel) {
- WindowInfo info = WindowInfo.obtain();
- info.initFromParcel(parcel);
- return info;
- }
-
- public WindowInfo[] newArray(int size) {
- return new WindowInfo[size];
- }
- };
-}