Merge "Don't allow windows with invalid types to be added." into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1ea6afe123
@@ -560,39 +560,43 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
case WindowManagerGlobal.ADD_BAD_APP_TOKEN:
|
case WindowManagerGlobal.ADD_BAD_APP_TOKEN:
|
||||||
case WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN:
|
case WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN:
|
||||||
throw new WindowManager.BadTokenException(
|
throw new WindowManager.BadTokenException(
|
||||||
"Unable to add window -- token " + attrs.token
|
"Unable to add window -- token " + attrs.token
|
||||||
+ " is not valid; is your activity running?");
|
+ " is not valid; is your activity running?");
|
||||||
case WindowManagerGlobal.ADD_NOT_APP_TOKEN:
|
case WindowManagerGlobal.ADD_NOT_APP_TOKEN:
|
||||||
throw new WindowManager.BadTokenException(
|
throw new WindowManager.BadTokenException(
|
||||||
"Unable to add window -- token " + attrs.token
|
"Unable to add window -- token " + attrs.token
|
||||||
+ " is not for an application");
|
+ " is not for an application");
|
||||||
case WindowManagerGlobal.ADD_APP_EXITING:
|
case WindowManagerGlobal.ADD_APP_EXITING:
|
||||||
throw new WindowManager.BadTokenException(
|
throw new WindowManager.BadTokenException(
|
||||||
"Unable to add window -- app for token " + attrs.token
|
"Unable to add window -- app for token " + attrs.token
|
||||||
+ " is exiting");
|
+ " is exiting");
|
||||||
case WindowManagerGlobal.ADD_DUPLICATE_ADD:
|
case WindowManagerGlobal.ADD_DUPLICATE_ADD:
|
||||||
throw new WindowManager.BadTokenException(
|
throw new WindowManager.BadTokenException(
|
||||||
"Unable to add window -- window " + mWindow
|
"Unable to add window -- window " + mWindow
|
||||||
+ " has already been added");
|
+ " has already been added");
|
||||||
case WindowManagerGlobal.ADD_STARTING_NOT_NEEDED:
|
case WindowManagerGlobal.ADD_STARTING_NOT_NEEDED:
|
||||||
// Silently ignore -- we would have just removed it
|
// Silently ignore -- we would have just removed it
|
||||||
// right away, anyway.
|
// right away, anyway.
|
||||||
return;
|
return;
|
||||||
case WindowManagerGlobal.ADD_MULTIPLE_SINGLETON:
|
case WindowManagerGlobal.ADD_MULTIPLE_SINGLETON:
|
||||||
throw new WindowManager.BadTokenException(
|
throw new WindowManager.BadTokenException(
|
||||||
"Unable to add window " + mWindow +
|
"Unable to add window " + mWindow +
|
||||||
" -- another window of this type already exists");
|
" -- another window of this type already exists");
|
||||||
case WindowManagerGlobal.ADD_PERMISSION_DENIED:
|
case WindowManagerGlobal.ADD_PERMISSION_DENIED:
|
||||||
throw new WindowManager.BadTokenException(
|
throw new WindowManager.BadTokenException(
|
||||||
"Unable to add window " + mWindow +
|
"Unable to add window " + mWindow +
|
||||||
" -- permission denied for this window type");
|
" -- permission denied for this window type");
|
||||||
case WindowManagerGlobal.ADD_INVALID_DISPLAY:
|
case WindowManagerGlobal.ADD_INVALID_DISPLAY:
|
||||||
throw new WindowManager.InvalidDisplayException(
|
throw new WindowManager.InvalidDisplayException(
|
||||||
"Unable to add window " + mWindow +
|
"Unable to add window " + mWindow +
|
||||||
" -- the specified display can not be found");
|
" -- the specified display can not be found");
|
||||||
|
case WindowManagerGlobal.ADD_INVALID_TYPE:
|
||||||
|
throw new WindowManager.InvalidDisplayException(
|
||||||
|
"Unable to add window " + mWindow
|
||||||
|
+ " -- the specified window type is not valid");
|
||||||
}
|
}
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"Unable to add window -- unknown error code " + res);
|
"Unable to add window -- unknown error code " + res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view instanceof RootViewSurfaceTaker) {
|
if (view instanceof RootViewSurfaceTaker) {
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ public final class WindowManagerGlobal {
|
|||||||
public static final int ADD_MULTIPLE_SINGLETON = -7;
|
public static final int ADD_MULTIPLE_SINGLETON = -7;
|
||||||
public static final int ADD_PERMISSION_DENIED = -8;
|
public static final int ADD_PERMISSION_DENIED = -8;
|
||||||
public static final int ADD_INVALID_DISPLAY = -9;
|
public static final int ADD_INVALID_DISPLAY = -9;
|
||||||
|
public static final int ADD_INVALID_TYPE = -10;
|
||||||
|
|
||||||
private static WindowManagerGlobal sDefaultWindowManager;
|
private static WindowManagerGlobal sDefaultWindowManager;
|
||||||
private static IWindowManager sWindowManagerService;
|
private static IWindowManager sWindowManagerService;
|
||||||
|
|||||||
@@ -1641,8 +1641,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
|
|
||||||
outAppOp[0] = AppOpsManager.OP_NONE;
|
outAppOp[0] = AppOpsManager.OP_NONE;
|
||||||
|
|
||||||
if (type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
|
if (!((type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW)
|
||||||
|| type > WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
|
|| (type >= FIRST_SUB_WINDOW && type <= LAST_SUB_WINDOW)
|
||||||
|
|| (type >= FIRST_SYSTEM_WINDOW && type <= LAST_SYSTEM_WINDOW))) {
|
||||||
|
return WindowManagerGlobal.ADD_INVALID_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type < FIRST_SYSTEM_WINDOW || type > LAST_SYSTEM_WINDOW) {
|
||||||
|
// Window manager will make sure these are okay.
|
||||||
return WindowManagerGlobal.ADD_OKAY;
|
return WindowManagerGlobal.ADD_OKAY;
|
||||||
}
|
}
|
||||||
String permission = null;
|
String permission = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user