安卓多用户管理之UserManagerService.UserData类

本文详细解读了AndroidUserManagerService中UserData类的源码,包括其包含的基本用户信息、属性(如账户名、种子账户等)、以及与系统行为相关的设置方法,帮助理解用户资料管理的实现细节。
摘要由CSDN通过智能技术生成


前言

UserManagerService.java内容繁多,对其进行逐个部分的拆解分析,本文对其内部UserData类进行基本说明和解读


UserData----用户资料

1.1 源码

    /**
     * Internal non-parcelable wrapper for UserInfo that is not exposed to other system apps.
     * 未公开给其他系统应用程序的UserInfo的内部不可分组包装。
     */
    @VisibleForTesting
    static class UserData {
        // Basic user information and properties    基本用户信息和属性
        UserInfo info;
        // Account name used when there is a strong association between a user and an account
        // 当用户和帐户之间存在强关联时使用的帐户名
        String account;
        // Account information for seeding into a newly created user. This could also be
        // used for login validation for an existing user, for updating their credentials.
        // In the latter case, data may not need to be persisted as it is only valid for the
        // current login session.
        /*
        用于种子设定到新创建的用户的帐户信息。这也可以用于现有用户的登录验证,用于更新他们的凭据。
        在后一种情况下,数据可能不需要持久化,因为它只对当前登录会话有效。
        */
        String seedAccountName;
        String seedAccountType;
        PersistableBundle seedAccountOptions;
        // Whether to perist the seed account information to be available after a boot
        // 是否在引导后销毁可用的种子帐户信息
        boolean persistSeedData;

        /** Elapsed realtime since boot when the user started. */ /**自用户启动后实时运行的时间*/
        long startRealtime;

        /** Elapsed realtime since boot when the user was unlocked. */ /**自用户解锁时启动以来实时运行的时间*/
        long unlockRealtime;

        private long mLastRequestQuietModeEnabledMillis;

        /**
         * {@code true} if the system should ignore errors when preparing the
         * storage directories for this user. This is {@code false} for all new
         * users; it will only be {@code true} for users that already existed
         * on-disk from an older version of Android.
         */
         /**
         /**
  		如果系统在准备此用户的存储目录时应忽略错误。这对所有新用户来说都是错误的;
		这只适用于已经存在于旧版本Android磁盘上的用户。
         */
        private boolean mIgnorePrepareStorageErrors;

        void setLastRequestQuietModeEnabledMillis(long millis) {
            mLastRequestQuietModeEnabledMillis = millis;
        }

        long getLastRequestQuietModeEnabledMillis() {
            return mLastRequestQuietModeEnabledMillis;
        }

        boolean getIgnorePrepareStorageErrors() {
            return mIgnorePrepareStorageErrors;
        }

        void setIgnorePrepareStorageErrors() {
            mIgnorePrepareStorageErrors = true;
        }

        void clearSeedAccountData() {
            seedAccountName = null;
            seedAccountType = null;
            seedAccountOptions = null;
            persistSeedData = false;
        }
    }

1.2 属性

属性类型含义
infoUserInfo基本用户信息和属性
accountString当用户和帐户之间存在强关联时使用的帐户名
seedAccountNameString种子账户名称
seedAccountTypeString种子账户类型
seedAccountOptionsPersistableBundle种子账户选项
persistSeedDataboolean存留种子信息
startRealtimelong自用户启动后实时运行的时间
unlockRealtimelong自用户解锁时启动以来实时运行的时间
mLastRequestQuietModeEnabledMillislong上次请求静态模式Enabled毫秒时间
mIgnorePrepareStorageErrorsboolean忽视准备存储错误

1.3 方法

方法返回值参数含义
setLastRequestQuietModeEnabledMillisvoidlong millis设置上次请求静态模式Enabled毫秒时间为millis
getLastRequestQuietModeEnabledMillislong返回上次请求静态模式Enabled毫秒时间
getIgnorePrepareStorageErrorsboolean返回mIgnorePrepareStorageErrors的值
setIgnorePrepareStorageErrorsvoid设置mIgnorePrepareStorageErrors的值为true
clearSeedAccountDatavoid清除种子账户信息,seedAccountName 、type、options为null, persistSeedData为false。
  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值