diff options
| author | 2018-03-01 04:21:25 +0000 | |
|---|---|---|
| committer | 2018-03-01 04:21:25 +0000 | |
| commit | 8e1522197a6ff963736953eff55a583f9297ea70 (patch) | |
| tree | 18bfb2013436bbe5081e2e4413dfd273fe72db54 | |
| parent | c7c1ce8012ab224e14d62c7140f5ecc4613960f0 (diff) | |
| parent | 7ea0cc485df85ec845679896a774483568f0b2e3 (diff) | |
Merge "Remove RemoteSurfaceTrace functionality."
9 files changed, 0 insertions, 452 deletions
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 4adcb8f15be7..914ba0c673aa 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -185,13 +185,6 @@ interface IWindowManager */ void setScreenCaptureDisabled(int userId, boolean disabled); - /** - * Testing and debugging infrastructure for writing surface events - * to given FD. See RemoteSurfaceTrace.java or Wm.java for format. - */ - void enableSurfaceTrace(in ParcelFileDescriptor fd); - void disableSurfaceTrace(); - // These can only be called with the SET_ORIENTATION permission. /** * Update the current screen rotation based on the current state of diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 332bdb7fa8fb..232e1c17869b 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -2607,18 +2607,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo }, false /* traverseTopToBottom */); } - void enableSurfaceTrace(FileDescriptor fd) { - forAllWindows(w -> { - w.mWinAnimator.enableSurfaceTrace(fd); - }, true /* traverseTopToBottom */); - } - - void disableSurfaceTrace() { - forAllWindows(w -> { - w.mWinAnimator.disableSurfaceTrace(); - }, true /* traverseTopToBottom */); - } - /** * Starts the Keyguard exit animation on all windows that don't belong to an app token. */ diff --git a/services/core/java/com/android/server/wm/RemoteEventTrace.java b/services/core/java/com/android/server/wm/RemoteEventTrace.java deleted file mode 100644 index b214d35f208c..000000000000 --- a/services/core/java/com/android/server/wm/RemoteEventTrace.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2016 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 com.android.server.wm; - -import java.io.FileDescriptor; -import java.io.FileOutputStream; -import java.io.DataOutputStream; - -import android.os.StrictMode; -import android.util.Slog; -import android.os.Debug; - -// Counterpart to remote surface trace for events which are not tied to a particular surface. -class RemoteEventTrace { - private static final String TAG = "RemoteEventTrace"; - - // We terminate all our messages with a recognizable marker, to avoid issues - // with partial reads (which ADB makes impossible to avoid). - static final byte[] sigil = {(byte)0xfc, (byte)0xfc, (byte)0xfc, (byte)0xfc}; - - private final WindowManagerService mService; - private final DataOutputStream mOut; - - RemoteEventTrace(WindowManagerService service, FileDescriptor fd) { - mService = service; - mOut = new DataOutputStream(new FileOutputStream(fd, false)); - } - - void openSurfaceTransaction() { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - mOut.writeUTF("OpenTransaction"); - writeSigil(); - } catch (Exception e) { - logException(e); - mService.disableSurfaceTrace(); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - } - - void closeSurfaceTransaction() { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - mOut.writeUTF("CloseTransaction"); - writeSigil(); - } catch (Exception e) { - logException(e); - mService.disableSurfaceTrace(); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - } - - private void writeSigil() throws Exception { - mOut.write(RemoteEventTrace.sigil, 0, 4); - } - - static void logException(Exception e) { - Slog.i(TAG, "Exception writing to SurfaceTrace (client vanished?): " + e.toString()); - } -} diff --git a/services/core/java/com/android/server/wm/RemoteSurfaceTrace.java b/services/core/java/com/android/server/wm/RemoteSurfaceTrace.java deleted file mode 100644 index 33e560f35dfb..000000000000 --- a/services/core/java/com/android/server/wm/RemoteSurfaceTrace.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (C) 2016 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 com.android.server.wm; - -import android.graphics.Rect; -import android.graphics.Region; -import android.os.IBinder; -import android.os.Parcel; -import android.os.StrictMode; -import android.util.Slog; -import android.view.SurfaceControl; - -import java.io.FileDescriptor; -import java.io.FileOutputStream; -import java.io.DataOutputStream; - -// A surface control subclass which logs events to a FD in binary format. -// This can be used in our CTS tests to enable a pattern similar to mocking -// the surface control. -// -// See cts/hostsidetests/../../SurfaceTraceReceiver.java for parsing side. -class RemoteSurfaceTrace extends SurfaceControl { - static final String TAG = "RemoteSurfaceTrace"; - - final FileDescriptor mWriteFd; - final DataOutputStream mOut; - - final WindowManagerService mService; - final WindowState mWindow; - - RemoteSurfaceTrace(FileDescriptor fd, SurfaceControl wrapped, - WindowState window) { - super(wrapped); - - mWriteFd = fd; - mOut = new DataOutputStream(new FileOutputStream(fd, false)); - - mWindow = window; - mService = mWindow.mService; - } - - @Override - public void setAlpha(float alpha) { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeFloatEvent("Alpha", alpha); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.setAlpha(alpha); - } - - @Override - public void setLayer(int zorder) { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeIntEvent("Layer", zorder); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.setLayer(zorder); - } - - @Override - public void setPosition(float x, float y) { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeFloatEvent("Position", x, y); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.setPosition(x, y); - } - - @Override - public void setGeometryAppliesWithResize() { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeEvent("GeometryAppliesWithResize"); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.setGeometryAppliesWithResize(); - } - - @Override - public void setSize(int w, int h) { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeIntEvent("Size", w, h); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.setSize(w, h); - } - - @Override - public void setWindowCrop(Rect crop) { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeRectEvent("Crop", crop); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.setWindowCrop(crop); - } - - @Override - public void setFinalCrop(Rect crop) { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeRectEvent("FinalCrop", crop); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.setFinalCrop(crop); - } - - @Override - public void setLayerStack(int layerStack) { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeIntEvent("LayerStack", layerStack); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.setLayerStack(layerStack); - } - - @Override - public void setMatrix(float dsdx, float dtdx, float dsdy, float dtdy) { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeFloatEvent("Matrix", dsdx, dtdx, dsdy, dtdy); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.setMatrix(dsdx, dtdx, dsdy, dtdy); - } - - @Override - public void hide() { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeEvent("Hide"); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.hide(); - } - - @Override - public void show() { - final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - writeEvent("Show"); - } finally { - StrictMode.setThreadPolicy(oldPolicy); - } - super.show(); - } - - private void writeEvent(String tag) { - try { - mOut.writeUTF(tag); - mOut.writeUTF(mWindow.getWindowTag().toString()); - writeSigil(); - } catch (Exception e) { - RemoteEventTrace.logException(e); - mService.disableSurfaceTrace(); - } - } - - private void writeIntEvent(String tag, int... values) { - try { - mOut.writeUTF(tag); - mOut.writeUTF(mWindow.getWindowTag().toString()); - for (int value: values) { - mOut.writeInt(value); - } - writeSigil(); - } catch (Exception e) { - RemoteEventTrace.logException(e); - mService.disableSurfaceTrace(); - } - } - - private void writeFloatEvent(String tag, float... values) { - try { - mOut.writeUTF(tag); - mOut.writeUTF(mWindow.getWindowTag().toString()); - for (float value: values) { - mOut.writeFloat(value); - } - writeSigil(); - } catch (Exception e) { - RemoteEventTrace.logException(e); - mService.disableSurfaceTrace(); - } - } - - private void writeRectEvent(String tag, Rect value) { - writeFloatEvent(tag, value.left, value.top, value.right, value.bottom); - } - - private void writeSigil() throws Exception { - mOut.write(RemoteEventTrace.sigil, 0, 4); - } -} diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 36d331da19e4..8d36dacadcd0 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -123,13 +123,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> { private final ArrayList<TaskStack> mTmpStackList = new ArrayList(); private final ArrayList<Integer> mTmpStackIds = new ArrayList<>(); - // State for the RemoteSurfaceTrace system used in testing. If this is enabled SurfaceControl - // instances will be replaced with an instance that writes a binary representation of all - // commands to mSurfaceTraceFd. - boolean mSurfaceTraceEnabled; - ParcelFileDescriptor mSurfaceTraceFd; - RemoteEventTrace mRemoteEventTrace; - final WallpaperController mWallpaperController; private final Handler mHandler; @@ -1002,30 +995,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> { } } - void enableSurfaceTrace(ParcelFileDescriptor pfd) { - final FileDescriptor fd = pfd.getFileDescriptor(); - if (mSurfaceTraceEnabled) { - disableSurfaceTrace(); - } - mSurfaceTraceEnabled = true; - mRemoteEventTrace = new RemoteEventTrace(mService, fd); - mSurfaceTraceFd = pfd; - for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) { - final DisplayContent dc = mChildren.get(displayNdx); - dc.enableSurfaceTrace(fd); - } - } - - void disableSurfaceTrace() { - mSurfaceTraceEnabled = false; - mRemoteEventTrace = null; - mSurfaceTraceFd = null; - for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) { - final DisplayContent dc = mChildren.get(displayNdx); - dc.disableSurfaceTrace(); - } - } - void dumpDisplayContents(PrintWriter pw) { pw.println("WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)"); if (mService.mDisplayReady) { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index d12eee36b771..0c6429a30db9 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -822,9 +822,6 @@ public class WindowManagerService extends IWindowManager.Stub try { Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "openSurfaceTransaction"); synchronized (mWindowMap) { - if (mRoot.mSurfaceTraceEnabled) { - mRoot.mRemoteEventTrace.openSurfaceTransaction(); - } SurfaceControl.openTransaction(); } } finally { @@ -843,9 +840,6 @@ public class WindowManagerService extends IWindowManager.Stub try { traceStateLocked(where); } finally { - if (mRoot.mSurfaceTraceEnabled) { - mRoot.mRemoteEventTrace.closeSurfaceTransaction(); - } SurfaceControl.closeTransaction(); } } @@ -1589,30 +1583,6 @@ public class WindowManagerService extends IWindowManager.Stub return false; } - @Override - public void enableSurfaceTrace(ParcelFileDescriptor pfd) { - final int callingUid = Binder.getCallingUid(); - if (callingUid != SHELL_UID && callingUid != ROOT_UID) { - throw new SecurityException("Only shell can call enableSurfaceTrace"); - } - - synchronized (mWindowMap) { - mRoot.enableSurfaceTrace(pfd); - } - } - - @Override - public void disableSurfaceTrace() { - final int callingUid = Binder.getCallingUid(); - if (callingUid != SHELL_UID && callingUid != ROOT_UID && - callingUid != SYSTEM_UID) { - throw new SecurityException("Only shell can call disableSurfaceTrace"); - } - synchronized (mWindowMap) { - mRoot.disableSurfaceTrace(); - } - } - /** * Set mScreenCaptureDisabled for specific user */ diff --git a/services/core/java/com/android/server/wm/WindowManagerShellCommand.java b/services/core/java/com/android/server/wm/WindowManagerShellCommand.java index e24c3938f5d3..ab139dbb2f12 100644 --- a/services/core/java/com/android/server/wm/WindowManagerShellCommand.java +++ b/services/core/java/com/android/server/wm/WindowManagerShellCommand.java @@ -74,8 +74,6 @@ public class WindowManagerShellCommand extends ShellCommand { return runSetScreenCapture(pw); case "dismiss-keyguard": return runDismissKeyguard(pw); - case "surface-trace": - return runSurfaceTrace(pw); case "tracing": // XXX this should probably be changed to use openFileForSystem() to create // the output trace file, so the shell gets the correct semantics for where @@ -235,46 +233,6 @@ public class WindowManagerShellCommand extends ShellCommand { return 0; } - private int runSurfaceTrace(PrintWriter pw) throws RemoteException { - final ParcelFileDescriptor pfd; - try { - pfd = ParcelFileDescriptor.dup(getOutFileDescriptor()); - } catch (IOException e) { - getErrPrintWriter().println("Unable to dup output stream: " + e.getMessage()); - return -1; - } - mInternal.enableSurfaceTrace(pfd); - - // Read input until an explicit quit command is sent or the stream is closed (meaning - // the user killed the command). - try { - InputStream input = getRawInputStream(); - InputStreamReader converter = new InputStreamReader(input); - BufferedReader in = new BufferedReader(converter); - String line; - - while ((line = in.readLine()) != null) { - if (line.length() <= 0) { - // no-op - } else if ("q".equals(line) || "quit".equals(line)) { - break; - } else { - pw.println("Invalid command: " + line); - } - } - } catch (IOException e) { - e.printStackTrace(pw); - } finally { - mInternal.disableSurfaceTrace(); - try { - pfd.close(); - } catch (IOException e) { - } - } - - return 0; - } - private int parseDimension(String s) throws NumberFormatException { if (s.endsWith("px")) { return Integer.parseInt(s.substring(0, s.length() - 2)); @@ -311,8 +269,6 @@ public class WindowManagerShellCommand extends ShellCommand { pw.println(" Enable or disable screen capture."); pw.println(" dismiss-keyguard"); pw.println(" Dismiss the keyguard, prompting user for auth if necessary."); - pw.println(" surface-trace"); - pw.println(" Log surface commands to stdout in a binary format."); if (!IS_USER) { pw.println(" tracing (start | stop)"); pw.println(" Start or stop window tracing."); diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 0e80819a149f..247cab299e82 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -1456,22 +1456,6 @@ class WindowStateAnimator { DsDy * w.mVScale, false); } - void enableSurfaceTrace(FileDescriptor fd) { - if (mSurfaceController != null) { - mSurfaceController.installRemoteTrace(fd); - } - } - - void disableSurfaceTrace() { - if (mSurfaceController != null) { - try { - mSurfaceController.removeRemoteTrace(); - } catch (ClassCastException e) { - Slog.e(TAG, "Disable surface trace for " + this + " but its not enabled"); - } - } - } - /** The force-scaled state for a given window can persist past * the state for it's stack as the windows complete resizing * independently of one another. diff --git a/services/core/java/com/android/server/wm/WindowSurfaceController.java b/services/core/java/com/android/server/wm/WindowSurfaceController.java index 554a60023aff..1b64d0a1b299 100644 --- a/services/core/java/com/android/server/wm/WindowSurfaceController.java +++ b/services/core/java/com/android/server/wm/WindowSurfaceController.java @@ -110,21 +110,8 @@ class WindowSurfaceController { .setMetadata(windowType, ownerUid); mSurfaceControl = b.build(); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); - - if (mService.mRoot.mSurfaceTraceEnabled) { - installRemoteTrace(mService.mRoot.mSurfaceTraceFd.getFileDescriptor()); - } - } - - void installRemoteTrace(FileDescriptor fd) { - mSurfaceControl = new RemoteSurfaceTrace(fd, mSurfaceControl, mAnimator.mWin); } - void removeRemoteTrace() { - mSurfaceControl = new SurfaceControl(mSurfaceControl); - } - - private void logSurface(String msg, RuntimeException where) { String str = " SURFACE " + msg + ": " + title; if (where != null) { |