【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
:发送用户切换完毕通知。
-
配置项
用户名配置
- 默认Owner用户配置
<resources><string name="owner_name">Driver</string>
</resources>
- 默认Guest用户配置
<resources><string name="default_guest_name">Guest</string>
</resources>
用户权限
packages/services/Car/car_product/rro/overlay-config/androidRRO/res/xml/config_user_types.xml
<user-types><full-type name="android.os.usertype.full.SECONDARY" ><default-restrictions /></full-type><full-type name="android.os.usertype.full.GUEST" ><default-restrictions no_factory_reset="true" no_remove_user="true"no_modify_accounts="tru