Android主副屏显示-Android13
- 1、DisplayDeviceInfo屏幕信息
- 2、LogicalDisplay.java
- 2.1 configureDisplayLocked刷新
DisplayManagerService启动及主屏添加-Android13
1、DisplayDeviceInfo屏幕信息
DisplayManagerService启动及主屏添加-Android13 中监听获取,在
LocalDisplayAdapter.java#tryConnectDisplayLocked
获取DisplayDevice
信息,在DisplayDeviceRepository.java#handleDisplayDeviceAdded
获取DisplayDeviceInfo
( 即 DisplayDevice.getDisplayDeviceInfoLocked())
命令查看屏幕信息:
$ dumpsys SurfaceFlinger --display-id # Example output. Display 21691504607621632 (HWC display 0): port=0 pnpId=SHP displayName="LQ123P1JX32" Display 9834494747159041 (HWC display 2): port=1 pnpId=HWP displayName="HP Z24i" Display 1886279400700944 (HWC display 1): port=2 pnpId=AUS displayName="ASUS MB16AP"
mInfo.width = mActiveSfDisplayMode.width
:屏幕宽mInfo.height = mActiveSfDisplayMode.height
:屏幕高mInfo.densityDpi = getLogicalDensity()
:屏幕DensitymInfo.xDpi = mActiveSfDisplayMode.xDpi
:显示器在X方向上的DPI物理密度mInfo.yDpi = mActiveSfDisplayMode.yDpi
:显示器在Y方向上的DPI物理密度。mInfo.installOrientation = mStaticDisplayInfo.installOrientation
:显示面板的安装方向相对于其自然方向。mInfo.type = Display.TYPE_INTERNAL 或 Display.TYPE_EXTERNAL
:内置屏幕<string name="display_manager_built_in_display_name">Built-in Screen</string>
、HDMI 屏幕<string name="display_manager_hdmi_display_name">HDMI Screen</string>
public int rotation = Surface.ROTATION_0
:显示旋转方向
public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
if (mInfo == null) {
mInfo = new DisplayDeviceInfo();
mInfo.width = mActiveSfDisplayMode.width;
mInfo.height = mActiveSfDisplayMode.height;
mInfo.modeId = mActiveModeId;
mInfo.defaultModeId = getPreferredModeId();
mInfo.supportedModes = getDisplayModes(mSupportedModes);
mInfo.colorMode = mActiveColorMode;
mInfo.allmSupported = mAllmSupported;
mInfo.gameContentTypeSupported = mGameContentTypeSupported;
mInfo.supportedColorModes =
new int[mSupportedColorModes.size()];
for (int i = 0; i < mSupportedColorModes.size(); i++) {
mInfo.supportedColorModes[i] = mSupportedColorModes.get(i);
}
mInfo.hdrCapabilities = mHdrCapabilities;
mInfo.appVsyncOffsetNanos = mActiveSfDisplayMode.appVsyncOffsetNanos;
mInfo.presentationDeadlineNanos = mActiveSfDisplayMode.presentationDeadlineNanos;
mInfo.state = mState;
mInfo.uniqueId = getUniqueId();
final DisplayAddress.Physical physicalAddress =
DisplayAddress.fromPhysicalDisplayId(mPhysicalDisplayId);
mInfo.address = physicalAddress;
mInfo.densityDpi = getLogicalDensity();
mInfo.xDpi = mActiveSfDisplayMode.xDpi;
mInfo.yDpi = mActiveSfDisplayMode.yDpi;
mInfo.deviceProductInfo = mStaticDisplayInfo.deviceProductInfo;
// Assume that all built-in displays that have secure output (eg. HDCP) also
// support compositing from gralloc protected buffers.
if (mStaticDisplayInfo.secure) {
mInfo.flags = DisplayDeviceInfo.FLAG_SECURE
| DisplayDeviceInfo.FLAG_SUPPORTS_PROTECTED_BUFFERS;
}
final Resources res = getOverlayContext().getResources();
mInfo.flags |= DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY;
if (mIsFirstDisplay) {
if (res.getBoolean(com.android.internal.R.bool.config_mainBuiltInDisplayIsRound)
|| (Build.IS_EMULATOR
&& SystemProperties.getBoolean(PROPERTY_EMULATOR_CIRCULAR, false))) {
mInfo.flags |= DisplayDeviceInfo.FLAG_ROUND;
}
} else {
if (!res.getBoolean(
com.android.internal.R.bool.config_localDisplaysMirrorContent)) {
mInfo.flags |= DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY;
}
if (isDisplayPrivate(physicalAddress)) {
mInfo.flags |= DisplayDeviceInfo.FLAG_PRIVATE;
}
}
if (DisplayCutout.getMaskBuiltInDisplayCutout(res, mInfo.uniqueId)) {
mInfo.flags |= DisplayDeviceInfo.FLAG_MASK_DISPLAY_CUTOUT;
}
final Display.Mode maxDisplayMode =
DisplayUtils.getMaximumResolutionDisplayMode(mInfo.supportedModes);
final int maxWidth =
maxDisplayMode == null ? mInfo.width : maxDisplayMode.getPhysicalWidth();
final int maxHeight =
maxDisplayMode == null ? mInfo.height : maxDisplayMode.getPhysicalHeight();
mInfo.displayCutout = DisplayCutout.fromResourcesRectApproximation(res,
mInfo.uniqueId, maxWidth, maxHeight, mInfo.width, mInfo.height);
mInfo.roundedCorners = RoundedCorners.fromResources(
res, mInfo.uniqueId, maxWidth, maxHeight, mInfo.width, mInfo.height);
mInfo.installOrientation = mStaticDisplayInfo.installOrientation;
if (mStaticDisplayInfo.isInternal) {
mInfo.type = Display.TYPE_INTERNAL;
mInfo.touch = DisplayDeviceInfo.TOUCH_INTERNAL;
mInfo.flags |= DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT;
mInfo.name = res.getString(
com.android.internal.R.string.display_manager_built_in_display_name);
} else {
mInfo.type = Display.TYPE_EXTERNAL;
mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL;
mInfo.flags |= DisplayDeviceInfo.FLAG_PRESENTATION;
mInfo.name = getContext().getResources().getString(
com.android.internal.R.string.display_manager_hdmi_display_name);
}
mInfo.frameRateOverrides = mFrameRateOverrides;
// The display is trusted since it is created by system.
mInfo.flags |= DisplayDeviceInfo.FLAG_TRUSTED;
mInfo.brightnessMinimum = PowerManager.BRIGHTNESS_MIN;
mInfo.brightnessMaximum = PowerManager.BRIGHTNESS_MAX;
mInfo.brightnessDefault = getDisplayDeviceConfig().getBrightnessDefault();
}
return mInfo;
}
2、LogicalDisplay.java
frameworks/base/services/core/java/com/android/server/wm/RootWindowContainer.java
frameworks/base/services/core/java/com/android/server/wm/DisplayContent.java
frameworks/base/services/core/java/com/android/server/display/LogicalDisplay.java
RootWindowContainer.java#onDisplayAdded
DisplayContent.java#updateDisplayAndOrientation
DisplayManagerService.java#setDisplayInfoOverrideFromWindowManager
LogicalDisplay.java#setDisplayInfoOverrideFromWindowManagerLocked
2.1 configureDisplayLocked刷新
RootWindowContainer.java#applySurfaceChangesTransaction
DisplayManagerService.java#performTraversalLocked
DisplayManagerService.java#configureDisplayLocked
LogicalDisplay.java#configureDisplayLocked