/Mate20_10_1_0/src/main/java/com/android/server/display/DisplayDevice.java

https://github.com/SivanLiu/HwFrameWorkSource · Java · 195 lines · 167 code · 27 blank · 1 comment · 37 complexity · cd78f3b346a4e556db881bc5f56a341c MD5 · raw file

  1. package com.android.server.display;
  2. import android.graphics.Rect;
  3. import android.hardware.display.DisplayViewport;
  4. import android.hardware.display.HwFoldScreenState;
  5. import android.hardware.display.IHwFoldable;
  6. import android.os.IBinder;
  7. import android.os.SystemProperties;
  8. import android.util.HwPCUtils;
  9. import android.util.Slog;
  10. import android.view.DisplayAddress;
  11. import android.view.Surface;
  12. import android.view.SurfaceControl;
  13. import java.io.PrintWriter;
  14. /* access modifiers changed from: package-private */
  15. public abstract class DisplayDevice implements IHwFoldable {
  16. private static final String TAG = "DisplayDevice";
  17. private static boolean mIsRotateScreen = (!SystemProperties.get("ro.config.hw_fold_disp").isEmpty());
  18. private Rect mCurrentDisplayRect;
  19. private int mCurrentLayerStack;
  20. private Rect mCurrentLayerStackRect;
  21. private int mCurrentOrientation;
  22. private Surface mCurrentSurface;
  23. DisplayDeviceInfo mDebugLastLoggedDeviceInfo;
  24. private final DisplayAdapter mDisplayAdapter;
  25. private final IBinder mDisplayToken;
  26. protected HwFoldScreenState mHwFoldScreenState;
  27. private final String mUniqueId;
  28. public abstract DisplayDeviceInfo getDisplayDeviceInfoLocked();
  29. public abstract boolean hasStableUniqueId();
  30. public DisplayDevice(DisplayAdapter displayAdapter, IBinder displayToken, String uniqueId) {
  31. this.mCurrentLayerStack = -1;
  32. this.mCurrentOrientation = -1;
  33. this.mDisplayAdapter = displayAdapter;
  34. this.mDisplayToken = displayToken;
  35. this.mUniqueId = uniqueId;
  36. }
  37. public DisplayDevice(DisplayAdapter displayAdapter, IBinder displayToken, String uniqueId, HwFoldScreenState foldScreenState) {
  38. this(displayAdapter, displayToken, uniqueId);
  39. this.mHwFoldScreenState = foldScreenState;
  40. }
  41. public final DisplayAdapter getAdapterLocked() {
  42. return this.mDisplayAdapter;
  43. }
  44. public final IBinder getDisplayTokenLocked() {
  45. return this.mDisplayToken;
  46. }
  47. public final String getNameLocked() {
  48. return getDisplayDeviceInfoLocked().name;
  49. }
  50. public final String getUniqueId() {
  51. return this.mUniqueId;
  52. }
  53. public void updateDesityforRog() {
  54. }
  55. public void applyPendingDisplayDeviceInfoChangesLocked() {
  56. }
  57. public void performTraversalLocked(SurfaceControl.Transaction t) {
  58. }
  59. public Runnable requestDisplayStateLocked(int state, int brightness) {
  60. return null;
  61. }
  62. public void setAllowedDisplayModesLocked(int[] modes) {
  63. }
  64. public void setRequestedColorModeLocked(int colorMode) {
  65. }
  66. public void onOverlayChangedLocked() {
  67. }
  68. public final void setLayerStackLocked(SurfaceControl.Transaction t, int layerStack) {
  69. if (HwPCUtils.enabledInPad() && HwPCUtils.isPcCastModeInServer()) {
  70. int layerStackPC = HwPCUtils.getPCDisplayID();
  71. if (this.mCurrentLayerStack != layerStackPC) {
  72. this.mCurrentLayerStack = layerStackPC;
  73. t.setDisplayLayerStack(this.mDisplayToken, layerStackPC);
  74. }
  75. } else if (this.mCurrentLayerStack != layerStack) {
  76. this.mCurrentLayerStack = layerStack;
  77. t.setDisplayLayerStack(this.mDisplayToken, layerStack);
  78. }
  79. }
  80. public final void setProjectionLocked(SurfaceControl.Transaction t, int orientationOld, Rect layerStackRect, Rect displayRect) {
  81. Rect rect;
  82. Rect rect2;
  83. boolean ifDefault = this.mUniqueId.equals("local:0");
  84. int orientation = orientationOld;
  85. HwPCUtils.log(TAG, "setProjectionLocked getContext " + this.mDisplayAdapter.getContext() + " getName " + this.mDisplayAdapter.getName() + " getHandler " + this.mDisplayAdapter.getHandler() + " getSyncRoot " + this.mDisplayAdapter.getSyncRoot());
  86. if (ifDefault) {
  87. HwPCUtils.log(TAG, "setProjectionLocked ifDefault is true mIsRotateScreen " + mIsRotateScreen);
  88. if (mIsRotateScreen) {
  89. orientation = (orientation + 3) % 4;
  90. }
  91. }
  92. Slog.i(TAG, "setProjectionLocked orientation(" + this.mCurrentOrientation + "->" + orientation + ") LayerStackRect(" + this.mCurrentLayerStackRect + "->" + layerStackRect + ") DisplayRect(" + this.mCurrentDisplayRect + "->" + displayRect + ")");
  93. if (this.mCurrentOrientation != orientation || (rect = this.mCurrentLayerStackRect) == null || !rect.equals(layerStackRect) || (rect2 = this.mCurrentDisplayRect) == null || !rect2.equals(displayRect) || isFoldable()) {
  94. this.mCurrentOrientation = orientation;
  95. if (this.mCurrentLayerStackRect == null) {
  96. this.mCurrentLayerStackRect = new Rect();
  97. }
  98. this.mCurrentLayerStackRect.set(layerStackRect);
  99. if (this.mCurrentDisplayRect == null) {
  100. this.mCurrentDisplayRect = new Rect();
  101. }
  102. this.mCurrentDisplayRect.set(displayRect);
  103. t.setDisplayProjection(this.mDisplayToken, orientation, layerStackRect, displayRect);
  104. }
  105. }
  106. public final void setSurfaceLocked(SurfaceControl.Transaction t, Surface surface) {
  107. if (this.mCurrentSurface != surface) {
  108. this.mCurrentSurface = surface;
  109. t.setDisplaySurface(this.mDisplayToken, surface);
  110. }
  111. }
  112. public final void populateViewportLocked(DisplayViewport viewport) {
  113. viewport.orientation = this.mCurrentOrientation;
  114. if (this.mCurrentLayerStackRect != null) {
  115. viewport.logicalFrame.set(this.mCurrentLayerStackRect);
  116. } else {
  117. viewport.logicalFrame.setEmpty();
  118. }
  119. if (this.mCurrentDisplayRect != null) {
  120. viewport.physicalFrame.set(this.mCurrentDisplayRect);
  121. } else {
  122. viewport.physicalFrame.setEmpty();
  123. }
  124. if (isFoldable()) {
  125. this.mHwFoldScreenState.adjustViewportFrame(viewport, this.mCurrentLayerStackRect, this.mCurrentDisplayRect);
  126. Slog.d(TAG, "hwc adjustViewportFrame viewport=" + viewport + " mCurrentOrientation=" + this.mCurrentOrientation);
  127. }
  128. int i = this.mCurrentOrientation;
  129. boolean isRotated = true;
  130. if (!(i == 1 || i == 3)) {
  131. isRotated = false;
  132. }
  133. DisplayDeviceInfo info = getDisplayDeviceInfoLocked();
  134. viewport.deviceWidth = isRotated ? info.height : info.width;
  135. viewport.deviceHeight = isRotated ? info.width : info.height;
  136. viewport.uniqueId = info.uniqueId;
  137. if (info.address instanceof DisplayAddress.Physical) {
  138. viewport.physicalPort = Byte.valueOf(info.address.getPort());
  139. } else {
  140. viewport.physicalPort = null;
  141. }
  142. }
  143. public boolean isFoldable() {
  144. return false;
  145. }
  146. public Rect getScreenDispRect(int orientation) {
  147. return null;
  148. }
  149. public int getDisplayState() {
  150. return 0;
  151. }
  152. public int setDisplayState(int state) {
  153. return 0;
  154. }
  155. public int setDisplayState(int displayMode, int flodState) {
  156. return 0;
  157. }
  158. public void dumpLocked(PrintWriter pw) {
  159. pw.println("mAdapter=" + this.mDisplayAdapter.getName());
  160. pw.println("mUniqueId=" + this.mUniqueId);
  161. pw.println("mDisplayToken=" + this.mDisplayToken);
  162. pw.println("mCurrentLayerStack=" + this.mCurrentLayerStack);
  163. pw.println("mCurrentOrientation=" + this.mCurrentOrientation);
  164. pw.println("mCurrentLayerStackRect=" + this.mCurrentLayerStackRect);
  165. pw.println("mCurrentDisplayRect=" + this.mCurrentDisplayRect);
  166. pw.println("mCurrentSurface=" + this.mCurrentSurface);
  167. }
  168. }