当前位置: 首页> 财经> 访谈 > Android主副屏显示-Android13

Android主副屏显示-Android13

时间:2025/7/11 0:10:42来源:https://blog.csdn.net/qq_23452385/article/details/142034616 浏览次数:0次

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():屏幕Density
  • mInfo.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

主屏:1080x2160

mDisplayId=0; orientation=0; physWidth=1080; physHeight=2160; rotated=false [ displayDeviceInfo.rotation=0; displayDeviceInfo.width=1080; displayDeviceInfo.height=2160; displayInfo.rotation=0; displayInfo.logicalWidth=1080; displayInfo.logicalHeight=2160 ]
mDisplayId=0; mTempDisplayRect=Rect(0, 0 - 1080, 2160); mTempLayerStackRect=Rect(0, 0 - 1080, 2160); orientation=0mDisplayId=0; orientation=1; physWidth=2160; physHeight=1080; rotated=true [ displayDeviceInfo.rotation=0; displayDeviceInfo.width=1080; displayDeviceInfo.height=2160; displayInfo.rotation=1; displayInfo.logicalWidth=2160; displayInfo.logicalHeight=1080 ]
mDisplayId=0; mTempDisplayRect=Rect(0, 0 - 2160, 1080); mTempLayerStackRect=Rect(0, 0 - 2160, 1080); orientation=1

副屏:1920x1080 (修改处理?

mDisplayId=2; orientation=0; physWidth=1920; physHeight=1080 [ displayDeviceInfo.rotation=0; displayDeviceInfo.width=1920; displayDeviceInfo.height=1080; displayInfo.rotation=0; displayInfo.logicalWidth=1920; displayInfo.logicalHeight=1080 ] 
mDisplayId=2; mTempDisplayRect=Rect(0, 0 - 1920, 1080); mTempLayerStackRect=Rect(0, 0 - 1920, 1080); orientation=0mDisplayId=2; orientation=3; physWidth=1080; physHeight=1920; rotated=true [ displayDeviceInfo.rotation=3; displayDeviceInfo.width=1920; displayDeviceInfo.height=1080; displayInfo.rotation=0; displayInfo.logicalWidth=1920; displayInfo.logicalHeight=1080 ]
mDisplayId=2; mTempDisplayRect=Rect(0, 0 - 1080, 1920); mTempLayerStackRect=Rect(0, 0 - 1080, 1920); orientation=3
关键字:Android主副屏显示-Android13

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: