当前位置: 首页 > article >正文

Android副屏锁屏界面-Android14

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;
}

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.kler.cn/a/542050.html

相关文章:

  • 期权帮 | 聊一聊股指期货交割是什么意思?
  • chromium-mojo
  • Maven 在 Eclipse 中的使用指南
  • Vue3+codemirror6实现公式(规则)编辑器
  • AI与大数据融合:技术路径与行业赋能
  • 【C++八股】 前置 ++i vs. 后置 i++ 的区别
  • React - 事件绑定this
  • SearchBar组件的功能与用法
  • Kafka知识点总结
  • Python+网络爬虫+Hadoop的电影票房数据分析管理系统
  • 探索B-树系列
  • Docker 和 Kubernetes 如何协同工作?
  • VBA语言的数据可视化
  • 【愚公系列】《Python网络爬虫从入门到精通》001-初识网络爬虫
  • Windows11+PyCharm利用MMSegmentation训练自己的数据集保姆级教程
  • 使用 Visual Studio Code (VS Code) 开发 Python 图形界面程序
  • Day59_20250207_图论part4_110.字符串接龙|105.有向图的完全可达性|106.岛屿的周长
  • Spring Boot整合DeepSeek实现AI对话(API调用和本地部署)
  • 淘宝App交易链路终端混合场景体验探索
  • 教育局网络设备运维和资产管理方案
  • SpringBoot中能被外部注入以来的注解
  • 网站快速收录攻略:提升页面加载速度
  • django中间件,中间件给下面传值
  • 05:定时器生成频率不同的波形
  • Rocketmq 和 Rabbitmq ,在多消费者的情况下,可以实现顺序消费吗
  • 使用腾讯云大模型知识引擎搭建满血deepseek