Back-port fixes for b/62196835
am: 5bdffc5d57
Change-Id: Ia5dafc7a8724d296e710f32d936bb493b51951de
This commit is contained in:
@@ -547,6 +547,25 @@ public interface WindowManager extends ViewManager {
|
|||||||
*/
|
*/
|
||||||
public static final int LAST_SYSTEM_WINDOW = 2999;
|
public static final int LAST_SYSTEM_WINDOW = 2999;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the window type is an alert window.
|
||||||
|
*
|
||||||
|
* @param type The window type.
|
||||||
|
* @return If the window type is an alert window.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static boolean isSystemAlertWindowType(int type) {
|
||||||
|
switch (type) {
|
||||||
|
case TYPE_PHONE:
|
||||||
|
case TYPE_PRIORITY_PHONE:
|
||||||
|
case TYPE_SYSTEM_ALERT:
|
||||||
|
case TYPE_SYSTEM_ERROR:
|
||||||
|
case TYPE_SYSTEM_OVERLAY:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** @deprecated this is ignored, this value is set automatically when needed. */
|
/** @deprecated this is ignored, this value is set automatically when needed. */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final int MEMORY_TYPE_NORMAL = 0;
|
public static final int MEMORY_TYPE_NORMAL = 0;
|
||||||
@@ -1086,6 +1105,15 @@ public interface WindowManager extends ViewManager {
|
|||||||
* {@hide} */
|
* {@hide} */
|
||||||
public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200;
|
public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to indicate that any window added by an application process that is of type
|
||||||
|
* {@link #TYPE_TOAST} or that requires
|
||||||
|
* {@link android.app.AppOpsManager#OP_SYSTEM_ALERT_WINDOW} permission should be hidden when
|
||||||
|
* this window is visible.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final int PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 0x00080000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Control flags that are private to the platform.
|
* Control flags that are private to the platform.
|
||||||
* @hide
|
* @hide
|
||||||
|
|||||||
@@ -1848,6 +1848,15 @@
|
|||||||
android:description="@string/permdesc_internalSystemWindow"
|
android:description="@string/permdesc_internalSystemWindow"
|
||||||
android:protectionLevel="signature" />
|
android:protectionLevel="signature" />
|
||||||
|
|
||||||
|
<!-- Allows an application to use
|
||||||
|
{@link android.view.WindowManager.LayoutsParams#PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS}
|
||||||
|
to hide non-system-overlay windows.
|
||||||
|
<p>Not for use by third-party applications.
|
||||||
|
@hide
|
||||||
|
-->
|
||||||
|
<permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"
|
||||||
|
android:protectionLevel="signature" />
|
||||||
|
|
||||||
<!-- Allows an application to manage (create, destroy,
|
<!-- Allows an application to manage (create, destroy,
|
||||||
Z-order) application tokens in the window manager.
|
Z-order) application tokens in the window manager.
|
||||||
<p>Not for use by third-party applications. -->
|
<p>Not for use by third-party applications. -->
|
||||||
|
|||||||
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package com.android.server.wm;
|
package com.android.server.wm;
|
||||||
|
|
||||||
|
import static android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||||
|
import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
|
||||||
|
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||||
|
|
||||||
import android.view.IWindowId;
|
import android.view.IWindowId;
|
||||||
import com.android.internal.view.IInputContext;
|
import com.android.internal.view.IInputContext;
|
||||||
import com.android.internal.view.IInputMethodClient;
|
import com.android.internal.view.IInputMethodClient;
|
||||||
@@ -59,6 +63,8 @@ final class Session extends IWindowSession.Stub
|
|||||||
final int mUid;
|
final int mUid;
|
||||||
final int mPid;
|
final int mPid;
|
||||||
final String mStringName;
|
final String mStringName;
|
||||||
|
final boolean mCanAddInternalSystemWindow;
|
||||||
|
final boolean mCanHideNonSystemOverlayWindows;
|
||||||
SurfaceSession mSurfaceSession;
|
SurfaceSession mSurfaceSession;
|
||||||
int mNumWindow = 0;
|
int mNumWindow = 0;
|
||||||
boolean mClientDead = false;
|
boolean mClientDead = false;
|
||||||
@@ -70,6 +76,10 @@ final class Session extends IWindowSession.Stub
|
|||||||
mInputContext = inputContext;
|
mInputContext = inputContext;
|
||||||
mUid = Binder.getCallingUid();
|
mUid = Binder.getCallingUid();
|
||||||
mPid = Binder.getCallingPid();
|
mPid = Binder.getCallingPid();
|
||||||
|
mCanAddInternalSystemWindow = service.mContext.checkCallingOrSelfPermission(
|
||||||
|
INTERNAL_SYSTEM_WINDOW) == PERMISSION_GRANTED;
|
||||||
|
mCanHideNonSystemOverlayWindows = service.mContext.checkCallingOrSelfPermission(
|
||||||
|
HIDE_NON_SYSTEM_OVERLAY_WINDOWS) == PERMISSION_GRANTED;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Session{");
|
sb.append("Session{");
|
||||||
sb.append(Integer.toHexString(System.identityHashCode(this)));
|
sb.append(Integer.toHexString(System.identityHashCode(this)));
|
||||||
@@ -500,4 +510,4 @@ final class Session extends IWindowSession.Stub
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return mStringName;
|
return mStringName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -390,6 +390,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
*/
|
*/
|
||||||
ArrayList<WindowState> mForceRemoves;
|
ArrayList<WindowState> mForceRemoves;
|
||||||
|
|
||||||
|
/** List of window currently causing non-system overlay windows to be hidden. */
|
||||||
|
private ArrayList<WindowState> mHidingNonSystemOverlayWindows = new ArrayList<WindowState>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Windows that clients are waiting to have drawn.
|
* Windows that clients are waiting to have drawn.
|
||||||
*/
|
*/
|
||||||
@@ -2274,6 +2277,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean hideSystemAlertWindows = !mHidingNonSystemOverlayWindows.isEmpty();
|
||||||
|
win.setForceHideNonSystemOverlayWindowIfNeeded(hideSystemAlertWindows);
|
||||||
|
|
||||||
if (type == TYPE_APPLICATION_STARTING && token.appWindowToken != null) {
|
if (type == TYPE_APPLICATION_STARTING && token.appWindowToken != null) {
|
||||||
token.appWindowToken.startingWindow = win;
|
token.appWindowToken.startingWindow = win;
|
||||||
if (DEBUG_STARTING_WINDOW) Slog.v (TAG, "addWindow: " + token.appWindowToken
|
if (DEBUG_STARTING_WINDOW) Slog.v (TAG, "addWindow: " + token.appWindowToken
|
||||||
@@ -2501,6 +2507,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
windows.remove(win);
|
windows.remove(win);
|
||||||
mPendingRemove.remove(win);
|
mPendingRemove.remove(win);
|
||||||
mResizingWindows.remove(win);
|
mResizingWindows.remove(win);
|
||||||
|
updateNonSystemOverlayWindowsVisibilityIfNeeded(win, false /* surfaceShown */);
|
||||||
mWindowsChanged = true;
|
mWindowsChanged = true;
|
||||||
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Final remove of window: " + win);
|
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Final remove of window: " + win);
|
||||||
|
|
||||||
@@ -10878,4 +10885,34 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
public Object getWindowManagerLock() {
|
public Object getWindowManagerLock() {
|
||||||
return mWindowMap;
|
return mWindowMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateNonSystemOverlayWindowsVisibilityIfNeeded(WindowState win, boolean surfaceShown) {
|
||||||
|
if (!win.hideNonSystemOverlayWindowsWhenVisible()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final boolean systemAlertWindowsHidden = !mHidingNonSystemOverlayWindows.isEmpty();
|
||||||
|
if (surfaceShown) {
|
||||||
|
if (!mHidingNonSystemOverlayWindows.contains(win)) {
|
||||||
|
mHidingNonSystemOverlayWindows.add(win);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mHidingNonSystemOverlayWindows.remove(win);
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean hideSystemAlertWindows = !mHidingNonSystemOverlayWindows.isEmpty();
|
||||||
|
|
||||||
|
if (systemAlertWindowsHidden == hideSystemAlertWindows) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int numDisplays = mDisplayContents.size();
|
||||||
|
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
|
||||||
|
final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||||
|
final int numWindows = windows.size();
|
||||||
|
for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
|
||||||
|
final WindowState w = windows.get(winNdx);
|
||||||
|
w.setForceHideNonSystemOverlayWindowIfNeeded(hideSystemAlertWindows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,12 +21,15 @@ import static com.android.server.wm.WindowManagerService.DEBUG_LAYOUT;
|
|||||||
|
|
||||||
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
|
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
|
||||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
|
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
|
||||||
|
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||||
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
|
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
|
||||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
|
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
|
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
|
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD;
|
import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD;
|
||||||
|
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
|
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
|
||||||
|
import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType;
|
||||||
|
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.os.RemoteCallbackList;
|
import android.os.RemoteCallbackList;
|
||||||
@@ -76,6 +79,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
|
|||||||
final int mAppOp;
|
final int mAppOp;
|
||||||
// UserId and appId of the owner. Don't display windows of non-current user.
|
// UserId and appId of the owner. Don't display windows of non-current user.
|
||||||
final int mOwnerUid;
|
final int mOwnerUid;
|
||||||
|
final boolean mOwnerCanAddInternalSystemWindow;
|
||||||
final IWindowId mWindowId;
|
final IWindowId mWindowId;
|
||||||
WindowToken mToken;
|
WindowToken mToken;
|
||||||
WindowToken mRootToken;
|
WindowToken mRootToken;
|
||||||
@@ -101,6 +105,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
|
|||||||
boolean mPolicyVisibility = true;
|
boolean mPolicyVisibility = true;
|
||||||
boolean mPolicyVisibilityAfterAnim = true;
|
boolean mPolicyVisibilityAfterAnim = true;
|
||||||
boolean mAppOpVisibility = true;
|
boolean mAppOpVisibility = true;
|
||||||
|
// This is a non-system overlay window that is currently force hidden.
|
||||||
|
private boolean mForceHideNonSystemOverlayWindow;
|
||||||
boolean mAppFreezing;
|
boolean mAppFreezing;
|
||||||
boolean mAttachedHidden; // is our parent window hidden?
|
boolean mAttachedHidden; // is our parent window hidden?
|
||||||
boolean mWallpaperVisible; // for wallpaper, what was last vis report?
|
boolean mWallpaperVisible; // for wallpaper, what was last vis report?
|
||||||
@@ -312,6 +318,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
|
|||||||
mAppOp = appOp;
|
mAppOp = appOp;
|
||||||
mToken = token;
|
mToken = token;
|
||||||
mOwnerUid = s.mUid;
|
mOwnerUid = s.mUid;
|
||||||
|
mOwnerCanAddInternalSystemWindow = s.mCanAddInternalSystemWindow;
|
||||||
mWindowId = new IWindowId.Stub() {
|
mWindowId = new IWindowId.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void registerFocusObserver(IWindowFocusObserver observer) {
|
public void registerFocusObserver(IWindowFocusObserver observer) {
|
||||||
@@ -1089,6 +1096,10 @@ final class WindowState implements WindowManagerPolicy.WindowState {
|
|||||||
// Being hidden due to app op request.
|
// Being hidden due to app op request.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (mForceHideNonSystemOverlayWindow) {
|
||||||
|
// This is an alert window that is currently force hidden.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (mPolicyVisibility && mPolicyVisibilityAfterAnim) {
|
if (mPolicyVisibility && mPolicyVisibilityAfterAnim) {
|
||||||
// Already showing.
|
// Already showing.
|
||||||
return false;
|
return false;
|
||||||
@@ -1162,6 +1173,22 @@ final class WindowState implements WindowManagerPolicy.WindowState {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setForceHideNonSystemOverlayWindowIfNeeded(boolean forceHide) {
|
||||||
|
if (mOwnerCanAddInternalSystemWindow
|
||||||
|
|| (!isSystemAlertWindowType(mAttrs.type) && mAttrs.type != TYPE_TOAST)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mForceHideNonSystemOverlayWindow == forceHide) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mForceHideNonSystemOverlayWindow = forceHide;
|
||||||
|
if (forceHide) {
|
||||||
|
hideLw(true /* doAnimation */, true /* requestAnim */);
|
||||||
|
} else {
|
||||||
|
showLw(true /* doAnimation */, true /* requestAnim */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setAppOpVisibilityLw(boolean state) {
|
public void setAppOpVisibilityLw(boolean state) {
|
||||||
if (mAppOpVisibility != state) {
|
if (mAppOpVisibility != state) {
|
||||||
mAppOpVisibility = state;
|
mAppOpVisibility = state;
|
||||||
@@ -1458,6 +1485,17 @@ final class WindowState implements WindowManagerPolicy.WindowState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if any window added by an application process that if of type
|
||||||
|
* {@link android.view.WindowManager.LayoutParams#TYPE_TOAST} or that requires that requires
|
||||||
|
* {@link android.app.AppOpsManager#OP_SYSTEM_ALERT_WINDOW} permission should be hidden when
|
||||||
|
* this window is visible.
|
||||||
|
*/
|
||||||
|
boolean hideNonSystemOverlayWindowsWhenVisible() {
|
||||||
|
return (mAttrs.privateFlags & PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS) != 0
|
||||||
|
&& mSession.mCanHideNonSystemOverlayWindows;
|
||||||
|
}
|
||||||
|
|
||||||
String makeInputChannelName() {
|
String makeInputChannelName() {
|
||||||
return Integer.toHexString(System.identityHashCode(this))
|
return Integer.toHexString(System.identityHashCode(this))
|
||||||
+ " " + mAttrs.getTitle();
|
+ " " + mAttrs.getTitle();
|
||||||
|
|||||||
@@ -425,6 +425,7 @@ class WindowStateAnimator {
|
|||||||
"HIDE (performLayout)", null);
|
"HIDE (performLayout)", null);
|
||||||
if (mSurfaceControl != null) {
|
if (mSurfaceControl != null) {
|
||||||
mSurfaceShown = false;
|
mSurfaceShown = false;
|
||||||
|
mService.updateNonSystemOverlayWindowsVisibilityIfNeeded(mWin, false);
|
||||||
try {
|
try {
|
||||||
mSurfaceControl.hide();
|
mSurfaceControl.hide();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
@@ -1488,6 +1489,7 @@ class WindowStateAnimator {
|
|||||||
if (mSurfaceControl != null) {
|
if (mSurfaceControl != null) {
|
||||||
mSurfaceShown = true;
|
mSurfaceShown = true;
|
||||||
mSurfaceControl.show();
|
mSurfaceControl.show();
|
||||||
|
mService.updateNonSystemOverlayWindowsVisibilityIfNeeded(mWin, true);
|
||||||
if (mWin.mTurnOnScreen) {
|
if (mWin.mTurnOnScreen) {
|
||||||
if (DEBUG_VISIBILITY) Slog.v(TAG,
|
if (DEBUG_VISIBILITY) Slog.v(TAG,
|
||||||
"Show surface turning screen on: " + mWin);
|
"Show surface turning screen on: " + mWin);
|
||||||
|
|||||||
Reference in New Issue
Block a user