private void dumpInternal(PrintWriter pw) {
    pw.println("DISPLAY MANAGER (dumpsys display)");

    synchronized (mSyncRoot) {
      pw.println("  mOnlyCode=" + mOnlyCore);
      pw.println("  mSafeMode=" + mSafeMode);
      pw.println("  mPendingTraversal=" + mPendingTraversal);
      pw.println("  mGlobalDisplayState=" + Display.stateToString(mGlobalDisplayState));
      pw.println("  mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId);
      pw.println("  mDefaultViewport=" + mDefaultViewport);
      pw.println("  mExternalTouchViewport=" + mExternalTouchViewport);
      pw.println("  mSingleDisplayDemoMode=" + mSingleDisplayDemoMode);
      pw.println("  mWifiDisplayScanRequestCount=" + mWifiDisplayScanRequestCount);

      IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "    ");
      ipw.increaseIndent();

      pw.println();
      pw.println("Display Adapters: size=" + mDisplayAdapters.size());
      for (DisplayAdapter adapter : mDisplayAdapters) {
        pw.println("  " + adapter.getName());
        adapter.dumpLocked(ipw);
      }

      pw.println();
      pw.println("Display Devices: size=" + mDisplayDevices.size());
      for (DisplayDevice device : mDisplayDevices) {
        pw.println("  " + device.getDisplayDeviceInfoLocked());
        device.dumpLocked(ipw);
      }

      final int logicalDisplayCount = mLogicalDisplays.size();
      pw.println();
      pw.println("Logical Displays: size=" + logicalDisplayCount);
      for (int i = 0; i < logicalDisplayCount; i++) {
        int displayId = mLogicalDisplays.keyAt(i);
        LogicalDisplay display = mLogicalDisplays.valueAt(i);
        pw.println("  Display " + displayId + ":");
        display.dumpLocked(ipw);
      }

      final int callbackCount = mCallbacks.size();
      pw.println();
      pw.println("Callbacks: size=" + callbackCount);
      for (int i = 0; i < callbackCount; i++) {
        CallbackRecord callback = mCallbacks.valueAt(i);
        pw.println(
            "  "
                + i
                + ": mPid="
                + callback.mPid
                + ", mWifiDisplayScanRequested="
                + callback.mWifiDisplayScanRequested);
      }

      if (mDisplayPowerController != null) {
        mDisplayPowerController.dump(pw);
      }
    }
  }
  @Override // Binder call
  public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
    if (mContext == null
        || mContext.checkCallingOrSelfPermission(Manifest.permission.DUMP)
            != PackageManager.PERMISSION_GRANTED) {
      pw.println(
          "Permission Denial: can't dump DisplayManager from from pid="
              + Binder.getCallingPid()
              + ", uid="
              + Binder.getCallingUid());
      return;
    }

    pw.println("DISPLAY MANAGER (dumpsys display)");

    synchronized (mSyncRoot) {
      pw.println("  mHeadless=" + mHeadless);
      pw.println("  mOnlyCode=" + mOnlyCore);
      pw.println("  mSafeMode=" + mSafeMode);
      pw.println("  mPendingTraversal=" + mPendingTraversal);
      pw.println(
          "  mAllDisplayBlankStateFromPowerManager=" + mAllDisplayBlankStateFromPowerManager);
      pw.println("  mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId);
      pw.println("  mDefaultViewport=" + mDefaultViewport);
      pw.println("  mExternalTouchViewport=" + mExternalTouchViewport);
      pw.println("  mSingleDisplayDemoMode=" + mSingleDisplayDemoMode);

      IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "    ");
      ipw.increaseIndent();

      pw.println();
      pw.println("Display Adapters: size=" + mDisplayAdapters.size());
      for (DisplayAdapter adapter : mDisplayAdapters) {
        pw.println("  " + adapter.getName());
        adapter.dumpLocked(ipw);
      }

      pw.println();
      pw.println("Display Devices: size=" + mDisplayDevices.size());
      for (DisplayDevice device : mDisplayDevices) {
        pw.println("  " + device.getDisplayDeviceInfoLocked());
        device.dumpLocked(ipw);
      }

      final int logicalDisplayCount = mLogicalDisplays.size();
      pw.println();
      pw.println("Logical Displays: size=" + logicalDisplayCount);
      for (int i = 0; i < logicalDisplayCount; i++) {
        int displayId = mLogicalDisplays.keyAt(i);
        LogicalDisplay display = mLogicalDisplays.valueAt(i);
        pw.println("  Display " + displayId + ":");
        display.dumpLocked(ipw);
      }
    }
  }