Android副屏锁屏界面-Android14

news/2025/2/12 15:01:57/

Android副屏锁屏界面-Android14

  • 1、副屏锁屏界面模式
  • 2、副屏锁屏界面
    • 2.1 添加KeyguardPresentation
    • 2.2 副屏同步主屏锁屏界面

Android 镜像模式和扩展模式区别探讨-Android14


1、副屏锁屏界面模式

属于 扩展模式 ,非镜像模式。LogicalDisplay.java#configureDisplayLocked 添加日志显示mHasContent=true,表明副屏添加了单独的界面。

2、副屏锁屏界面

SystemUIKeyguardDisplayManager.javaisKeyguardShowable 判断锁屏界面是否添加KeyguardPresentation;默认主屏DEFAULT_DISPLAY不会添加

frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java

private boolean isKeyguardShowable(Display display) {if (display == null) {if (DEBUG) Log.i(TAG, "Cannot show Keyguard on null display");return false;}if (display.getDisplayId() == mDisplayTracker.getDefaultDisplayId()) {if (DEBUG) Log.i(TAG, "Do not show KeyguardPresentation on the default display");return false;}display.getDisplayInfo(mTmpDisplayInfo);if ((mTmpDisplayInfo.flags & Display.FLAG_PRIVATE) != 0) {if (DEBUG) Log.i(TAG, "Do not show KeyguardPresentation on a private display");return false;}if ((mTmpDisplayInfo.flags & Display.FLAG_ALWAYS_UNLOCKED) != 0) {if (DEBUG) {Log.i(TAG, "Do not show KeyguardPresentation on an unlocked display");}return false;}if (mKeyguardStateController.isOccluded()&& mDeviceStateHelper.isConcurrentDisplayActive(display)) {if (DEBUG) {// When activities with FLAG_SHOW_WHEN_LOCKED are shown on top of Keyguard, the// Keyguard state becomes "occluded". In this case, we should not show the// KeyguardPresentation, since the activity is presenting content onto the// non-default display.Log.i(TAG, "Do not show KeyguardPresentation when occluded and concurrent"+ " display is active");}return false;}return true;
}/**
* @param display The display to show the presentation on.
* @return {@code true} if a presentation was added.
*         {@code false} if the presentation cannot be added on that display or the presentation
*         was already there.
*/
private boolean showPresentation(Display display) {if (!isKeyguardShowable(display)) return false;if (DEBUG) Log.i(TAG, "Keyguard enabled on display: " + display);final int displayId = display.getDisplayId();Presentation presentation = mPresentations.get(displayId);if (presentation == null) {final Presentation newPresentation = createPresentation(display);newPresentation.setOnDismissListener(dialog -> {if (newPresentation.equals(mPresentations.get(displayId))) {mPresentations.remove(displayId);}});presentation = newPresentation;try {presentation.show();} catch (WindowManager.InvalidDisplayException ex) {Log.w(TAG, "Invalid display:", ex);presentation = null;}if (presentation != null) {mPresentations.append(displayId, presentation);return true;}}return false;
}

KeyguardPresentation_83">2.1 添加KeyguardPresentation

KeyguardPresentation继承Presentation,根据副屏对应Display信息 createDisplayContext 创建对应的Context添加对应的副屏上。

frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java

KeyguardPresentation createPresentation(Display display) {return new KeyguardPresentation(mContext, display, mKeyguardStatusViewComponentFactory);
}

frameworks/base/core/java/android/app/Presentation.java

private static Context createPresentationContext(Context outerContext, Display display, int theme, @WindowType int type) {if (outerContext == null) {throw new IllegalArgumentException("outerContext must not be null");}if (display == null) {throw new IllegalArgumentException("display must not be null");}Context windowContext = outerContext.createDisplayContext(display).createWindowContext(getWindowType(type, display), null /* options */);if (theme == 0) {TypedValue outValue = new TypedValue();windowContext.getTheme().resolveAttribute(com.android.internal.R.attr.presentationTheme, outValue, true);theme = outValue.resourceId;}return new ContextThemeWrapper(windowContext, theme);
}

2.2 副屏同步主屏锁屏界面

副屏同步主屏锁屏界面就不需要显示KeyguardPresentation,需要在KeyguardDisplayManager.java#isKeyguardShowable判断,可以判断display.getDisplayId() > mDisplayTracker.getDefaultDisplayId()副屏返回false不添加界面;这里需要注意 CTS会失败


http://www.ppmy.cn/news/1571446.html

相关文章

VS Code 通知中一直显示“Reactivating terminals...”的问题解决

VS Code 通知中一直显示“Reactivating terminals...”的问题解决 问题截图解决方案修复截图相关链接 问题截图 解决方案 点击顶部放大镜(🔍) -> 输入尖括号(>) -> 然后搜索(Python: Clear Workspace Interpreter Setting) -> 最后点击即可 修复截图…

爬虫工程师分享:获取京东商品详情SKU数据的技术难点与攻破方法

在电商数据领域,京东商品详情页的SKU数据是许多爬虫工程师的目标。这些数据包含了商品的价格、库存、规格等关键信息,对于市场分析、价格监控等应用场景至关重要。然而,获取这些数据并非易事,京东作为国内电商巨头,其反…

git客户端版本下载

1. 访问官方网站:您可以在git官方网站(https://git-scm.com)上找到git软件最新稳定版下载链接。 2.如果需要下载其它版本,可访https://github.com/git-for-windows/git/releases选择想要的版本下载。

SWIFT 后训练 Deepseek-VL2 参数

SWIFT 后训练 Deepseek-VL2 参数 flyfish [INFO:swift] args: TrainArguments( _n_gpu-1, acc_steps1, acc_strategytoken, accelerator_config{dispatch_batches: False}, adafactorFalse, adalora_beta10.85, adalora_beta20.85, adalora_deltaT1, adalora_init_r12, adalo…

【Windows】PowerShell 缓存区大小调节

PowerShell 缓存区大小调节 方式1 打开powershell 窗口属性调节方式2,修改 PowerShell 配置文件 方式1 打开powershell 窗口属性调节 打开 CMD(按 Win R,输入 cmd)。右键标题栏 → 选择 属性(Properties)…

团结引擎高性能ECS架构(上)

在 Unite Shanghai 2024 及 Unity Open Day 厦门站中,团结引擎 DOTS Team 带来两场技术分享,分别解读了团结引擎 ECS 架构的详细实现及其高性能的真相。本文为首场演讲实录。 大家下午好!今天由我们团结引擎的 DOTS Team 带来团结引擎高性能 …

前端打包后的dist文件太大怎么办?如何优化处理?

Vue 项目打包后 dist 目录的大小取决于多个因素,例如项目的复杂度、使用的依赖库、图片资源、是否做了代码拆分和压缩等。通常来说: 1. 一般情况下的 dist 目录大小 2. 如何检查 dist 文件大小? 你可以使用 du -sh 命令快速查看 dist 目录…

【DeepSeek】DeepSeek概述 | 本地部署deepseek

目录 1 -> 概述 1.1 -> 技术特点 1.2 -> 模型发布 1.3 -> 应用领域 1.4 -> 优势与影响 2 -> 本地部署 2.1 -> 安装ollama 2.2 -> 部署deepseek-r1模型 1 -> 概述 DeepSeek是由中国的深度求索公司开发的一系列人工智能模型,以其…