【AAOS】【源码分析】用户管理(二)-- 用户启动
用户大体流程:用户启动过程中,涉及很多模块,其中UserController模块负责居中调度
-
创建并启动主用户:系统在首次启动时自动创建 User 0,在SystemReady时,由 SystemServer 启动系统用户(User 0),主用户是以Background方式运行,在用户启动过程中发送一系列广播通知,包括:
-
android.intent.action.USER_STARTED
:表示用户已经启动完成。 -
android.intent.action.USER_STARTING
:表示用户启动过程即将开始。
-
- 创建Secondary用户:CarUserService在启动时,会创建相应的Secondary用户(默认用户id为10),涉及的广播通知为:
android.intent.action.USER_ADDED
:表示用户已经创建完成。
- 启动Secondary用户:在用户创建完毕后,会直接启动Secondary用户,涉及的广播通知:
-
android.intent.action.USER_STARTED
:表示用户已经启动完成。 -
android.intent.action.USER_STARTING
:表示用户启动过程即将开始。
-
-
解锁用户:在用户启动后,调用maybeUnlockUser来解锁Secondary用户的父用户及Secondary用户,涉及的广播通知:
-
android.intent.action.USER_UNLOCKED
:解锁主用户。 -
android.intent.action.USER_UNLOCKED
:解锁Secondary用户。
-
-
切换用户:解锁完毕后,会将Secondary用户切换为foreground,涉及的广播通知:
-
android.intent.action.USER_BACKGROUND
:主用户切换为Background用户。 -
android.intent.action.USER_FOREGROUND
:Secondary用户切换为Foreground。 -
android.intent.action.USER_SWITCHED
:发送用户切换完毕通知。
-
配置项
-
headless配置:系统属性ro.fw.mu.headless_system_user用于标识是否采用 Headless System User模式,针对AAOS,默认为true。
[ro.fw.mu.headless_system_user]: [true]
-
config_isMainUserPermanentAdmin: 用于指定主用户(通常是用户 0)是否应始终拥有设备管理员权限。
-
Car配置文件
-
packages/services/Car/car_product/rro/overlay-config/androidRRO/res/values/config.xml
<!-- Whether the main user is a permanent admin user. If the main user is a permanent admin userit can't be deleted or downgraded to non-admin status.This is generally only relevant on headless system user mode devices; on other devices, themain user is the system user which is always a permanent admin anyway. -->
<bool name="config_isMainUserPermanentAdmin">false</bool>
主要模块
模块图
模块描述
No. | 模块名称 | 功能描述 |
1 | UserManager | 提供应用层 API,用于管理用户账户,如创建、删除和查询用户信息。 |