private void performTraversalInTransactionLocked() {
    // Perform one last traversal for each removed display device.
    final int removedCount = mRemovedDisplayDevices.size();
    for (int i = 0; i < removedCount; i++) {
      DisplayDevice device = mRemovedDisplayDevices.get(i);
      device.performTraversalInTransactionLocked();
    }
    mRemovedDisplayDevices.clear();

    // Clear all viewports before configuring displays so that we can keep
    // track of which ones we have configured.
    clearViewportsLocked();

    // Configure each display device.
    final int count = mDisplayDevices.size();
    for (int i = 0; i < count; i++) {
      DisplayDevice device = mDisplayDevices.get(i);
      configureDisplayInTransactionLocked(device);
      device.performTraversalInTransactionLocked();
    }

    // Tell the input system about these new viewports.
    if (mInputManagerFuncs != null) {
      mHandler.sendEmptyMessage(MSG_UPDATE_VIEWPORT);
    }
  }