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);
      }
    }
  }
 public static void dumpCallEvents(IndentingPrintWriter pw) {
   pw.println("Historical Calls:");
   pw.increaseIndent();
   for (CallEventRecord callEventRecord : mCallEventRecords) {
     callEventRecord.dump(pw);
   }
   pw.decreaseIndent();
 }
  @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);
      }
    }
  }
  public void removeSimulatedPort(String portId, IndentingPrintWriter pw) {
    synchronized (mLock) {
      final int index = mSimulatedPorts.indexOfKey(portId);
      if (index < 0) {
        pw.println("Cannot remove simulated port which does not exist.");
        return;
      }

      pw.println("Disconnecting simulated port: portId=" + portId);
      mSimulatedPorts.removeAt(index);
      updatePortsLocked(pw);
    }
  }
  public void connectSimulatedPort(
      String portId,
      int mode,
      boolean canChangeMode,
      int powerRole,
      boolean canChangePowerRole,
      int dataRole,
      boolean canChangeDataRole,
      IndentingPrintWriter pw) {
    synchronized (mLock) {
      final SimulatedPortInfo portInfo = mSimulatedPorts.get(portId);
      if (portInfo == null) {
        pw.println("Cannot connect simulated port which does not exist.");
        return;
      }

      if (mode == 0 || powerRole == 0 || dataRole == 0) {
        pw.println("Cannot connect simulated port in null mode, " + "power role, or data role.");
        return;
      }

      if ((portInfo.mSupportedModes & mode) == 0) {
        pw.println("Simulated port does not support mode: " + UsbPort.modeToString(mode));
        return;
      }

      pw.println(
          "Connecting simulated port: portId="
              + portId
              + ", mode="
              + UsbPort.modeToString(mode)
              + ", canChangeMode="
              + canChangeMode
              + ", powerRole="
              + UsbPort.powerRoleToString(powerRole)
              + ", canChangePowerRole="
              + canChangePowerRole
              + ", dataRole="
              + UsbPort.dataRoleToString(dataRole)
              + ", canChangeDataRole="
              + canChangeDataRole);
      portInfo.mCurrentMode = mode;
      portInfo.mCanChangeMode = canChangeMode;
      portInfo.mCurrentPowerRole = powerRole;
      portInfo.mCanChangePowerRole = canChangePowerRole;
      portInfo.mCurrentDataRole = dataRole;
      portInfo.mCanChangeDataRole = canChangeDataRole;
      updatePortsLocked(pw);
    }
  }
Esempio n. 6
0
  @Override
  public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);

    // Dump the state of all the app widget providers
    synchronized (mAppWidgetServices) {
      IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "  ");
      for (int i = 0; i < mAppWidgetServices.size(); i++) {
        pw.println("User: " + mAppWidgetServices.keyAt(i));
        ipw.increaseIndent();
        AppWidgetServiceImpl service = mAppWidgetServices.valueAt(i);
        service.dump(fd, ipw, args);
        ipw.decreaseIndent();
      }
    }
  }
  public void addSimulatedPort(String portId, int supportedModes, IndentingPrintWriter pw) {
    synchronized (mLock) {
      if (mSimulatedPorts.containsKey(portId)) {
        pw.println("Port with same name already exists.  Please remove it first.");
        return;
      }

      pw.println(
          "Adding simulated port: portId="
              + portId
              + ", supportedModes="
              + UsbPort.modeToString(supportedModes));
      mSimulatedPorts.put(portId, new SimulatedPortInfo(portId, supportedModes));
      updatePortsLocked(pw);
    }
  }
  public void dump(IndentingPrintWriter pw) {
    synchronized (mLock) {
      pw.print("USB Port State:");
      if (!mSimulatedPorts.isEmpty()) {
        pw.print(" (simulation active; end with 'dumpsys usb reset')");
      }
      pw.println();

      if (mPorts.isEmpty()) {
        pw.println("  <no ports>");
      } else {
        for (PortInfo portInfo : mPorts.values()) {
          pw.println("  " + portInfo.mUsbPort.getId() + ": " + portInfo);
        }
      }
    }
  }
 public void resetSimulation(IndentingPrintWriter pw) {
   synchronized (mLock) {
     pw.println("Removing all simulated ports and ending simulation.");
     if (!mSimulatedPorts.isEmpty()) {
       mSimulatedPorts.clear();
       updatePortsLocked(pw);
     }
   }
 }
  public void disconnectSimulatedPort(String portId, IndentingPrintWriter pw) {
    synchronized (mLock) {
      final SimulatedPortInfo portInfo = mSimulatedPorts.get(portId);
      if (portInfo == null) {
        pw.println("Cannot disconnect simulated port which does not exist.");
        return;
      }

      pw.println("Disconnecting simulated port: portId=" + portId);
      portInfo.mCurrentMode = 0;
      portInfo.mCanChangeMode = false;
      portInfo.mCurrentPowerRole = 0;
      portInfo.mCanChangePowerRole = false;
      portInfo.mCurrentDataRole = 0;
      portInfo.mCanChangeDataRole = false;
      updatePortsLocked(pw);
    }
  }
 public void dump(IndentingPrintWriter pw) {
   pw.println("USB Device State:");
   pw.println("  mCurrentFunctions: " + mCurrentFunctions);
   pw.println("  mCurrentFunctionsApplied: " + mCurrentFunctionsApplied);
   pw.println("  mConnected: " + mConnected);
   pw.println("  mConfigured: " + mConfigured);
   pw.println("  mUsbDataUnlocked: " + mUsbDataUnlocked);
   pw.println("  mCurrentAccessory: " + mCurrentAccessory);
   try {
     pw.println(
         "  Kernel state: " + FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim());
     pw.println(
         "  Kernel function list: "
             + FileUtils.readTextFile(new File(FUNCTIONS_PATH), 0, null).trim());
   } catch (IOException e) {
     pw.println("IOException: " + e);
   }
 }
  /** Called by the Binder stub. */
  void dump(String[] args, PrintWriter pw) {
    synchronized (mLock) {
      final long screenOnTime = getScreenOnTimeLocked(checkAndGetTimeLocked());
      IndentingPrintWriter idpw = new IndentingPrintWriter(pw, "  ");
      ArraySet<String> argSet = new ArraySet<>();
      argSet.addAll(Arrays.asList(args));

      final int userCount = mUserState.size();
      for (int i = 0; i < userCount; i++) {
        idpw.printPair("user", mUserState.keyAt(i));
        idpw.println();
        idpw.increaseIndent();
        if (argSet.contains("--checkin")) {
          mUserState.valueAt(i).checkin(idpw, screenOnTime);
        } else {
          mUserState.valueAt(i).dump(idpw, screenOnTime);
          idpw.println();
          if (args.length > 0 && "history".equals(args[0])) {
            mAppIdleHistory.dump(idpw, mUserState.keyAt(i));
          }
        }
        idpw.decreaseIndent();
      }
      pw.write("Screen On Timebase:" + mScreenOnTime + "\n");
    }
  }
  public void setPortRoles(
      String portId, int newPowerRole, int newDataRole, IndentingPrintWriter pw) {
    synchronized (mLock) {
      final PortInfo portInfo = mPorts.get(portId);
      if (portInfo == null) {
        if (pw != null) {
          pw.println("No such USB port: " + portId);
        }
        return;
      }

      // Check whether the new role is actually supported.
      if (!portInfo.mUsbPortStatus.isRoleCombinationSupported(newPowerRole, newDataRole)) {
        logAndPrint(
            Log.ERROR,
            pw,
            "Attempted to set USB port into unsupported "
                + "role combination: portId="
                + portId
                + ", newPowerRole="
                + UsbPort.powerRoleToString(newPowerRole)
                + ", newDataRole="
                + UsbPort.dataRoleToString(newDataRole));
        return;
      }

      // Check whether anything actually changed.
      final int currentDataRole = portInfo.mUsbPortStatus.getCurrentDataRole();
      final int currentPowerRole = portInfo.mUsbPortStatus.getCurrentPowerRole();
      if (currentDataRole == newDataRole && currentPowerRole == newPowerRole) {
        if (pw != null) {
          pw.println("No change.");
        }
        return;
      }

      // Determine whether we need to change the mode in order to accomplish this goal.
      // We prefer not to do this since it's more likely to fail.
      //
      // Note: Arguably it might be worth allowing the client to influence this policy
      // decision so that we could show more powerful developer facing UI but let's
      // see how far we can get without having to do that.
      final boolean canChangeMode = portInfo.mCanChangeMode;
      final boolean canChangePowerRole = portInfo.mCanChangePowerRole;
      final boolean canChangeDataRole = portInfo.mCanChangeDataRole;
      final int currentMode = portInfo.mUsbPortStatus.getCurrentMode();
      final int newMode;
      if ((!canChangePowerRole && currentPowerRole != newPowerRole)
          || (!canChangeDataRole && currentDataRole != newDataRole)) {
        if (canChangeMode
            && newPowerRole == UsbPort.POWER_ROLE_SOURCE
            && newDataRole == UsbPort.DATA_ROLE_HOST) {
          newMode = UsbPort.MODE_DFP;
        } else if (canChangeMode
            && newPowerRole == UsbPort.POWER_ROLE_SINK
            && newDataRole == UsbPort.DATA_ROLE_DEVICE) {
          newMode = UsbPort.MODE_UFP;
        } else {
          logAndPrint(
              Log.ERROR,
              pw,
              "Found mismatch in supported USB role combinations "
                  + "while attempting to change role: "
                  + portInfo
                  + ", newPowerRole="
                  + UsbPort.powerRoleToString(newPowerRole)
                  + ", newDataRole="
                  + UsbPort.dataRoleToString(newDataRole));
          return;
        }
      } else {
        newMode = currentMode;
      }

      // Make it happen.
      logAndPrint(
          Log.INFO,
          pw,
          "Setting USB port mode and role: portId="
              + portId
              + ", currentMode="
              + UsbPort.modeToString(currentMode)
              + ", currentPowerRole="
              + UsbPort.powerRoleToString(currentPowerRole)
              + ", currentDataRole="
              + UsbPort.dataRoleToString(currentDataRole)
              + ", newMode="
              + UsbPort.modeToString(newMode)
              + ", newPowerRole="
              + UsbPort.powerRoleToString(newPowerRole)
              + ", newDataRole="
              + UsbPort.dataRoleToString(newDataRole));

      SimulatedPortInfo sim = mSimulatedPorts.get(portId);
      if (sim != null) {
        // Change simulated state.
        sim.mCurrentMode = newMode;
        sim.mCurrentPowerRole = newPowerRole;
        sim.mCurrentDataRole = newDataRole;
      } else if (mHaveKernelSupport) {
        // Change actual state.
        final File portDir = new File(SYSFS_CLASS, portId);
        if (!portDir.exists()) {
          logAndPrint(Log.ERROR, pw, "USB port not found: portId=" + portId);
          return;
        }

        if (currentMode != newMode) {
          // Changing the mode will have the side-effect of also changing
          // the power and data roles but it might take some time to apply
          // and the renegotiation might fail.  Due to limitations of the USB
          // hardware, we have no way of knowing whether it will work apriori
          // which is why we would prefer to set the power and data roles
          // directly instead.
          if (!writeFile(
              portDir,
              SYSFS_PORT_MODE,
              newMode == UsbPort.MODE_DFP ? PORT_MODE_DFP : PORT_MODE_UFP)) {
            logAndPrint(
                Log.ERROR,
                pw,
                "Failed to set the USB port mode: "
                    + "portId="
                    + portId
                    + ", newMode="
                    + UsbPort.modeToString(newMode));
            return;
          }
        } else {
          // Change power and data role independently as needed.
          if (currentPowerRole != newPowerRole) {
            if (!writeFile(
                portDir,
                SYSFS_PORT_POWER_ROLE,
                newPowerRole == UsbPort.POWER_ROLE_SOURCE
                    ? PORT_POWER_ROLE_SOURCE
                    : PORT_POWER_ROLE_SINK)) {
              logAndPrint(
                  Log.ERROR,
                  pw,
                  "Failed to set the USB port power role: "
                      + "portId="
                      + portId
                      + ", newPowerRole="
                      + UsbPort.powerRoleToString(newPowerRole));
              return;
            }
          }
          if (currentDataRole != newDataRole) {
            if (!writeFile(
                portDir,
                SYSFS_PORT_DATA_ROLE,
                newDataRole == UsbPort.DATA_ROLE_HOST
                    ? PORT_DATA_ROLE_HOST
                    : PORT_DATA_ROLE_DEVICE)) {
              logAndPrint(
                  Log.ERROR,
                  pw,
                  "Failed to set the USB port data role: "
                      + "portId="
                      + portId
                      + ", newDataRole="
                      + UsbPort.dataRoleToString(newDataRole));
              return;
            }
          }
        }
      }
      updatePortsLocked(pw);
    }
  }
 private static void logAndPrint(int priority, IndentingPrintWriter pw, String msg) {
   Slog.println(priority, TAG, msg);
   if (pw != null) {
     pw.println(msg);
   }
 }
    public void dump(IndentingPrintWriter pw) {
      Map<String, CallEvent> pendingResponses = new HashMap<>();

      pw.print("Call ");
      pw.print(mId);
      pw.print(" [");
      pw.print(sDateFormat.format(new Date(mCall.getCreationTimeMillis())));
      pw.print("]");
      pw.println(mCall.isIncoming() ? "(MT - incoming)" : "(MO - outgoing)");

      pw.increaseIndent();
      pw.println("To address: " + piiHandle(mCall.getHandle()));

      for (CallEvent event : mEvents) {

        // We print out events in chronological order. During that process we look at each
        // event and see if it maps to a request on the Request-Response pairs map. If it
        // does, then we effectively start 'listening' for the response. We do that by
        // storing the response event ID in {@code pendingResponses}. When we find the
        // response in a later iteration of the loop, we grab the original request and
        // calculate the time it took to get a response.
        if (Events.requestResponsePairs.containsKey(event.eventId)) {
          // This event expects a response, so add that response to the maps
          // of pending events.
          String pendingResponse = Events.requestResponsePairs.get(event.eventId);
          pendingResponses.put(pendingResponse, event);
        }

        pw.print(sDateFormat.format(new Date(event.time)));
        pw.print(" - ");
        pw.print(event.eventId);
        if (event.data != null) {
          pw.print(" (");
          Object data = event.data;

          if (data instanceof Call) {
            // If the data is another call, then change the data to the call's CallEvent
            // ID instead.
            CallEventRecord record = mCallEventRecordMap.get(data);
            if (record != null) {
              data = "Call " + record.mId;
            }
          }

          pw.print(data);
          pw.print(")");
        }

        // If this event is a response event that we've been waiting for, calculate the time
        // it took for the response to complete and print that out as well.
        CallEvent requestEvent = pendingResponses.remove(event.eventId);
        if (requestEvent != null) {
          pw.print(", time since ");
          pw.print(requestEvent.eventId);
          pw.print(": ");
          pw.print(event.time - requestEvent.time);
          pw.print(" ms");
        }
        pw.println();
      }
      pw.decreaseIndent();
    }
 @Override
 public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
   final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ", 160);
   synchronized (mRootsLock) {
     for (int i = 0; i < mRoots.size(); i++) {
       final RootInfo root = mRoots.valueAt(i);
       pw.println("Root{" + root.rootId + "}:");
       pw.increaseIndent();
       pw.printPair("flags", DebugUtils.flagsToString(Root.class, "FLAG_", root.flags));
       pw.println();
       pw.printPair("title", root.title);
       pw.printPair("docId", root.docId);
       pw.println();
       pw.printPair("path", root.path);
       pw.printPair("visiblePath", root.visiblePath);
       pw.decreaseIndent();
       pw.println();
     }
   }
 }
  public static void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    pw.println("PhoneFactory:");
    PhoneProxy[] phones = (PhoneProxy[]) PhoneFactory.getPhones();
    int i = -1;
    for (PhoneProxy phoneProxy : phones) {
      PhoneBase phoneBase;
      i += 1;

      try {
        phoneBase = (PhoneBase) phoneProxy.getActivePhone();
        phoneBase.dump(fd, pw, args);
      } catch (Exception e) {
        pw.println("Telephony DebugService: Could not get Phone[" + i + "] e=" + e);
        continue;
      }

      pw.flush();
      pw.println("++++++++++++++++++++++++++++++++");

      try {
        ((IccCardProxy) phoneProxy.getIccCard()).dump(fd, pw, args);
      } catch (Exception e) {
        e.printStackTrace();
      }
      pw.flush();
      pw.println("++++++++++++++++++++++++++++++++");
    }

    try {
      DctController.getInstance().dump(fd, pw, args);
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      mUiccController.dump(fd, pw, args);
    } catch (Exception e) {
      e.printStackTrace();
    }
    pw.flush();
    pw.println("++++++++++++++++++++++++++++++++");

    try {
      SubscriptionController.getInstance().dump(fd, pw, args);
    } catch (Exception e) {
      e.printStackTrace();
    }
    pw.flush();
    pw.println("++++++++++++++++++++++++++++++++");

    try {
      sSubInfoRecordUpdater.dump(fd, pw, args);
    } catch (Exception e) {
      e.printStackTrace();
    }
    pw.flush();

    pw.println("++++++++++++++++++++++++++++++++");
    synchronized (sLocalLogs) {
      final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "  ");
      for (String key : sLocalLogs.keySet()) {
        ipw.println(key);
        ipw.increaseIndent();
        sLocalLogs.get(key).dump(fd, ipw, args);
        ipw.decreaseIndent();
      }
      ipw.flush();
    }
  }
 @Override
 protected void dump(final IndentingPrintWriter pw) {
   super.dump(pw);
   pw.println("mIsActiveSource: " + mIsActiveSource);
 }