网站更换服务器 备案,asp.net mvc 统计网站流量数据,门户类网页,企业网站美工设计Android多屏幕支持-Android12 1、概览及相关文章2、屏幕窗口配置2.1 配置xml文件2.2 DisplayInfo#uniqueId 屏幕标识2.3 adb查看信息 3、配置文件解析3.1 xml字段读取3.2 简要时序图 4、每屏幕焦点 android12-release 1、概览及相关文章 
AOSP  文档  心主题  多屏… Android多屏幕支持-Android12 1、概览及相关文章2、屏幕窗口配置2.1 配置xml文件2.2 DisplayInfo#uniqueId 屏幕标识2.3 adb查看信息 3、配置文件解析3.1 xml字段读取3.2 简要时序图 4、每屏幕焦点 android12-release 1、概览及相关文章 
AOSP  文档  心主题  多屏幕概览 术语 在这些文章中主屏幕和辅助屏幕的定义如下 主默认屏幕的屏幕 ID 为 DEFAULT_DISPLAY 辅助屏幕的屏幕 ID 不是 DEFAULT_DISPLAY 主题区域文章开发和测试推荐做法测试和开发环境常见问题解答相关文章集显示系统装饰支持输入法支持单篇文章多项恢复Activity 启动政策锁定屏幕输入路由多区音频 
2、屏幕窗口配置 
2.1 配置xml文件 
/data/system/display_settings.xml 配置 
模拟屏幕uniqueId 用于在名称属性中标识屏幕对于模拟屏幕此 ID 为 overlay:1。 
?xml version1.0 encodingutf-8 standaloneyes ?
display-settings
config identifier0 /
displaynameoverlay:1shouldShowSystemDecorstrueshouldShowImetrue /
/display-settings内置屏幕uniqueId 对于内置屏幕示例值可以是 “local:45354385242535243453”。另一种方式是使用硬件端口信息并设置 identifier“1” 以与 DisplayWindowSettingsProvider#IDENTIFIER_PORT 对应然后更新 name 以使用 port:port_id 格式。 
?xmlversion1.0 encodingutf-8 standaloneyes ?
display-settings
config identifier1 /
displaynameport:12345shouldShowSystemDecorstrueshouldShowImetrue /
/display-settings2.2 DisplayInfo#uniqueId 屏幕标识 
DisplayInfo#uniqueId以添加稳定的标识符并区分本地、网络和虚拟屏幕 
屏幕类型格式本地local:stable-id网络network:mac-address虚拟virtual:package-name-and-name 
2.3 adb查看信息 
$ dumpsys SurfaceFlinger --display-id
# Example output.
Display 21691504607621632 (HWC display 0): port0 pnpIdSHP displayNameLQ123P1JX32
Display 9834494747159041 (HWC display 2): port1 pnpIdHWP displayNameHP Z24i
Display 1886279400700944 (HWC display 1): port2 pnpIdAUS displayNameASUS MB16APframeworks/native/services/surfaceflinger/SurfaceFlinger.cpp#SurfaceFlinger::dumpDisplayIdentificationData 
void SurfaceFlinger::dumpDisplayIdentificationData(std::string result) const {for (const auto [token, display] : mDisplays) {const auto displayId  PhysicalDisplayId::tryCast(display-getId());if (!displayId) {continue;}const auto hwcDisplayId  getHwComposer().fromPhysicalDisplayId(*displayId);if (!hwcDisplayId) {continue;}StringAppendF(result,Display %s (HWC display % PRIu64 ): , to_string(*displayId).c_str(),*hwcDisplayId);uint8_t port;DisplayIdentificationData data;if (!getHwComposer().getDisplayIdentificationData(*hwcDisplayId, port, data)) {result.append(no identification data\n);continue;}if (!isEdid(data)) {result.append(unknown identification data\n);continue;}const auto edid  parseEdid(data);if (!edid) {result.append(invalid EDID\n);continue;}StringAppendF(result, port%u pnpId%s displayName\, port, edid-pnpId.data());result.append(edid-displayName.data(), edid-displayName.length());result.append(\\n);}
}3、配置文件解析 
3.1 xml字段读取 文件路径DATA_DISPLAY_SETTINGS_FILE_PATH  system/display_settings.xml、VENDOR_DISPLAY_SETTINGS_FILE_PATH  etc/display_settings.xml、Settings.Global.getString(resolver,DEVELOPMENT_WM_DISPLAY_SETTINGS_PATH)DEVELOPMENT_WM_DISPLAY_SETTINGS_PATH  wm_display_settings_pathFileData对象fileData.mIdentifierType  getIntAttribute(parser, identifier, IDENTIFIER_UNIQUE_ID)、name  parser.getAttributeValue(null, name)、shouldShowIme  getBooleanAttribute(parser, shouldShowIme, null /* defaultValue */)、settingsEntry.mShouldShowSystemDecors  getBooleanAttribute(parser, shouldShowSystemDecors, null /* defaultValue */)等等 private static final class FileData {int mIdentifierType;final MapString, SettingsEntry mSettings  new HashMap();Overridepublic String toString() {return FileData{ mIdentifierType  mIdentifierType , mSettings  mSettings };}
}DisplayWindowSettings.java有关显示器的当前持久设置。提供显示设置的策略并将设置值的持久性和查找委派给提供的{link SettingsProvider} Nullable
private static FileData readSettings(ReadableSettingsStorage storage) {InputStream stream;try {stream  storage.openRead();} catch (IOException e) {Slog.i(TAG, No existing display settings, starting empty);return null;}FileData fileData  new FileData();boolean success  false;try {TypedXmlPullParser parser  Xml.resolvePullParser(stream);int type;while ((type  parser.next()) ! XmlPullParser.START_TAG type ! XmlPullParser.END_DOCUMENT) {// Do nothing.}if (type ! XmlPullParser.START_TAG) {throw new IllegalStateException(no start tag found);}int outerDepth  parser.getDepth();while ((type  parser.next()) ! XmlPullParser.END_DOCUMENT (type ! XmlPullParser.END_TAG || parser.getDepth()  outerDepth)) {if (type  XmlPullParser.END_TAG || type  XmlPullParser.TEXT) {continue;}String tagName  parser.getName();if (tagName.equals(display)) {readDisplay(parser, fileData);} else if (tagName.equals(config)) {readConfig(parser, fileData);} else {Slog.w(TAG, Unknown element under display-settings:  parser.getName());XmlUtils.skipCurrentTag(parser);}}success  true;} catch (IllegalStateException e) {Slog.w(TAG, Failed parsing   e);} catch (NullPointerException e) {Slog.w(TAG, Failed parsing   e);} catch (NumberFormatException e) {Slog.w(TAG, Failed parsing   e);} catch (XmlPullParserException e) {Slog.w(TAG, Failed parsing   e);} catch (IOException e) {Slog.w(TAG, Failed parsing   e);} catch (IndexOutOfBoundsException e) {Slog.w(TAG, Failed parsing   e);} finally {try {stream.close();} catch (IOException ignored) {}}if (!success) {fileData.mSettings.clear();}return fileData;
}private static int getIntAttribute(TypedXmlPullParser parser, String name, int defaultValue) {return parser.getAttributeInt(null, name, defaultValue);
}Nullable
private static Integer getIntegerAttribute(TypedXmlPullParser parser, String name,Nullable Integer defaultValue) {try {return parser.getAttributeInt(null, name);} catch (Exception ignored) {return defaultValue;}
}Nullable
private static Boolean getBooleanAttribute(TypedXmlPullParser parser, String name,Nullable Boolean defaultValue) {try {return parser.getAttributeBoolean(null, name);} catch (Exception ignored) {return defaultValue;}
}private static void readDisplay(TypedXmlPullParser parser, FileData fileData)throws NumberFormatException, XmlPullParserException, IOException {String name  parser.getAttributeValue(null, name);if (name ! null) {SettingsEntry settingsEntry  new SettingsEntry();settingsEntry.mWindowingMode  getIntAttribute(parser, windowingMode,WindowConfiguration.WINDOWING_MODE_UNDEFINED /* defaultValue */);settingsEntry.mUserRotationMode  getIntegerAttribute(parser, userRotationMode,null /* defaultValue */);settingsEntry.mUserRotation  getIntegerAttribute(parser, userRotation,null /* defaultValue */);settingsEntry.mForcedWidth  getIntAttribute(parser, forcedWidth,0 /* defaultValue */);settingsEntry.mForcedHeight  getIntAttribute(parser, forcedHeight,0 /* defaultValue */);settingsEntry.mForcedDensity  getIntAttribute(parser, forcedDensity,0 /* defaultValue */);settingsEntry.mForcedScalingMode  getIntegerAttribute(parser, forcedScalingMode,null /* defaultValue */);settingsEntry.mRemoveContentMode  getIntAttribute(parser, removeContentMode,REMOVE_CONTENT_MODE_UNDEFINED /* defaultValue */);settingsEntry.mShouldShowWithInsecureKeyguard  getBooleanAttribute(parser,shouldShowWithInsecureKeyguard, null /* defaultValue */);settingsEntry.mShouldShowSystemDecors  getBooleanAttribute(parser,shouldShowSystemDecors, null /* defaultValue */);final Boolean shouldShowIme  getBooleanAttribute(parser, shouldShowIme,null /* defaultValue */);if (shouldShowIme ! null) {settingsEntry.mImePolicy  shouldShowIme ? DISPLAY_IME_POLICY_LOCAL: DISPLAY_IME_POLICY_FALLBACK_DISPLAY;} else {settingsEntry.mImePolicy  getIntegerAttribute(parser, imePolicy,null /* defaultValue */);}settingsEntry.mFixedToUserRotation  getIntegerAttribute(parser, fixedToUserRotation,null /* defaultValue */);settingsEntry.mIgnoreOrientationRequest  getBooleanAttribute(parser,ignoreOrientationRequest, null /* defaultValue */);settingsEntry.mIgnoreDisplayCutout  getBooleanAttribute(parser,ignoreDisplayCutout, null /* defaultValue */);settingsEntry.mDontMoveToTop  getBooleanAttribute(parser,dontMoveToTop, null /* defaultValue */);fileData.mSettings.put(name, settingsEntry);}XmlUtils.skipCurrentTag(parser);
}private static void readConfig(TypedXmlPullParser parser, FileData fileData)throws NumberFormatException,XmlPullParserException, IOException {fileData.mIdentifierType  getIntAttribute(parser, identifier,IDENTIFIER_UNIQUE_ID);XmlUtils.skipCurrentTag(parser);
}3.2 简要时序图 4、每屏幕焦点 
每个屏幕焦点 为了同时支持多个以单个屏幕为目标的输入源可以将 Android 10 配置为支持多个聚焦窗口每个屏幕最多支持一个。当多个用户同时与同一设备交互并使用不同的输入方法或设备例如 Android Automotive时此功能仅适用于特殊类型的设备。 强烈建议不要为常规设备启用此功能包括跨屏设备或用于类似桌面设备体验的设备。这主要是出于安全方面的考虑因为这样做可能会导致用户不确定哪个窗口具有输入焦点。 想象一下用户在文本输入字段中输入安全信息也许是登录某个银行应用或者输入包含敏感信息的文本。恶意应用可以创建一个虚拟的屏幕外屏幕用于执行 activity也可以使用文本输入字段执行 activity。合法 activity 和恶意 activity 均具有焦点并且都显示一个有效的输入指示符闪烁光标。 不过键盘硬件或软件的输入只能进入最顶层的 activity最近启动的应用。通过创建隐藏的虚拟屏幕即使在主设备屏幕上使用软件键盘恶意应用也可以获取用户输入。 使用 com.android.internal.R.bool.config_perDisplayFocusEnabled 设置每屏幕焦点。 兼容性 **问题**在 Android 9 及更低版本中系统中一次最多只有一个窗口具有焦点。 **解决方案**在极少数情况下来自同一进程的两个窗口都处于聚焦状态则系统仅向在 Z 轴顺序中较高的窗口提供焦点。对于以 Android 10 为目标平台的应用目前已取消这一限制此时预计这些应用可以支持同时聚焦多个窗口。 实现 WindowManagerService#mPerDisplayFocusEnabled 用于控制此功能的可用性。在 ActivityManager 中系统现在使用的是 ActivityDisplay#getFocusedStack()而不是利用变量进行全局跟踪。ActivityDisplay#getFocusedStack() 根据 Z 轴顺序确定焦点而不是通过缓存值来确定。这样一来只有一个来源 WindowManager 需要跟踪 activity 的 Z 轴顺序。 如果必须要确定系统中最顶层的聚焦堆栈ActivityStackSupervisor#getTopDisplayFocusedStack() 会采用类似的方法处理这些情况。系统将从上到下遍历这些堆栈搜索第一个符合条件的堆栈。 InputDispatcher 现在可以有多个聚焦窗口每个屏幕一个。如果某个输入事件特定于屏幕则该事件会被分派到相应屏幕中的聚焦窗口。否则它会被分派到聚焦屏幕即用户最近与之交互的屏幕中的聚焦窗口。 请参阅 InputDispatcher::mFocusedWindowHandlesByDisplay 和 InputDispatcher::setFocusedDisplay()。聚焦应用也会通过 NativeInputManager::setFocusedApplication() 在 InputManagerService 中分别更新。 在 WindowManager 中系统还会单独跟踪聚焦窗口。请参阅 DisplayContent#mCurrentFocus 和 DisplayContent#mFocusedApp 以及各自的用途。相关的焦点跟踪和更新方法已从 WindowManagerService 移至 DisplayContent。