android T分屏流程

article/2025/9/15 17:13:04

概览

在这里插入图片描述
在这里插入图片描述
分屏前的order

  Task display areas in top down Z order:TaskDisplayArea DefaultTaskDisplayAreamPreferredTopFocusableRootTask=Task{919dc1b #1 type=home ?? U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}mLastFocusedRootTask=Task{919dc1b #1 type=home ?? U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}Application tokens in top down Z order:* Task{919dc1b #1 type=home ?? U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}bounds=[0,0][1080,2520]* Task{95cd9f8 #2 type=home I=com.miui.home/.launcher.Launcher U=0 rootTaskId=1 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}bounds=[0,0][1080,2520]* ActivityRecord{23a7bec u0 com.miui.home/.launcher.Launcher} t2}* Task{e49cf5a #27 type=standard A=10219:com.miui.weather2 U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1}bounds=[0,0][1080,2520]* ActivityRecord{4788499 u0 com.miui.weather2/.ActivityWeatherMain} t27}* Task{ec94c1a #38 type=undefined ?? U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=0}bounds=[0,0][1080,2520]* Task{a07962f #25 type=standard A=10070:android.task.mms U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1}bounds=[0,0][1080,2520]* ActivityRecord{43f400e u0 com.android.mms/.ui.MmsTabActivity} t25}// 分屏的Task位于TaskDisplayArea的最底部* Task{bcbb9ca #39 type=standard ?? U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=2}bounds=[0,0][1080,2520]* Task{495d73b #41 type=standard ?? U=0 rootTaskId=39 visible=false visibleRequested=false mode=multi-window translucent=true sz=0}bounds=[0,1317][1080,2520]* Task{65e6135 #40 type=undefined ?? U=0 rootTaskId=39 visible=false visibleRequested=false mode=multi-window translucent=true sz=0}bounds=[0,0][1080,1289]

分屏时的order

  Task display areas in top down Z order:TaskDisplayArea DefaultTaskDisplayAreamPreferredTopFocusableRootTask=Task{f555c62 #4 type=standard ?? U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=2}mLastFocusedRootTask=Task{f555c62 #4 type=standard ?? U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=2}Application tokens in top down Z order:// reorder分屏相关Task到TaskDisplayArea顶部* Task{f555c62 #4 type=standard ?? U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=2}bounds=[0,0][1080,2520]* Task{f4a61f3 #6 type=undefined ?? U=0 rootTaskId=4 visible=true visibleRequested=true mode=multi-window translucent=false sz=1}bounds=[0,1295][1080,2520]* Task{9b3720c #80 type=standard A=10213:com.miui.notes U=0 rootTaskId=4 visible=true visibleRequested=true mode=multi-window translucent=false sz=1}bounds=[0,1295][1080,2520]* ActivityRecord{2ab7e0 u0 com.miui.notes/.ui.NotesListActivity} t80}* Task{3c50f2d #5 type=standard ?? U=0 rootTaskId=4 visible=true visibleRequested=true mode=multi-window translucent=false sz=1}bounds=[0,0][1080,1267]* Task{27d1129 #78 type=undefined A=10003:com.miui.gallery.home U=0 rootTaskId=4 visible=true visibleRequested=true mode=multi-window translucent=false sz=2}bounds=[0,0][1080,1267]* ActivityRecord{c63706 u0 com.miui.gallery/.activity.GallerySettingsActivity} t78}* ActivityRecord{1435ba u0 com.miui.gallery/.activity.HomePageActivity} t78}* Task{a48f388 #1 type=home ?? U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1}bounds=[0,0][1080,2520]* Task{e676dd2 #2 type=home I=com.miui.home/.launcher.Launcher U=0 rootTaskId=1 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1}bounds=[0,0][1080,2520]* ActivityRecord{3faca81 u0 com.miui.home/.launcher.Launcher} t2}* Task{ad9de1e #3 type=undefined ?? U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=0}bounds=[0,0][1080,2520]

进入分屏

systemui 进程

android T上的分屏是在分屏下屏确定后桌面进程调用位于systemui进程的wm shell下的com.android.wm.shell.splitscreen.SplitScreenController.ISplitScreenImpl的startTasksWithLegacyTransition方法去开启分屏流程。

    /*** The interface for calls from outside the host process.*/@BinderThreadprivate static class ISplitScreenImpl extends ISplitScreen.Stub {......@Overridepublic void startTasksWithLegacyTransition(int mainTaskId, @Nullable Bundle mainOptions,int sideTaskId, @Nullable Bundle sideOptions, @SplitPosition int sidePosition,float splitRatio, RemoteAnimationAdapter adapter) {// binder 线程post 到主线程的executor去执行executeRemoteCallWithTaskPermission(mController, "startTasks",(controller) -> controller.mStageCoordinator.startTasksWithLegacyTransition(mainTaskId, mainOptions, sideTaskId, sideOptions, sidePosition,splitRatio, adapter));}

system server进程

进入分屏时WindowContainerTransaction的HierarchyOp列表包含三个元素:reorder、startTask、startTask
在这里插入图片描述

    private void applyTransaction(@NonNull WindowContainerTransaction t, int syncId,@Nullable Transition transition, @NonNull CallerInfo caller,@Nullable Transition finishTransition) {......// Hierarchy changesfinal List<WindowContainerTransaction.HierarchyOp> hops = t.getHierarchyOps();final int hopSize = hops.size();if (hopSize > 0) {final boolean isInLockTaskMode = mService.isInLockTaskMode();for (int i = 0; i < hopSize; ++i) {effects |= applyHierarchyOp(hops.get(i), effects, syncId, transition,isInLockTaskMode, caller, t.getErrorCallbackToken(),t.getTaskFragmentOrganizer(), finishTransition);}}......}

在这里插入图片描述

退出分屏

systemui进程

在这里插入图片描述

system server进程

退出分屏时WindowContainerTransaction的HierarchyOp列表也包含三个元素:childrenTasksReparent、childrenTasksReparent、reorder(分屏最外层的fullcscreen task)
在这里插入图片描述

{ChildrenTasksReparent: from=RemoteToken{6206d89 Task{495d73b #41 type=standard ?? U=0 rootTaskId=39 visible=true visibleRequested=true mode=multi-window translucent=false sz=1}} to=null mToTop=false mReparentTopOnly=false mWindowingMode=[1, 0, 6] mActivityType=[1]}
{ChildrenTasksReparent: from=RemoteToken{1d0a090 Task{65e6135 #40 type=undefined ?? U=0 rootTaskId=39 visible=true visibleRequested=true mode=multi-window translucent=false sz=1}} to=null mToTop=true mReparentTopOnly=false mWindowingMode=[1, 0, 6] mActivityType=[1]}
{reorder: RemoteToken{aae4b1a Task{bcbb9ca #39 type=standard ?? U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=2}} to bottom}

在这里插入图片描述

    private int reparentChildrenTasksHierarchyOp(WindowContainerTransaction.HierarchyOp hop,@Nullable Transition transition, int syncId) {// 一般为分屏的上下屏Task,mode为multi-windowWindowContainer<?> currentParent = hop.getContainer() != null? WindowContainer.fromBinder(hop.getContainer()) : null;// 这里一般为nullWindowContainer newParent = hop.getNewParent() != null? WindowContainer.fromBinder(hop.getNewParent()) : null;if (currentParent == null && newParent == null) {throw new IllegalArgumentException("reparentChildrenTasksHierarchyOp: " + hop);} else if (currentParent == null) {currentParent = newParent.asTask().getDisplayContent().getDefaultTaskDisplayArea();} else if (newParent == null) {// newParent赋值为TaskDisplayAreanewParent = currentParent.asTask().getDisplayContent().getDefaultTaskDisplayArea();}......// We want to collect the tasks first before re-parenting to avoid array shifting on us.final ArrayList<Task> tasksToReparent = new ArrayList<>();currentParent.forAllTasks(task -> {Slog.i(TAG, " Processing task=" + task);final boolean reparent;if (task.mCreatedByOrganizer || task.getParent() != finalCurrentParent) {// We only care about non-organized task that are direct children of the thing we// are reparenting from.return false;}if (newParentInMultiWindow && !task.supportsMultiWindowInDisplayArea(newParentTda)) {Slog.e(TAG, "reparentChildrenTasksHierarchyOp non-resizeable task to multi window,"+ " task=" + task);return false;}if (!ArrayUtils.contains(hop.getActivityTypes(), task.getActivityType())|| !ArrayUtils.contains(hop.getWindowingModes(), task.getWindowingMode())) {return false;}if (hop.getToTop()) {tasksToReparent.add(0, task);} else {tasksToReparent.add(task);}return hop.getReparentTopOnly() && tasksToReparent.size() == 1;});final int count = tasksToReparent.size();for (int i = 0; i < count; ++i) {final Task task = tasksToReparent.get(i);if (syncId >= 0) {addToSyncSet(syncId, task);}if (transition != null) transition.collect(task);// 执行reparent操作if (newParent instanceof TaskDisplayArea) {// For now, reparenting to display area is different from other reparents...task.reparent((TaskDisplayArea) newParent, hop.getToTop());} else {task.reparent((Task) newParent,hop.getToTop() ? POSITION_TOP : POSITION_BOTTOM,false /*moveParents*/, "processChildrenTaskReparentHierarchyOp");}}if (transition != null) transition.collect(newParent);return TRANSACT_EFFECTS_LIFECYCLE;}

http://chatgpt.dhexx.cn/article/ea6n7vZW.shtml

相关文章

android 分屏切换流程,一种切换分屏模式和多窗口模式的方法与流程

本发明涉及一种切换分屏模式和多窗口模式的方法,适用于常见的带有触摸的电子设备,包括但不限于在系统的用户界面中使用触摸的方法进行导航的电子设备。 背景技术: 分屏模式是一种将两个应用扩充到全屏幕的交互方法。近几年随着技术的发展,使用触摸作为设备的输入方式已经被…

Android 分屏模式-多窗口支持

第一篇博客请多多担待&#xff0c;测试一下。 来自于https://developer.android.com/guide/topics/ui/multi-window.html#lifecycle Android N 添加了同时显示多个应用窗口的支持&#xff0c;在手持设备上&#xff0c;两个应用可以在“分屏”模式中左右并排或者上下并排显示。…

AndroidQ 分屏窗口模式 (AMS部分)

1. 多窗口 1.1 栈 Android7.0开始支持多窗口&#xff0c;多窗口分为三种&#xff0c;画中画&#xff0c;分屏&#xff0c;自由窗口&#xff0c;多窗口的核心原理其实就是分栈和设置栈边界&#xff0c; 分栈即把不同窗口模式下的Activity放在不同的ActivityStack中&#xff0…

Android分屏显示(多窗口支持) 开发总结

最近公司有分屏显示需求&#xff0c;遇到几点问题 &#xff0c;在此记录&#xff0c;以做备忘。 我所谓的分屏显示&#xff0c;是在同一个界面内&#xff0c;分屏显示两个app的界面 或者是 注意点1&#xff1a; 系统好像没有获取应用显示的左右或者上下位置的方法&#xff0c;…

android安卓手机分屏多窗口实现方法

效果图 frameborder"0" allowtransparency"true" scrolling"no" vspace"0" hspace"0" style"display: block; position: static; padding: 0px; margin: 0px; border-style: none; vertical-align: baseline; width: 3…

Android实现一键开启自由窗口、分屏、画中画模式——画中画模式

转载请注明出处&#xff1a;https://blog.csdn.net/sunmmer123 Android实现一键开启自由窗口、分屏、画中画模式系列 一键开启进入自由窗口模式一键开启进入分屏模式一键进入画中画模式 通过前俩篇博文&#xff0c;我们学习了一些多窗口模式中的自由窗口模式与分屏模式的知识 最…

Android多窗口模式(分屏模式)

Android N 支持多窗口模式&#xff0c;或者叫分屏模式&#xff0c;即在屏幕上可以同时显示多个窗口。 在手机模式下&#xff0c;两个应用可以并排或者上下同时显示&#xff0c;如图 1 所示&#xff0c;屏幕上半部分的窗口是系统的 CLOCK 应用&#xff0c;下半部分是系统设置功能…

git 命令怎么创建新分支?

问题 比如&#xff1a;我们要以 dev 分支创建一个 test-branch 分支。 解决 1、在本地创建一个 test-branch 分支&#xff0c;并切换到该分支。 git checkout -b test-branch执行完&#xff0c;可以使用下面命令查看是否创建了该本地分支 git branch -a2、把分支推到远程仓…

git命令之快速搭建远程仓库

首先使用系统管理员账号登录远程服务器&#xff0c;具体步骤如下所示&#xff1a; 1 安装git应用程序 sudo apt-get install git 2 创建git用户组和git用户&#xff0c;具体命令如下所示&#xff1a; groupadd git adduser git -g git 3 修改git用户默认shell为git-shell…

Git命令常用操作 代码拉取和提交

常规的git命令就是以下几个语句 项目首次拉取 git clone 项目地址url拉取并同步代码到本地 git pull将本地所有更改的文件添加到缓存区 git add .添加备注&#xff0c;方便之后查看历史提交记录 git commit -m "本次提交备注信息"提交到git仓库 git push

git命令之新建仓库

一. 配置git用户名 1&#xff09;安装git&#xff0c;配置用户名和邮箱 git config --global user.name "你的用户名" git config --global user.email "你的注册邮箱" 2&#xff09;使用git config --global --list查看配置 二. 工作区操作 1&#x…

常见Git命令使用

常见Git命令使用 1.初始化创库 git init 2.git status 这个命令顾名思义就是查看状态&#xff0c; 这个命令可以算是使用最频繁的一个命令了&#xff0c; 建议大家没事就输入下这个命令&#xff0c; 来查看你当前 git 仓库的一些状态。 3.git add 文件名 将文件添加到git仓库…

git命令拉取代码

流程 1在本地clone项目【保持与远程仓库一致】 此时已绑定远程仓库 git clone xxxx2.添加文件 3.放到暂存区 git add .4.提交到本地仓库 git commint -m "提示信息"5推送到远程仓库 git push origin master其他命令 分支命令 分支就是每个人开发 互不影响 之后…

Git 命令之stash

Git 命令之stash 前言1 stash1.1 描述1.2 应用场景命令使用 前言 使用 Git 作为代码版本管理&#xff0c;早已是现在开发工程师必备的技能。可大多数工程师还是只会最基本的保存、拉取、推送&#xff0c;遇到一些commit管理的问题就束手无策&#xff0c;或者用一些不优雅的方式…

git命令登录

1. 执行登陆用户名和密码命令 git config --global user.email "youexample.com" git config --global user.name "Your Name"2. 生成密钥对 ssh-keygen -t rsa -C "your_emailyouremail.com"3. 配置公钥私钥 然后将 .ssh/id_rsa.pub中的内容复…

git命令详解

一、简介 git作为应用广泛的一种分布式版本控制系统&#xff0c;其与svn比较最大的差别就是一个是分布式&#xff0c;一个是集中式&#xff0c;git在每个开发者的本地有一个完整的版本库&#xff0c;当在本地处理工作时&#xff0c;无需联网便可修改提交&#xff0c;当需要与其…

关于Git这一篇就够了

目录 前言 发展过程 集中式与分布式的区别 Debian/Linux安装Git 配置git环境&#xff1a;git config --global 创建本地空仓库&#xff1a;git init 新建文件添加到本地仓库&#xff1a;git add、git commit -m 改写提交&#xff1a;git commit --amend 查看历史提交日…

【信号与系统】—知识点:自由响应、强迫响应、暂态响应、稳态响应、零输入响应、零状态响应如何区分!

自由响应、强迫响应、暂态响应、稳态响应、零输入响应、零状态响应如何区分&#xff01; 一、系统的响应划分 二、自由响应、强迫响应 自由响应和强迫响应是从数学上来分解的&#xff0c;没有什么物理意义&#xff0c;自由响应是齐次解&#xff0c;因为它的形式和激励无关&am…

一阶电路的零状态响应

零状态响应就是电路在零初始状态下(动态元件初始储能为零)由外施激励引起的响应。 RC电路的零状态响应 在t0时刻&#xff0c;开关S闭合&#xff0c;电路接入直流电压源US。根据KVL&#xff0c;有 uRuCUS (KVL ∑u0 指定回路的绕行方向是顺时针的&#xff0c;R、C的电压参考方向…

MATLAB:零状态响应(lsim(连续);filter(离散))、冲激响应(impulse或impz)和阶跃响应(step)、卷积(conv)

例1&#xff1a;求系统y(t)2y(t)100y(t)10x(t)的零状态响应&#xff0c;已知x(t)sin(2pt)u(t)。【连续时间系统零状态响应】 例2&#xff1a;求系统y(t)2y(t)100y(t)10x(t)的零状态响应&#xff0c;已知x(t)d(t)。&#xff08;ts0;te5;dt0.01&#xff09;【连续时间系统冲激响应…