diff options
22 files changed, 181 insertions, 443 deletions
diff --git a/Android.mk b/Android.mk index eef900acf923..b0a3dace6477 100644 --- a/Android.mk +++ b/Android.mk @@ -61,7 +61,6 @@ LOCAL_SRC_FILES := $(filter-out \ LOCAL_SRC_FILES += \ core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl \ core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl \ - core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.aidl \ core/java/android/accounts/IAccountManager.aidl \ core/java/android/accounts/IAccountManagerResponse.aidl \ core/java/android/accounts/IAccountAuthenticator.aidl \ diff --git a/CleanSpec.mk b/CleanSpec.mk index 939c117ff246..539b84ebf549 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -129,6 +129,9 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/host/$(HOST_PREBUILT_TAG)/obj/STATIC_LI $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IEventListener.java) $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IEventListener.P) $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/view/accessibility/IAccessibilityManager.P) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.java) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.P) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IAccessibilityServiceClient.P) # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST # ************************************************ diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index c0fb06fc9c4d..1d5f20766c06 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -55,6 +55,10 @@ #define SYSTEM_BOOTANIMATION_FILE "/system/media/bootanimation.zip" #define SYSTEM_ENCRYPTED_BOOTANIMATION_FILE "/system/media/bootanimation-encrypted.zip" +extern "C" int clock_nanosleep(clockid_t clock_id, int flags, + const struct timespec *request, + struct timespec *remain); + namespace android { // --------------------------------------------------------------------------- @@ -476,6 +480,7 @@ bool BootAnimation::movie() for (int r=0 ; !part.count || r<part.count ; r++) { for (int j=0 ; j<fcount && !exitPending(); j++) { const Animation::Frame& frame(part.frames[j]); + nsecs_t lastFrame = systemTime(); if (r > 0) { glBindTexture(GL_TEXTURE_2D, frame.tid); @@ -508,10 +513,18 @@ bool BootAnimation::movie() nsecs_t now = systemTime(); nsecs_t delay = frameDuration - (now - lastFrame); + //ALOGD("%lld, %lld", ns2ms(now - lastFrame), ns2ms(delay)); lastFrame = now; - long wait = ns2us(delay); - if (wait > 0) - usleep(wait); + + if (delay > 0) { + struct timespec spec; + spec.tv_sec = (now + delay) / 1000000000; + spec.tv_nsec = (now + delay) % 1000000000; + int err; + do { + err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL); + } while (err<0 && errno == EINTR); + } } usleep(part.pause * ns2us(frameDuration)); } diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java index 850fe4879917..044c0c276221 100644 --- a/core/java/android/accessibilityservice/AccessibilityService.java +++ b/core/java/android/accessibilityservice/AccessibilityService.java @@ -371,7 +371,7 @@ public abstract class AccessibilityService extends Service { * * <strong>Note:</strong> To receive gestures an accessibility service must * request that the device is in touch exploration mode by setting the - * {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS} + * {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_REQUEST_TOUCH_EXPLORATION_MODE} * flag. * * @param gestureId The unique id of the performed gesture. @@ -565,10 +565,8 @@ public abstract class AccessibilityService extends Service { mCaller.sendMessage(message); } - public void onGesture(int gestureId, IAccessibilityServiceClientCallback callback, - int interactionId) { - Message message = mCaller.obtainMessageIIO(DO_ON_GESTURE, gestureId, interactionId, - callback); + public void onGesture(int gestureId) { + Message message = mCaller.obtainMessageI(DO_ON_GESTURE, gestureId); mCaller.sendMessage(message); } @@ -601,15 +599,7 @@ public abstract class AccessibilityService extends Service { return; case DO_ON_GESTURE : final int gestureId = message.arg1; - final int interactionId = message.arg2; - IAccessibilityServiceClientCallback callback = - (IAccessibilityServiceClientCallback) message.obj; - final boolean handled = mCallback.onGesture(gestureId); - try { - callback.setGestureResult(gestureId, handled, interactionId); - } catch (RemoteException re) { - Log.e(LOG_TAG, "Error calling back with the gesture resut.", re); - } + mCallback.onGesture(gestureId); return; default : Log.w(LOG_TAG, "Unknown message type " + message.what); diff --git a/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl b/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl index 0257aa463dfd..d459fd546264 100644 --- a/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl +++ b/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl @@ -16,7 +16,6 @@ package android.accessibilityservice; -import android.accessibilityservice.IAccessibilityServiceClientCallback; import android.accessibilityservice.IAccessibilityServiceConnection; import android.view.accessibility.AccessibilityEvent; @@ -33,5 +32,5 @@ import android.view.accessibility.AccessibilityEvent; void onInterrupt(); - void onGesture(int gesture, in IAccessibilityServiceClientCallback callback, int interactionId); + void onGesture(int gesture); } diff --git a/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.aidl b/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.aidl deleted file mode 100644 index 90613981f012..000000000000 --- a/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.aidl +++ /dev/null @@ -1,30 +0,0 @@ -/* -** Copyright 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.accessibilityservice; - -import android.accessibilityservice.IAccessibilityServiceConnection; -import android.view.accessibility.AccessibilityEvent; - -/** - * Callback for IAccessibilityServiceClient. - * - * @hide - */ - oneway interface IAccessibilityServiceClientCallback { - - void setGestureResult(int gestureId, boolean handled, int interactionId); -} diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 9d3667766fec..3e0942c5c6e7 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -154,7 +154,6 @@ public abstract class WallpaperService extends Service { int mCurWindowPrivateFlags = mWindowPrivateFlags; final Rect mVisibleInsets = new Rect(); final Rect mWinFrame = new Rect(); - final Rect mSystemInsets = new Rect(); final Rect mContentInsets = new Rect(); final Configuration mConfiguration = new Configuration(); @@ -254,7 +253,7 @@ public abstract class WallpaperService extends Service { final BaseIWindow mWindow = new BaseIWindow() { @Override - public void resized(int w, int h, Rect systemInsets, Rect contentInsets, + public void resized(int w, int h, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED, reportDraw ? 1 : 0); @@ -621,7 +620,7 @@ public abstract class WallpaperService extends Service { final int relayoutResult = mSession.relayout( mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, - View.VISIBLE, 0, mWinFrame, mSystemInsets, mContentInsets, + View.VISIBLE, 0, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurfaceHolder.mSurface); if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl index 555f306d965b..b4caad3d3908 100644 --- a/core/java/android/view/IWindow.aidl +++ b/core/java/android/view/IWindow.aidl @@ -45,7 +45,7 @@ oneway interface IWindow { */ void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor); - void resized(int w, int h, in Rect systemInsets, in Rect contentInsets, + void resized(int w, int h, in Rect contentInsets, in Rect visibleInsets, boolean reportDraw, in Configuration newConfig); void dispatchAppVisibility(boolean visible); void dispatchGetNewSurface(); diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl index f26d5e1d14cf..d4a03ce657e3 100644 --- a/core/java/android/view/IWindowSession.aidl +++ b/core/java/android/view/IWindowSession.aidl @@ -58,10 +58,6 @@ interface IWindowSession { * {@link WindowManagerImpl#RELAYOUT_DEFER_SURFACE_DESTROY}. * @param outFrame Rect in which is placed the new position/size on * screen. - * @param outSystemInsets Rect in which is placed the offsets from - * <var>outFrame</var> over which any core system UI elements are - * currently covering the window. This is not generally used for - * layout, but just to know where the window is obscured. * @param outContentInsets Rect in which is placed the offsets from * <var>outFrame</var> in which the content of the window should be * placed. This can be used to modify the window layout to ensure its @@ -83,7 +79,7 @@ interface IWindowSession { */ int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, - int flags, out Rect outFrame, out Rect outSystemInsets, + int flags, out Rect outFrame, out Rect outContentInsets, out Rect outVisibleInsets, out Configuration outConfig, out Surface outSurface); diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index ee322f8b773c..fd302dc5b359 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -98,7 +98,6 @@ public class SurfaceView extends View { MyWindow mWindow; final Rect mVisibleInsets = new Rect(); final Rect mWinFrame = new Rect(); - final Rect mSystemInsets = new Rect(); final Rect mContentInsets = new Rect(); final Configuration mConfiguration = new Configuration(); @@ -231,7 +230,17 @@ public class SurfaceView extends View { public void setVisibility(int visibility) { super.setVisibility(visibility); mViewVisibility = visibility == VISIBLE; - mRequestedVisible = mWindowVisibility && mViewVisibility; + boolean newRequestedVisible = mWindowVisibility && mViewVisibility; + if (newRequestedVisible != mRequestedVisible) { + // our base class (View) invalidates the layout only when + // we go from/to the GONE state. However, SurfaceView needs + // to request a re-layout when the visibility changes at all. + // This is needed because the transparent region is computed + // as part of the layout phase, and it changes (obviously) when + // the visibility changes. + requestLayout(); + } + mRequestedVisible = newRequestedVisible; updateWindow(false, false); } @@ -472,7 +481,7 @@ public class SurfaceView extends View { mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, visible ? VISIBLE : GONE, WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY, - mWinFrame, mSystemInsets, mContentInsets, + mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mNewSurface); if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) { mReportDrawNeeded = true; @@ -606,7 +615,7 @@ public class SurfaceView extends View { mSurfaceView = new WeakReference<SurfaceView>(surfaceView); } - public void resized(int w, int h, Rect systemInsets, Rect contentInsets, + public void resized(int w, int h, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { SurfaceView surfaceView = mSurfaceView.get(); if (surfaceView != null) { diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 35a6879d1245..501cf29cc4c4 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -17190,12 +17190,6 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal boolean mUse32BitDrawingCache; /** - * Describes the parts of the window that are currently completely - * obscured by system UI elements. - */ - final Rect mSystemInsets = new Rect(); - - /** * For windows that are full-screen but using insets to layout inside * of the screen decorations, these are the current insets for the * content of the window. diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 131071917469..90e6034da65e 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -262,7 +262,6 @@ public final class ViewRootImpl implements ViewParent, final Rect mPendingVisibleInsets = new Rect(); final Rect mPendingContentInsets = new Rect(); - final Rect mPendingSystemInsets = new Rect(); final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets = new ViewTreeObserver.InternalInsetsInfo(); @@ -272,7 +271,6 @@ public final class ViewRootImpl implements ViewParent, final Configuration mPendingConfiguration = new Configuration(); class ResizedInfo { - Rect systemInsets; Rect contentInsets; Rect visibleInsets; Configuration newConfig; @@ -568,7 +566,6 @@ public final class ViewRootImpl implements ViewParent, if (mTranslator != null) { mTranslator.translateRectInScreenToAppWindow(mAttachInfo.mContentInsets); } - mPendingSystemInsets.set(0, 0, 0, 0); mPendingContentInsets.set(mAttachInfo.mContentInsets); mPendingVisibleInsets.set(0, 0, 0, 0); if (DEBUG_LAYOUT) Log.v(TAG, "Added window " + mWindow); @@ -1235,7 +1232,6 @@ public final class ViewRootImpl implements ViewParent, getRunQueue().executeActions(attachInfo.mHandler); boolean insetsChanged = false; - boolean activeRectChanged = false; boolean layoutRequested = mLayoutRequested && !mStopped; if (layoutRequested) { @@ -1247,12 +1243,7 @@ public final class ViewRootImpl implements ViewParent, // to opposite of the added touch mode. mAttachInfo.mInTouchMode = !mAddedTouchMode; ensureTouchModeLocally(mAddedTouchMode); - activeRectChanged = true; } else { - if (!mPendingSystemInsets.equals(mAttachInfo.mSystemInsets)) { - mAttachInfo.mSystemInsets.set(mPendingSystemInsets); - activeRectChanged = true; - } if (!mPendingContentInsets.equals(mAttachInfo.mContentInsets)) { insetsChanged = true; } @@ -1406,10 +1397,6 @@ public final class ViewRootImpl implements ViewParent, mPendingConfiguration.seq = 0; } - if (!mPendingSystemInsets.equals(mAttachInfo.mSystemInsets)) { - activeRectChanged = true; - mAttachInfo.mSystemInsets.set(mPendingSystemInsets); - } contentInsetsChanged = !mPendingContentInsets.equals( mAttachInfo.mContentInsets); visibleInsetsChanged = !mPendingVisibleInsets.equals( @@ -1512,7 +1499,6 @@ public final class ViewRootImpl implements ViewParent, // before actually drawing them, so it can display then // all at once. newSurface = true; - activeRectChanged = true; mFullRedrawNeeded = true; mPreviousTransparentRegion.setEmpty(); @@ -1578,7 +1564,6 @@ public final class ViewRootImpl implements ViewParent, // window size we asked for. We should avoid this by getting a maximum size from // the window session beforehand. if (mWidth != frame.width() || mHeight != frame.height()) { - activeRectChanged = true; mWidth = frame.width(); mHeight = frame.height(); } @@ -2814,7 +2799,6 @@ public final class ViewRootImpl implements ViewParent, ResizedInfo ri = (ResizedInfo)msg.obj; if (mWinFrame.width() == msg.arg1 && mWinFrame.height() == msg.arg2 - && mPendingSystemInsets.equals(ri.systemInsets) && mPendingContentInsets.equals(ri.contentInsets) && mPendingVisibleInsets.equals(ri.visibleInsets) && ((ResizedInfo)msg.obj).newConfig == null) { @@ -2831,7 +2815,6 @@ public final class ViewRootImpl implements ViewParent, mWinFrame.right = msg.arg1; mWinFrame.top = 0; mWinFrame.bottom = msg.arg2; - mPendingSystemInsets.set(((ResizedInfo)msg.obj).systemInsets); mPendingContentInsets.set(((ResizedInfo)msg.obj).contentInsets); mPendingVisibleInsets.set(((ResizedInfo)msg.obj).visibleInsets); if (msg.what == MSG_RESIZED_REPORT) { @@ -3866,7 +3849,7 @@ public final class ViewRootImpl implements ViewParent, (int) (mView.getMeasuredWidth() * appScale + 0.5f), (int) (mView.getMeasuredHeight() * appScale + 0.5f), viewVisibility, insetsPending ? WindowManagerImpl.RELAYOUT_INSETS_PENDING : 0, - mWinFrame, mPendingSystemInsets, mPendingContentInsets, mPendingVisibleInsets, + mWinFrame, mPendingContentInsets, mPendingVisibleInsets, mPendingConfiguration, mSurface); //Log.d(TAG, "<<<<<< BACK FROM relayout"); if (restore) { @@ -4062,11 +4045,10 @@ public final class ViewRootImpl implements ViewParent, mHandler.sendMessage(msg); } - public void dispatchResized(int w, int h, Rect systemInsets, Rect contentInsets, + public void dispatchResized(int w, int h, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { if (DEBUG_LAYOUT) Log.v(TAG, "Resizing " + this + ": w=" + w - + " h=" + h + " systemInsets=" + systemInsets.toShortString() - + " contentInsets=" + contentInsets.toShortString() + + " h=" + h + " contentInsets=" + contentInsets.toShortString() + " visibleInsets=" + visibleInsets.toShortString() + " reportDraw=" + reportDraw); Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT :MSG_RESIZED); @@ -4079,7 +4061,6 @@ public final class ViewRootImpl implements ViewParent, msg.arg1 = w; msg.arg2 = h; ResizedInfo ri = new ResizedInfo(); - ri.systemInsets = new Rect(systemInsets); ri.contentInsets = new Rect(contentInsets); ri.visibleInsets = new Rect(visibleInsets); ri.newConfig = newConfig; @@ -4735,11 +4716,11 @@ public final class ViewRootImpl implements ViewParent, mViewAncestor = new WeakReference<ViewRootImpl>(viewAncestor); } - public void resized(int w, int h, Rect systemInsets, Rect contentInsets, + public void resized(int w, int h, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { final ViewRootImpl viewAncestor = mViewAncestor.get(); if (viewAncestor != null) { - viewAncestor.dispatchResized(w, h, systemInsets, contentInsets, + viewAncestor.dispatchResized(w, h, contentInsets, visibleInsets, reportDraw, newConfig); } } diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index bc383687125e..0c5d6ea8e904 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -145,10 +145,6 @@ public interface WindowManagerPolicy { * @param displayFrame The frame of the overall display in which this * window can appear, used for constraining the overall dimensions * of the window. - * @param systemFrame The frame within the display that any system - * elements are currently covering. These indicate which parts of - * the window should be considered completely obscured by the screen - * decorations. * @param contentFrame The frame within the display in which we would * like active content to appear. This will cause windows behind to * be resized to match the given content frame. @@ -160,7 +156,7 @@ public interface WindowManagerPolicy { * are visible. */ public void computeFrameLw(Rect parentFrame, Rect displayFrame, - Rect systemFrame, Rect contentFrame, Rect visibleFrame); + Rect contentFrame, Rect visibleFrame); /** * Retrieve the current frame of the window that has been assigned by @@ -188,14 +184,6 @@ public interface WindowManagerPolicy { public Rect getDisplayFrameLw(); /** - * Retrieve the frame of the system elements that last covered the window. - * Must be called with the window manager lock held. - * - * @return Rect The rectangle holding the system frame. - */ - public Rect getSystemFrameLw(); - - /** * Retrieve the frame of the content area that this window was last * laid out in. This is the area in which the content of the window * should be placed. It will be smaller than the display frame to @@ -773,6 +761,21 @@ public interface WindowManagerPolicy { public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotation); /** + * Return the rectangle of the screen currently covered by system decorations. + * This will be called immediately after {@link #layoutWindowLw}. It can + * fill in the rectangle to indicate any part of the screen that it knows + * for sure is covered by system decor such as the status bar. The rectangle + * is initially set to the actual size of the screen, indicating nothing is + * covered. + * + * @param systemRect The rectangle of the screen that is not covered by + * system decoration. + * @return Returns the layer above which the system rectangle should + * not be applied. + */ + public int getSystemDecorRectLw(Rect systemRect); + + /** * Called for each window attached to the window manager as layout is * proceeding. The implementation of this function must take care of * setting the window's frame, either here or in finishLayout(). @@ -797,7 +800,7 @@ public interface WindowManagerPolicy { * */ public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset); - + /** * Called when layout of the windows is finished. After this function has * returned, all windows given to layoutWindow() <em>must</em> have had a diff --git a/core/java/com/android/internal/view/BaseIWindow.java b/core/java/com/android/internal/view/BaseIWindow.java index fbed4859f0e4..4c34d73307d0 100644 --- a/core/java/com/android/internal/view/BaseIWindow.java +++ b/core/java/com/android/internal/view/BaseIWindow.java @@ -33,7 +33,7 @@ public class BaseIWindow extends IWindow.Stub { mSession = session; } - public void resized(int w, int h, Rect systemInsets, Rect contentInsets, + public void resized(int w, int h, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { if (reportDraw) { try { diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 8e187cdad4d2..3147ba7cbb0f 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -15,7 +15,6 @@ package com.android.internal.policy.impl; -import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.IUiModeManager; @@ -37,8 +36,6 @@ import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.PixelFormat; import android.graphics.Rect; -import android.graphics.RectF; -import android.hardware.input.InputManager; import android.media.AudioManager; import android.media.IAudioService; import android.os.BatteryManager; @@ -148,7 +145,6 @@ import java.io.FileDescriptor; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; -import java.util.ArrayList; /** * WindowManagerPolicy implementation for the Android phone UI. This @@ -247,8 +243,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final int SYSTEM_UI_CHANGING_LAYOUT = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; - private static final int BTN_MOUSE = 0x110; - /* Table of Application Launch keys. Maps from key codes to intent categories. * * These are special keys that are used to launch particular kinds of applications, @@ -447,7 +441,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final Rect mTmpParentFrame = new Rect(); static final Rect mTmpDisplayFrame = new Rect(); - static final Rect mTmpSystemFrame = new Rect(); static final Rect mTmpContentFrame = new Rect(); static final Rect mTmpVisibleFrame = new Rect(); static final Rect mTmpNavigationFrame = new Rect(); @@ -2301,7 +2294,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mStatusBarLayer = mNavigationBar.getSurfaceLayer(); // And compute the final frame. mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, - mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame); + mTmpNavigationFrame, mTmpNavigationFrame); if (DEBUG_LAYOUT) Log.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); } if (DEBUG_LAYOUT) Log.i(TAG, String.format("mDock rect: (%d,%d - %d,%d)", @@ -2322,7 +2315,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mStatusBarLayer = mStatusBar.getSurfaceLayer(); // Let the status bar determine its size. - mStatusBar.computeFrameLw(pf, df, df, vf, vf); + mStatusBar.computeFrameLw(pf, df, vf, vf); // For layout, the status bar is always at the top with our fixed height. mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; @@ -2356,6 +2349,17 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } + /** {@inheritDoc} */ + public int getSystemDecorRectLw(Rect systemRect) { + systemRect.left = mSystemLeft; + systemRect.top = mSystemTop; + systemRect.right = mSystemRight; + systemRect.bottom = mSystemBottom; + if (mStatusBar != null) return mStatusBar.getSurfaceLayer(); + if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer(); + return 0; + } + void setAttachedWindowFrames(WindowState win, int fl, int adjust, WindowState attached, boolean insetDecors, Rect pf, Rect df, Rect cf, Rect vf) { if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) { @@ -2426,7 +2430,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { final Rect pf = mTmpParentFrame; final Rect df = mTmpDisplayFrame; - final Rect sf = mTmpSystemFrame; final Rect cf = mTmpContentFrame; final Rect vf = mTmpVisibleFrame; @@ -2670,20 +2673,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { df.right = df.bottom = cf.right = cf.bottom = vf.right = vf.bottom = 10000; } - // Compute the system frame. This is easy: for things behind the - // status bar, it is any application windows; otherwise it is not set. - int parentType = attached != null ? attached.getAttrs().type : attrs.type; - if (win.getSurfaceLayer() < mStatusBarLayer - && parentType < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW) { - sf.left = mSystemLeft; - sf.top = mSystemTop; - sf.right = mSystemRight; - sf.bottom = mSystemBottom; - } else { - sf.left = sf.top = -10000; - sf.right = sf.bottom = 10000; - } - if (DEBUG_LAYOUT) Log.v(TAG, "Compute frame " + attrs.getTitle() + ": sim=#" + Integer.toHexString(sim) + " attach=" + attached + " type=" + attrs.type @@ -2691,7 +2680,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { + " pf=" + pf.toShortString() + " df=" + df.toShortString() + " cf=" + cf.toShortString() + " vf=" + vf.toShortString()); - win.computeFrameLw(pf, df, sf, cf, vf); + win.computeFrameLw(pf, df, cf, vf); // Dock windows carve out the bottom of the screen, so normal windows // can't appear underneath them. diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java index 0c6d85dbb1e1..28ce1dfe965d 100644 --- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -23,7 +23,6 @@ import android.Manifest; import android.accessibilityservice.AccessibilityService; import android.accessibilityservice.AccessibilityServiceInfo; import android.accessibilityservice.IAccessibilityServiceClient; -import android.accessibilityservice.IAccessibilityServiceClientCallback; import android.accessibilityservice.IAccessibilityServiceConnection; import android.app.PendingIntent; import android.content.BroadcastReceiver; @@ -44,7 +43,6 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; -import android.os.Looper; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; @@ -58,9 +56,7 @@ import android.view.IWindow; import android.view.InputDevice; import android.view.KeyCharacterMap; import android.view.KeyEvent; -import android.view.View; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityInteractionClient; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.IAccessibilityInteractionConnection; @@ -69,8 +65,6 @@ import android.view.accessibility.IAccessibilityManager; import android.view.accessibility.IAccessibilityManagerClient; import com.android.internal.content.PackageMonitor; -import com.android.internal.os.HandlerCaller; -import com.android.internal.os.HandlerCaller.Callback; import com.android.server.accessibility.TouchExplorer.GestureListener; import com.android.server.wm.WindowManagerService; @@ -85,7 +79,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; /** * This class is instantiated by the system as a system level service and can be @@ -107,8 +100,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub private static final int OWN_PROCESS_ID = android.os.Process.myPid(); - private static final int UNDEFINED = -1; - private static int sIdCounter = 0; private static int sNextWindowId; @@ -155,10 +146,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub private Service mUiAutomationService; - private GestureHandler mGestureHandler; - - private int mDefaultGestureHandlingHelperServiceId = UNDEFINED; - /** * Handler for delayed event dispatch. */ @@ -416,7 +403,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub IAccessibilityInteractionConnection connection) throws RemoteException { synchronized (mLock) { final IWindow addedWindowToken = windowToken; - final IAccessibilityInteractionConnection addedConnection = connection; final int windowId = sNextWindowId++; AccessibilityConnectionWrapper wrapper = new AccessibilityConnectionWrapper(windowId, connection); @@ -486,44 +472,15 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub @Override public boolean onGesture(int gestureId) { - // Lazily instantiate the gesture handler. - if (mGestureHandler == null) { - mGestureHandler = new GestureHandler(); - } synchronized (mLock) { boolean handled = notifyGestureLocked(gestureId, false); if (!handled) { handled = notifyGestureLocked(gestureId, true); } - if (!handled) { - mGestureHandler.scheduleHandleGestureDefault(gestureId); - } return handled; } } - private Service getDefaultGestureHandlingHelperService() { - // Since querying of screen content is done through the - // AccessibilityInteractionClient which talks to an - // IAccessibilityServiceConnection implementation we create a proxy - // Service when necessary to enable interaction with the remote - // view tree. Note that this service is just a stateless proxy - // that does not get any events or interrupts. - if (mDefaultGestureHandlingHelperServiceId == UNDEFINED) { - ComponentName name = new ComponentName("android", - "DefaultGestureHandlingHelperService"); - AccessibilityServiceInfo info = new AccessibilityServiceInfo(); - Service service = new Service(name, info, true); - mDefaultGestureHandlingHelperServiceId = service.mId; - AccessibilityInteractionClient.getInstance().addConnection( - mDefaultGestureHandlingHelperServiceId, service); - return service; - } else { - return (Service) AccessibilityInteractionClient.getInstance() - .getConnection(mDefaultGestureHandlingHelperServiceId); - } - } - private boolean notifyGestureLocked(int gestureId, boolean isDefault) { // TODO: Now we are giving the gestures to the last enabled // service that can handle them which is the last one @@ -537,7 +494,12 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub for (int i = mServices.size() - 1; i >= 0; i--) { Service service = mServices.get(i); if (service.mReqeustTouchExplorationMode && service.mIsDefault == isDefault) { - mGestureHandler.scheduleHandleGesture(gestureId, service.mServiceInterface); + try { + service.mServiceInterface.onGesture(gestureId); + } catch (RemoteException re) { + Slog.e(LOG_TAG, "Error during sending gesture " + gestureId + + " to " + service.mService, re); + } return true; } } @@ -983,212 +945,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } } - class GestureHandler extends IAccessibilityServiceClientCallback.Stub - implements Runnable, Callback { - - private static final String THREAD_NAME = "AccessibilityGestureHandler"; - - private static final long TIMEOUT_INTERACTION_MILLIS = 5000; - - private static final int MSG_HANDLE_GESTURE = 1; - - private static final int MSG_HANDLE_GESTURE_DEFAULT = 2; - - private final AtomicInteger mInteractionCounter = new AtomicInteger(); - - private final Object mGestureLock = new Object(); - - private HandlerCaller mHandlerCaller; - - private volatile int mInteractionId = -1; - - private volatile boolean mGestureResult; - - public GestureHandler() { - synchronized (mGestureLock) { - Thread worker = new Thread(this, THREAD_NAME); - worker.start(); - while (mHandlerCaller == null) { - try { - mGestureLock.wait(); - } catch (InterruptedException ie) { - /* ignore */ - } - } - } - } - - @Override - public void run() { - Looper.prepare(); - synchronized (mGestureLock) { - mHandlerCaller = new HandlerCaller(mContext, Looper.myLooper(), this); - mGestureLock.notifyAll(); - } - Looper.loop(); - } - - @Override - public void setGestureResult(int gestureId, boolean handled, int interactionId) { - synchronized (mGestureLock) { - if (interactionId > mInteractionId) { - mGestureResult = handled; - mInteractionId = interactionId; - } - mGestureLock.notifyAll(); - } - } - - @Override - public void executeMessage(Message message) { - final int type = message.what; - switch (type) { - case MSG_HANDLE_GESTURE: { - IAccessibilityServiceClient service = - (IAccessibilityServiceClient) message.obj; - final int gestureId = message.arg1; - final int interactionId = message.arg2; - - try { - service.onGesture(gestureId, this, interactionId); - } catch (RemoteException re) { - Slog.e(LOG_TAG, "Error dispatching a gesture to a client.", re); - return; - } - - long waitTimeMillis = 0; - final long startTimeMillis = SystemClock.uptimeMillis(); - synchronized (mGestureLock) { - while (true) { - try { - // Did we get the expected callback? - if (mInteractionId == interactionId) { - break; - } - // Did we get an obsolete callback? - if (mInteractionId > interactionId) { - break; - } - // Did we time out? - final long elapsedTimeMillis = - SystemClock.uptimeMillis() - startTimeMillis; - waitTimeMillis = TIMEOUT_INTERACTION_MILLIS - elapsedTimeMillis; - if (waitTimeMillis <= 0) { - break; - } - mGestureLock.wait(waitTimeMillis); - } catch (InterruptedException ie) { - /* ignore */ - } - } - handleGestureIfNeededAndResetLocked(gestureId); - } - } break; - case MSG_HANDLE_GESTURE_DEFAULT: { - final int gestureId = message.arg1; - handleGestureDefault(gestureId); - } break; - default: { - throw new IllegalArgumentException("Unknown message type: " + type); - } - } - } - - private void handleGestureIfNeededAndResetLocked(int gestureId) { - if (!mGestureResult) { - handleGestureDefault(gestureId); - } - mGestureResult = false; - mInteractionId = -1; - } - - public void scheduleHandleGesture(int gestureId, IAccessibilityServiceClient service) { - final int interactionId = mInteractionCounter.incrementAndGet(); - mHandlerCaller.obtainMessageIIO(MSG_HANDLE_GESTURE, gestureId, interactionId, - service).sendToTarget(); - } - - public void scheduleHandleGestureDefault(int gestureId) { - final int interactionId = mInteractionCounter.incrementAndGet(); - mHandlerCaller.obtainMessageI(MSG_HANDLE_GESTURE_DEFAULT, gestureId).sendToTarget(); - } - - private void handleGestureDefault(int gestureId) { - Service service = getDefaultGestureHandlingHelperService(); - - // Global actions. - switch (gestureId) { - case AccessibilityService.GESTURE_SWIPE_DOWN_AND_LEFT: { - service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK); - } return; - case AccessibilityService.GESTURE_SWIPE_DOWN_AND_RIGHT: { - service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME); - } return; - case AccessibilityService.GESTURE_SWIPE_UP_AND_LEFT: { - service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS); - } return; - case AccessibilityService.GESTURE_SWIPE_UP_AND_RIGHT: { - service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_NOTIFICATIONS); - } return; - } - - AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance(); - - AccessibilityNodeInfo root = client.getRootInActiveWindow(service.mId); - if (root == null) { - return; - } - - AccessibilityNodeInfo current = root.findFocus( - AccessibilityNodeInfo.FOCUS_ACCESSIBILITY); - if (current == null) { - current = root; - } - - // Local actions. - AccessibilityNodeInfo next = null; - switch (gestureId) { - case AccessibilityService.GESTURE_SWIPE_UP: { - // TODO: - } break; - case AccessibilityService.GESTURE_SWIPE_DOWN: { - // TODO: - } break; - case AccessibilityService.GESTURE_SWIPE_LEFT: { - // TODO: Implement the RTL support. -// if (mLayoutDirection == View.LAYOUT_DIRECTION_LTR) { - next = current.focusSearch(View.ACCESSIBILITY_FOCUS_BACKWARD); -// } else { // LAYOUT_DIRECTION_RTL -// next = current.focusSearch(View.ACCESSIBILITY_FOCUS_FORWARD); -// } - } break; - case AccessibilityService.GESTURE_SWIPE_RIGHT: { - // TODO: Implement the RTL support. -// if (mLayoutDirection == View.LAYOUT_DIRECTION_LTR) { - next = current.focusSearch(View.ACCESSIBILITY_FOCUS_FORWARD); -// } else { // LAYOUT_DIRECTION_RTL -// next = current.focusSearch(View.ACCESSIBILITY_FOCUS_BACKWARD); -// } - } break; - case AccessibilityService.GESTURE_SWIPE_UP_AND_DOWN: { - next = current.focusSearch(View.ACCESSIBILITY_FOCUS_UP); - } break; - case AccessibilityService.GESTURE_SWIPE_DOWN_AND_UP: { - next = current.focusSearch(View.ACCESSIBILITY_FOCUS_DOWN); - } break; - case AccessibilityService.GESTURE_SWIPE_LEFT_AND_RIGHT: { - next = current.focusSearch(View.ACCESSIBILITY_FOCUS_LEFT); - } break; - case AccessibilityService.GESTURE_SWIPE_RIGHT_AND_LEFT: { - next = current.focusSearch(View.ACCESSIBILITY_FOCUS_RIGHT); - } break; - } - if (next != null && !next.equals(current)) { - next.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); - } - } - } - /** * This class represents an accessibility service. It stores all per service * data required for the service management, provides API for starting/stopping the @@ -1268,10 +1024,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub mIsDefault = (info.flags & DEFAULT) != 0; if (mIsAutomation || info.getResolveInfo().serviceInfo.applicationInfo.targetSdkVersion - // TODO: Uncomment this line and remove the line below when JellyBean - // SDK version is finalized. - // >= Build.VERSION_CODES.JELLY_BEAN) { - > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { + >= Build.VERSION_CODES.JELLY_BEAN) { mIncludeNotImportantViews = (info.flags & FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) != 0; } diff --git a/services/java/com/android/server/wm/Session.java b/services/java/com/android/server/wm/Session.java index 53c0e070461a..61c0e9cfd7ee 100644 --- a/services/java/com/android/server/wm/Session.java +++ b/services/java/com/android/server/wm/Session.java @@ -151,13 +151,13 @@ final class Session extends IWindowSession.Stub public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewFlags, - int flags, Rect outFrame, Rect outSystemInsets, Rect outContentInsets, + int flags, Rect outFrame, Rect outContentInsets, Rect outVisibleInsets, Configuration outConfig, Surface outSurface) { if (false) Slog.d(WindowManagerService.TAG, ">>>>>> ENTERED relayout from " + Binder.getCallingPid()); int res = mService.relayoutWindow(this, window, seq, attrs, requestedWidth, requestedHeight, viewFlags, flags, - outFrame, outSystemInsets, outContentInsets, outVisibleInsets, + outFrame, outContentInsets, outVisibleInsets, outConfig, outSurface); if (false) Slog.d(WindowManagerService.TAG, "<<<<<< EXITING relayout to " + Binder.getCallingPid()); diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 8c917c1ed559..b3ac6f1a8cf6 100755 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -479,6 +479,9 @@ public class WindowManagerService extends IWindowManager.Stub = new ArrayList<IRotationWatcher>(); int mDeferredRotationPauseCount; + final Rect mSystemDecorRect = new Rect(); + int mSystemDecorLayer = 0; + int mPendingLayoutChanges = 0; boolean mLayoutNeeded = true; boolean mTraversalScheduled = false; @@ -2646,7 +2649,7 @@ public class WindowManagerService extends IWindowManager.Stub public int relayoutWindow(Session session, IWindow client, int seq, WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewVisibility, int flags, - Rect outFrame, Rect outSystemInsets, Rect outContentInsets, + Rect outFrame, Rect outContentInsets, Rect outVisibleInsets, Configuration outConfig, Surface outSurface) { boolean displayed = false; boolean inTouchMode; @@ -2938,7 +2941,6 @@ public class WindowManagerService extends IWindowManager.Stub win.mAppToken.updateReportedVisibilityLocked(); } outFrame.set(win.mCompatFrame); - outSystemInsets.set(win.mSystemInsets); outContentInsets.set(win.mContentInsets); outVisibleInsets.set(win.mVisibleInsets); if (localLOGV) Slog.v( @@ -7716,6 +7718,7 @@ public class WindowManagerService extends IWindowManager.Stub } mPolicy.beginLayoutLw(dw, dh, mRotation); + mSystemDecorLayer = mPolicy.getSystemDecorRectLw(mSystemDecorRect); int seq = mLayoutSeq+1; if (seq < 0) seq = 0; @@ -8178,8 +8181,6 @@ public class WindowManagerService extends IWindowManager.Stub private void updateResizingWindows(final WindowState w) { final WindowStateAnimator winAnimator = w.mWinAnimator; if (w.mHasSurface && !w.mAppFreezing && w.mLayoutSeq == mLayoutSeq) { - w.mSystemInsetsChanged |= - !w.mLastSystemInsets.equals(w.mSystemInsets); w.mContentInsetsChanged |= !w.mLastContentInsets.equals(w.mContentInsets); w.mVisibleInsetsChanged |= @@ -8196,8 +8197,7 @@ public class WindowManagerService extends IWindowManager.Stub + ": configChanged=" + configChanged + " last=" + w.mLastFrame + " frame=" + w.mFrame); w.mLastFrame.set(w.mFrame); - if (w.mSystemInsetsChanged - || w.mContentInsetsChanged + if (w.mContentInsetsChanged || w.mVisibleInsetsChanged || winAnimator.mSurfaceResized || configChanged) { @@ -8209,7 +8209,6 @@ public class WindowManagerService extends IWindowManager.Stub + " configChanged=" + configChanged); } - w.mLastSystemInsets.set(w.mSystemInsets); w.mLastContentInsets.set(w.mContentInsets); w.mLastVisibleInsets.set(w.mVisibleInsets); makeWindowFreezingScreenIfNeededLocked(w); @@ -8593,11 +8592,10 @@ public class WindowManagerService extends IWindowManager.Stub winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING) Slog.i( TAG, "Resizing " + win + " WITH DRAW PENDING"); win.mClient.resized((int)winAnimator.mSurfaceW, - (int)winAnimator.mSurfaceH, win.mLastSystemInsets, + (int)winAnimator.mSurfaceH, win.mLastContentInsets, win.mLastVisibleInsets, winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING, configChanged ? win.mConfiguration : null); - win.mSystemInsetsChanged = false; win.mContentInsetsChanged = false; win.mVisibleInsetsChanged = false; winAnimator.mSurfaceResized = false; @@ -9588,6 +9586,8 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(" mInTouchMode="); pw.print(mInTouchMode); pw.print(" mLayoutSeq="); pw.println(mLayoutSeq); if (dumpAll) { + pw.print(" mSystemDecorRect="); pw.print(mSystemDecorRect.toShortString()); + pw.print(" mSystemDecorLayer="); pw.println(mSystemDecorLayer); if (mLastStatusBarVisibility != 0) { pw.print(" mLastStatusBarVisibility=0x"); pw.println(Integer.toHexString(mLastStatusBarVisibility)); diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index 05e7d3a0a2d1..1fd80c26c8dc 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -133,14 +133,6 @@ final class WindowState implements WindowManagerPolicy.WindowState { boolean mContentInsetsChanged; /** - * Insets that are covered by system windows such as the status bar. These - * are in the application's coordinate space (without compatibility scale applied). - */ - final Rect mSystemInsets = new Rect(); - final Rect mLastSystemInsets = new Rect(); - boolean mSystemInsetsChanged; - - /** * Set to true if we are waiting for this window to receive its * given internal insets before laying out other windows based on it. */ @@ -171,6 +163,13 @@ final class WindowState implements WindowManagerPolicy.WindowState { */ int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME; + /** + * This is rectangle of the window's surface that is not covered by + * system decorations. + */ + final Rect mSystemDecorRect = new Rect(); + final Rect mLastSystemDecorRect = new Rect(); + // Current transformation being applied. float mGlobalScale=1; float mInvGlobalScale=1; @@ -187,7 +186,6 @@ final class WindowState implements WindowManagerPolicy.WindowState { final Rect mContainingFrame = new Rect(); final Rect mDisplayFrame = new Rect(); - final Rect mSystemFrame = new Rect(); final Rect mContentFrame = new Rect(); final Rect mParentFrame = new Rect(); final Rect mVisibleFrame = new Rect(); @@ -356,7 +354,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { } @Override - public void computeFrameLw(Rect pf, Rect df, Rect sf, Rect cf, Rect vf) { + public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) { mHaveFrame = true; final Rect container = mContainingFrame; @@ -413,9 +411,6 @@ final class WindowState implements WindowManagerPolicy.WindowState { mContentChanged = true; } - final Rect system = mSystemFrame; - system.set(sf); - final Rect content = mContentFrame; content.set(cf); @@ -449,10 +444,6 @@ final class WindowState implements WindowManagerPolicy.WindowState { // Make sure the system, content and visible frames are inside of the // final window frame. - if (system.left < frame.left) system.left = frame.left; - if (system.top < frame.top) system.top = frame.top; - if (system.right > frame.right) system.right = frame.right; - if (system.bottom > frame.bottom) system.bottom = frame.bottom; if (content.left < frame.left) content.left = frame.left; if (content.top < frame.top) content.top = frame.top; if (content.right > frame.right) content.right = frame.right; @@ -462,12 +453,6 @@ final class WindowState implements WindowManagerPolicy.WindowState { if (visible.right > frame.right) visible.right = frame.right; if (visible.bottom > frame.bottom) visible.bottom = frame.bottom; - final Rect systemInsets = mSystemInsets; - systemInsets.left = system.left-frame.left; - systemInsets.top = system.top-frame.top; - systemInsets.right = frame.right-system.right; - systemInsets.bottom = frame.bottom-system.bottom; - final Rect contentInsets = mContentInsets; contentInsets.left = content.left-frame.left; contentInsets.top = content.top-frame.top; @@ -485,7 +470,6 @@ final class WindowState implements WindowManagerPolicy.WindowState { // If there is a size compatibility scale being applied to the // window, we need to apply this to its insets so that they are // reported to the app in its coordinate space. - systemInsets.scale(mInvGlobalScale); contentInsets.scale(mInvGlobalScale); visibleInsets.scale(mInvGlobalScale); @@ -506,7 +490,6 @@ final class WindowState implements WindowManagerPolicy.WindowState { + mRequestedWidth + ", mRequestedheight=" + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph + "): frame=" + mFrame.toShortString() - + " si=" + systemInsets.toShortString() + " ci=" + contentInsets.toShortString() + " vi=" + visibleInsets.toShortString()); //} @@ -529,11 +512,6 @@ final class WindowState implements WindowManagerPolicy.WindowState { } @Override - public Rect getSystemFrameLw() { - return mSystemFrame; - } - - @Override public Rect getContentFrameLw() { return mContentFrame; } @@ -1067,6 +1045,9 @@ final class WindowState implements WindowManagerPolicy.WindowState { pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw); pw.print(" last="); mLastFrame.printShortString(pw); pw.println(); + pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw); + pw.print(" last="); mLastSystemDecorRect.printShortString(pw); + pw.println(); } if (mEnforceSizeCompat) { pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw); @@ -1078,16 +1059,15 @@ final class WindowState implements WindowManagerPolicy.WindowState { pw.print(" parent="); mParentFrame.printShortString(pw); pw.print(" display="); mDisplayFrame.printShortString(pw); pw.println(); - pw.print(prefix); pw.print(" system="); mSystemFrame.printShortString(pw); - pw.print(" content="); mContentFrame.printShortString(pw); + pw.print(prefix); pw.print(" content="); mContentFrame.printShortString(pw); pw.print(" visible="); mVisibleFrame.printShortString(pw); pw.println(); - pw.print(prefix); pw.print("Cur insets: system="); mSystemInsets.printShortString(pw); - pw.print(" content="); mContentInsets.printShortString(pw);; + pw.print(prefix); pw.print("Cur insets: content="); + mContentInsets.printShortString(pw); pw.print(" visible="); mVisibleInsets.printShortString(pw); pw.println(); - pw.print(prefix); pw.print("Lst insets: system="); mLastSystemInsets.printShortString(pw); - pw.print(" content="); mLastContentInsets.printShortString(pw);; + pw.print(prefix); pw.print("Lst insets: content="); + mLastContentInsets.printShortString(pw); pw.print(" visible="); mLastVisibleInsets.printShortString(pw); pw.println(); } diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java index 293d3e879d6a..0aa1b453e293 100644 --- a/services/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/java/com/android/server/wm/WindowStateAnimator.java @@ -436,8 +436,9 @@ class WindowStateAnimator { private float mSurfaceTraceAlpha = 0; private int mLayer; - private PointF mPosition = new PointF(); - private Point mSize; + private final PointF mPosition = new PointF(); + private final Point mSize = new Point(); + private final Rect mWindowCrop = new Rect(); private boolean mShown = false; private String mName = "Not named"; @@ -445,7 +446,7 @@ class WindowStateAnimator { int pid, int display, int w, int h, int format, int flags) throws OutOfResourcesException { super(s, pid, display, w, h, format, flags); - mSize = new Point(w, h); + mSize.set(w, h); Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by " + Debug.getCallers(3)); } @@ -455,7 +456,7 @@ class WindowStateAnimator { throws OutOfResourcesException { super(s, pid, name, display, w, h, format, flags); mName = name; - mSize = new Point(w, h); + mSize.set(w, h); Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by " + Debug.getCallers(3)); } @@ -489,7 +490,7 @@ class WindowStateAnimator { @Override public void setPosition(float x, float y) { super.setPosition(x, y); - mPosition = new PointF(x, y); + mPosition.set(x, y); Slog.v(SURFACE_TAG, "setPosition: " + this + ". Called by " + Debug.getCallers(3)); } @@ -497,12 +498,20 @@ class WindowStateAnimator { @Override public void setSize(int w, int h) { super.setSize(w, h); - mSize = new Point(w, h); + mSize.set(w, h); Slog.v(SURFACE_TAG, "setSize: " + this + ". Called by " + Debug.getCallers(3)); } @Override + public void setWindowCrop(Rect crop) { + super.setWindowCrop(crop); + mWindowCrop.set(crop); + Slog.v(SURFACE_TAG, "setWindowCrop: " + this + ". Called by " + + Debug.getCallers(3)); + } + + @Override public void hide() { super.hide(); mShown = false; @@ -545,7 +554,8 @@ class WindowStateAnimator { return "Surface " + Integer.toHexString(System.identityHashCode(this)) + " " + mName + ": shown=" + mShown + " layer=" + mLayer + " alpha=" + mSurfaceTraceAlpha + " " + mPosition.x + "," + mPosition.y - + " " + mSize.x + "x" + mSize.y; + + " " + mSize.x + "x" + mSize.y + + " crop=" + mWindowCrop.toShortString(); } } @@ -596,6 +606,7 @@ class WindowStateAnimator { mSurfaceY = 0; mSurfaceW = w; mSurfaceH = h; + mWin.mLastSystemDecorRect.set(0, 0, 0, 0); try { final boolean isHwAccelerated = (attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0; @@ -991,6 +1002,55 @@ class WindowStateAnimator { } } } + + // Need to recompute a new system decor rect each time. + if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) { + // Currently can't do this cropping for scaled windows. We'll + // just keep the crop rect the same as the source surface. + w.mSystemDecorRect.set(0, 0, w.mRequestedWidth, w.mRequestedHeight); + } else if (w.mLayer >= mService.mSystemDecorLayer) { + // Above the decor layer is easy, just use the entire window. + w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), + w.mCompatFrame.height()); + } else { + final Rect decorRect = mService.mSystemDecorRect; + // Compute the offset of the window in relation to the decor rect. + final int offX = w.mXOffset + w.mFrame.left; + final int offY = w.mYOffset + w.mFrame.top; + // Initialize the decor rect to the entire frame. + w.mSystemDecorRect.set(0, 0, w.mFrame.width(), w.mFrame.height()); + // Intersect with the decor rect, offsetted by window position. + w.mSystemDecorRect.intersect(decorRect.left-offX, decorRect.top-offY, + decorRect.right-offX, decorRect.bottom-offY); + // If size compatibility is being applied to the window, the + // surface is scaled relative to the screen. Also apply this + // scaling to the crop rect. We aren't using the standard rect + // scale function because we want to round things to make the crop + // always round to a larger rect to ensure we don't crop too + // much and hide part of the window that should be seen. + if (w.mEnforceSizeCompat && w.mInvGlobalScale != 1.0f) { + final float scale = w.mInvGlobalScale; + w.mSystemDecorRect.left = (int) (w.mSystemDecorRect.left * scale - 0.5f); + w.mSystemDecorRect.top = (int) (w.mSystemDecorRect.top * scale - 0.5f); + w.mSystemDecorRect.right = (int) ((w.mSystemDecorRect.right+1) * scale - 0.5f); + w.mSystemDecorRect.bottom = (int) ((w.mSystemDecorRect.bottom+1) * scale - 0.5f); + } + } + + if (!w.mSystemDecorRect.equals(w.mLastSystemDecorRect)) { + w.mLastSystemDecorRect.set(w.mSystemDecorRect); + try { + if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, + "CROP " + w.mSystemDecorRect.toShortString(), null); + mSurface.setWindowCrop(w.mSystemDecorRect); + } catch (RuntimeException e) { + Slog.w(TAG, "Error setting crop surface of " + w + + " crop=" + w.mSystemDecorRect.toShortString(), e); + if (!recoveringMemory) { + mService.reclaimSomeSurfaceMemoryLocked(this, "crop", true); + } + } + } } public void prepareSurfaceLocked(final boolean recoveringMemory) { diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java index c44ddc6e1409..379fb81462e1 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java @@ -47,7 +47,7 @@ public final class BridgeWindow implements IWindow { } @Override - public void resized(int arg0, int arg1, Rect argBlah, Rect arg2, Rect arg3, + public void resized(int arg0, int arg1, Rect arg2, Rect arg3, boolean arg4, Configuration arg5) throws RemoteException { // pass for now. } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java index 3996d2693241..6fb599d3a11d 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java @@ -69,7 +69,7 @@ public final class BridgeWindowSession implements IWindowSession { } @Override public int relayout(IWindow arg0, int seq, LayoutParams arg1, int arg2, int arg3, int arg4, - int arg4_5, Rect arg4_6, Rect arg5, Rect arg6, Rect arg7, Configuration arg7b, + int arg4_5, Rect arg5, Rect arg6, Rect arg7, Configuration arg7b, Surface arg8) throws RemoteException { // pass for now. return 0; |