am dd7705bb: Merge "Update surfaces secure flag on screen capture setting change" into mnc-dev
* commit 'dd7705bbf26dc940ba314807f58dc9a81de452af': Update surfaces secure flag on screen capture setting change
This commit is contained in:
@@ -54,6 +54,7 @@ public class Wm extends BaseCommand {
|
||||
" wm density [reset|DENSITY]\n" +
|
||||
" wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]\n" +
|
||||
" wm scaling [off|auto]\n" +
|
||||
" wm screen-capture [userId] [true|false]\n" +
|
||||
"\n" +
|
||||
"wm size: return or override display size.\n" +
|
||||
" width and height in pixels unless suffixed with 'dp'.\n" +
|
||||
@@ -62,7 +63,9 @@ public class Wm extends BaseCommand {
|
||||
"\n" +
|
||||
"wm overscan: set overscan area for display.\n" +
|
||||
"\n" +
|
||||
"wm scaling: set display scaling mode.\n"
|
||||
"wm scaling: set display scaling mode.\n" +
|
||||
"\n" +
|
||||
"wm screen-capture: enable/disable screen capture.\n"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,16 +88,39 @@ public class Wm extends BaseCommand {
|
||||
runDisplayOverscan();
|
||||
} else if (op.equals("scaling")) {
|
||||
runDisplayScaling();
|
||||
} else if (op.equals("screen-capture")) {
|
||||
runSetScreenCapture();
|
||||
} else {
|
||||
showError("Error: unknown command '" + op + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void runSetScreenCapture() throws Exception {
|
||||
String userIdStr = nextArg();
|
||||
String enableStr = nextArg();
|
||||
int userId;
|
||||
boolean disable;
|
||||
|
||||
try {
|
||||
userId = Integer.parseInt(userIdStr);
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Error: bad number " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
disable = !Boolean.parseBoolean(enableStr);
|
||||
|
||||
try {
|
||||
mWm.setScreenCaptureDisabled(userId, disable);
|
||||
} catch (RemoteException e) {
|
||||
System.err.println("Error: Can't set screen capture " + e);
|
||||
}
|
||||
}
|
||||
|
||||
private void runDisplaySize() throws Exception {
|
||||
String size = nextArg();
|
||||
int w, h;
|
||||
boolean scale = true;
|
||||
if (size == null) {
|
||||
Point initialSize = new Point();
|
||||
Point baseSize = new Point();
|
||||
@@ -181,7 +207,6 @@ public class Wm extends BaseCommand {
|
||||
private void runDisplayOverscan() throws Exception {
|
||||
String overscanStr = nextArgRequired();
|
||||
Rect rect = new Rect();
|
||||
int density;
|
||||
if ("reset".equals(overscanStr)) {
|
||||
rect.set(0, 0, 0, 0);
|
||||
} else {
|
||||
|
||||
@@ -453,6 +453,19 @@ public class SurfaceControl {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the security of the surface. Setting the flag is equivalent to creating the
|
||||
* Surface with the {@link #SECURE} flag.
|
||||
*/
|
||||
public void setSecure(boolean isSecure) {
|
||||
checkNotReleased();
|
||||
if (isSecure) {
|
||||
nativeSetFlags(mNativeObject, SECURE, SECURE);
|
||||
} else {
|
||||
nativeSetFlags(mNativeObject, 0, SECURE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* set display parameters.
|
||||
* needs to be inside open/closeTransaction block
|
||||
|
||||
@@ -2671,6 +2671,16 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
synchronized(mWindowMap) {
|
||||
mScreenCaptureDisabled.put(userId, disabled);
|
||||
// Update secure surface for all windows belonging to this user.
|
||||
for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
|
||||
WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
|
||||
for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
|
||||
final WindowState win = windows.get(winNdx);
|
||||
if (win.mHasSurface && userId == UserHandle.getUserId(win.mOwnerUid)) {
|
||||
win.mWinAnimator.setSecureLocked(disabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -657,6 +657,11 @@ class WindowStateAnimator {
|
||||
super.setOpaque(isOpaque);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecure(boolean isSecure) {
|
||||
super.setSecure(isSecure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
|
||||
if (dsdx != mDsdx || dtdx != mDtdx || dsdy != mDsdy || dtdy != mDtdy) {
|
||||
@@ -1663,6 +1668,22 @@ class WindowStateAnimator {
|
||||
}
|
||||
}
|
||||
|
||||
void setSecureLocked(boolean isSecure) {
|
||||
if (mSurfaceControl == null) {
|
||||
return;
|
||||
}
|
||||
if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setSecureLocked");
|
||||
SurfaceControl.openTransaction();
|
||||
try {
|
||||
if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, "isSecure=" + isSecure,
|
||||
null);
|
||||
mSurfaceControl.setSecure(isSecure);
|
||||
} finally {
|
||||
SurfaceControl.closeTransaction();
|
||||
if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION setSecureLocked");
|
||||
}
|
||||
}
|
||||
|
||||
// This must be called while inside a transaction.
|
||||
boolean performShowLocked() {
|
||||
if (mWin.isHiddenFromUserLocked()) {
|
||||
|
||||
Reference in New Issue
Block a user