Merge \"Limit global drags to apps targeting SDK 24 and above\" into nyc-dev

am: f33af2285b

Change-Id: I539f39cfea50f34dade2141829b21d422809b09f
This commit is contained in:
Yorke Lee
2016-06-16 21:22:22 +00:00
committed by android-build-merger
7 changed files with 18 additions and 6 deletions

View File

@@ -106,12 +106,13 @@ interface IWindowManager
* @param alwaysFocusable True if the app windows are always focusable regardless of the stack * @param alwaysFocusable True if the app windows are always focusable regardless of the stack
* they are in. * they are in.
* @param homeTask True if this is the task. * @param homeTask True if this is the task.
* @param targetSdkVersion The application's target SDK version
*/ */
void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId, void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId,
int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId, int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId,
int configChanges, boolean voiceInteraction, boolean launchTaskBehind, int configChanges, boolean voiceInteraction, boolean launchTaskBehind,
in Rect taskBounds, in Configuration configuration, int taskResizeMode, in Rect taskBounds, in Configuration configuration, int taskResizeMode,
boolean alwaysFocusable, boolean homeTask); boolean alwaysFocusable, boolean homeTask, int targetSdkVersion);
/** /**
* *
* @param token The token we are adding to the input task Id. * @param token The token we are adding to the input task Id.

View File

@@ -5177,7 +5177,8 @@ final class ActivityStack {
r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen, r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen,
(r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges, (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges,
task.voiceSession != null, r.mLaunchTaskBehind, bounds, task.mOverrideConfig, task.voiceSession != null, r.mLaunchTaskBehind, bounds, task.mOverrideConfig,
task.mResizeMode, r.isAlwaysFocusable(), task.isHomeTask()); task.mResizeMode, r.isAlwaysFocusable(), task.isHomeTask(),
r.appInfo.targetSdkVersion);
r.taskConfigOverride = task.mOverrideConfig; r.taskConfigOverride = task.mOverrideConfig;
} }

View File

@@ -72,6 +72,7 @@ class AppWindowToken extends WindowToken {
int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
boolean layoutConfigChanges; boolean layoutConfigChanges;
boolean showForAllUsers; boolean showForAllUsers;
int targetSdk;
// The input dispatching timeout for this application token in nanoseconds. // The input dispatching timeout for this application token in nanoseconds.
long inputDispatchingTimeoutNanos; long inputDispatchingTimeoutNanos;

View File

@@ -28,6 +28,7 @@ import android.content.Context;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.Point; import android.graphics.Point;
import android.hardware.input.InputManager; import android.hardware.input.InputManager;
import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.os.Message; import android.os.Message;
import android.os.Process; import android.os.Process;
@@ -289,7 +290,7 @@ class DragState {
if (!targetWin.isPotentialDragTarget()) { if (!targetWin.isPotentialDragTarget()) {
return false; return false;
} }
if ((mFlags & View.DRAG_FLAG_GLOBAL) == 0) { if ((mFlags & View.DRAG_FLAG_GLOBAL) == 0 || !targetWindowSupportsGlobalDrag(targetWin)) {
// Drag is limited to the current window. // Drag is limited to the current window.
if (mLocalWin != targetWin.mClient.asBinder()) { if (mLocalWin != targetWin.mClient.asBinder()) {
return false; return false;
@@ -300,6 +301,13 @@ class DragState {
mSourceUserId == UserHandle.getUserId(targetWin.getOwningUid()); mSourceUserId == UserHandle.getUserId(targetWin.getOwningUid());
} }
private boolean targetWindowSupportsGlobalDrag(WindowState targetWin) {
// Global drags are limited to system windows, and windows for apps that are targeting N and
// above.
return targetWin.mAppToken == null
|| targetWin.mAppToken.targetSdk >= Build.VERSION_CODES.N;
}
/* helper - send a ACTION_DRAG_STARTED event only if the window has not /* helper - send a ACTION_DRAG_STARTED event only if the window has not
* previously been notified, i.e. it became visible after the drag operation * previously been notified, i.e. it became visible after the drag operation
* was begun. This is a rare case. * was begun. This is a rare case.

View File

@@ -3420,7 +3420,7 @@ public class WindowManagerService extends IWindowManager.Stub
int requestedOrientation, boolean fullscreen, boolean showForAllUsers, int userId, int requestedOrientation, boolean fullscreen, boolean showForAllUsers, int userId,
int configChanges, boolean voiceInteraction, boolean launchTaskBehind, int configChanges, boolean voiceInteraction, boolean launchTaskBehind,
Rect taskBounds, Configuration config, int taskResizeMode, boolean alwaysFocusable, Rect taskBounds, Configuration config, int taskResizeMode, boolean alwaysFocusable,
boolean homeTask) { boolean homeTask, int targetSdkVersion) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"addAppToken()")) { "addAppToken()")) {
throw new SecurityException("Requires MANAGE_APP_TOKENS permission"); throw new SecurityException("Requires MANAGE_APP_TOKENS permission");
@@ -3450,6 +3450,7 @@ public class WindowManagerService extends IWindowManager.Stub
atoken.inputDispatchingTimeoutNanos = inputDispatchingTimeoutNanos; atoken.inputDispatchingTimeoutNanos = inputDispatchingTimeoutNanos;
atoken.appFullscreen = fullscreen; atoken.appFullscreen = fullscreen;
atoken.showForAllUsers = showForAllUsers; atoken.showForAllUsers = showForAllUsers;
atoken.targetSdk = targetSdkVersion;
atoken.requestedOrientation = requestedOrientation; atoken.requestedOrientation = requestedOrientation;
atoken.layoutConfigChanges = (configChanges & atoken.layoutConfigChanges = (configChanges &
(ActivityInfo.CONFIG_SCREEN_SIZE | ActivityInfo.CONFIG_ORIENTATION)) != 0; (ActivityInfo.CONFIG_SCREEN_SIZE | ActivityInfo.CONFIG_ORIENTATION)) != 0;

View File

@@ -93,7 +93,7 @@ public class WindowManagerPermissionTests extends TestCase {
try { try {
mWm.addAppToken(0, null, 0, 0, 0, false, false, 0, 0, false, false, null, mWm.addAppToken(0, null, 0, 0, 0, false, false, 0, 0, false, false, null,
Configuration.EMPTY, 0, false, false); Configuration.EMPTY, 0, false, false, 0);
fail("IWindowManager.addAppToken did not throw SecurityException as" fail("IWindowManager.addAppToken did not throw SecurityException as"
+ " expected"); + " expected");
} catch (SecurityException e) { } catch (SecurityException e) {

View File

@@ -78,7 +78,7 @@ public class IWindowManagerImpl implements IWindowManager {
@Override @Override
public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, int arg4, public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, int arg4,
boolean arg5, boolean arg6, int arg7, int arg8, boolean arg9, boolean arg10, boolean arg5, boolean arg6, int arg7, int arg8, boolean arg9, boolean arg10,
Rect arg11, Configuration arg12, int arg13, boolean arg14, boolean arg15) Rect arg11, Configuration arg12, int arg13, boolean arg14, boolean arg15, int arg16)
throws RemoteException { throws RemoteException {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }