private void configureDisplayInTransactionLocked(DisplayDevice device) {
    // Find the logical display that the display device is showing.
    LogicalDisplay display = findLogicalDisplayForDeviceLocked(device);
    if (display != null && !display.hasContentLocked()) {
      display = null;
    }
    if (display == null) {
      display = mLogicalDisplays.get(Display.DEFAULT_DISPLAY);
    }

    // Apply the logical display configuration to the display device.
    if (display == null) {
      // TODO: no logical display for the device, blank it
      Slog.w(
          TAG,
          "Missing logical display to use for physical display device: "
              + device.getDisplayDeviceInfoLocked());
      return;
    } else {
      boolean isBlanked = (mAllDisplayBlankStateFromPowerManager == DISPLAY_BLANK_STATE_BLANKED);
      display.configureDisplayInTransactionLocked(device, isBlanked);
    }

    // Update the viewports if needed.
    DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
    if (!mDefaultViewport.valid && (info.flags & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) {
      setViewportLocked(mDefaultViewport, display, device);
    }
    if (!mExternalTouchViewport.valid && info.touch == DisplayDeviceInfo.TOUCH_EXTERNAL) {
      setViewportLocked(mExternalTouchViewport, display, device);
    }
  }
 /**
  * Tells the display manager whether there is interesting unique content on the specified logical
  * display. This is used to control automatic mirroring.
  *
  * <p>If the display has unique content, then the display manager arranges for it to be presented
  * on a physical display if appropriate. Otherwise, the display manager may choose to make the
  * physical display mirror some other logical display.
  *
  * @param displayId The logical display id to update.
  * @param hasContent True if the logical display has content.
  * @param inTraversal True if called from WindowManagerService during a window traversal prior to
  *     call to performTraversalInTransactionFromWindowManager.
  */
 public void setDisplayHasContent(int displayId, boolean hasContent, boolean inTraversal) {
   synchronized (mSyncRoot) {
     LogicalDisplay display = mLogicalDisplays.get(displayId);
     if (display != null && display.hasContentLocked() != hasContent) {
       display.setHasContentLocked(hasContent);
       scheduleTraversalLocked(inTraversal);
     }
   }
 }
  private void setDisplayHasContentInternal(
      int displayId, boolean hasContent, boolean inTraversal) {
    synchronized (mSyncRoot) {
      LogicalDisplay display = mLogicalDisplays.get(displayId);
      if (display != null && display.hasContentLocked() != hasContent) {
        if (DEBUG) {
          Slog.d(
              TAG,
              "Display "
                  + displayId
                  + " hasContent flag changed: "
                  + "hasContent="
                  + hasContent
                  + ", inTraversal="
                  + inTraversal);
        }

        display.setHasContentLocked(hasContent);
        scheduleTraversalLocked(inTraversal);
      }
    }
  }
  private void configureDisplayInTransactionLocked(DisplayDevice device) {
    final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
    final boolean ownContent = (info.flags & DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY) != 0;

    // Find the logical display that the display device is showing.
    // Certain displays only ever show their own content.
    LogicalDisplay display = findLogicalDisplayForDeviceLocked(device);
    if (!ownContent) {
      if (display != null && !display.hasContentLocked()) {
        // If the display does not have any content of its own, then
        // automatically mirror the default logical display contents.
        display = null;
      }
      if (display == null) {
        display = mLogicalDisplays.get(Display.DEFAULT_DISPLAY);
      }
    }

    // Apply the logical display configuration to the display device.
    if (display == null) {
      // TODO: no logical display for the device, blank it
      Slog.w(
          TAG,
          "Missing logical display to use for physical display device: "
              + device.getDisplayDeviceInfoLocked());
      return;
    }
    display.configureDisplayInTransactionLocked(device, info.state == Display.STATE_OFF);

    // Update the viewports if needed.
    if (!mDefaultViewport.valid && (info.flags & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) {
      setViewportLocked(mDefaultViewport, display, device);
    }
    if (!mExternalTouchViewport.valid && info.touch == DisplayDeviceInfo.TOUCH_EXTERNAL) {
      setViewportLocked(mExternalTouchViewport, display, device);
    }
  }