사용자 정의 사용자 유형 구현

Android 11에는 Android 다중 사용자 기능에서 허용하는 모든 다양한 유형의 사용자를 나타내는 잘 정의된 사용자 유형의 개념이 도입되었습니다. 이 기능을 통해 OEM은 사전 정의된 AOSP 사용자 유형을 사용자 정의하고 새 프로필 유형을 정의할 수 있습니다. 자세한 내용은 사용자 유형 섹션을 참조하세요.

이 페이지에서는 사용자 유형을 사용자 지정하는 데 필요한 구현 지침을 자세히 설명합니다.

커스터마이징

AOSP 사용자 유형을 사용자 정의하고 새 프로필 유형을 정의하려면 OEM이 원하는 사용자 정의로 config_user_types.xml 을 오버레이해야 합니다. config_user_types.xml 파일에는 참조 구현과 구성 가능한 속성의 포괄적인 목록이 포함되어 있습니다.

config_user_types.xml 파일에 지정된 default-restrictions 와 같은 모든 속성은 AOSP 기본값을 덮어씁니다. 지정되지 않은 속성은 AOSP 기본값을 따릅니다. 프로필 유형의 배지 속성과 같은 대부분의 속성을 변경하면 해당 사용자 유형의 기존 사용자에게 영향을 미칩니다. 그러나 default-restrictions 는 사용자가 생성될 때만 적용되기 때문에 이 특정 속성을 수정하면 OTA에 의해 config_user_types.xml 파일이 변경된 경우 기존 사용자에게 영향을 미치지 않습니다. 마찬가지로 최대 사용자 수를 지정하는 것은 새 사용자를 생성할 때만 적용됩니다. 기존 사용자는 제거되지 않습니다.

각 사용자 유형에 대한 현재 사용자 지정 제한은 다음과 같습니다.

  • 프로필을 완전히 사용자 정의하고 정의할 수 있습니다. 이 경우 AOSP는 사전 정의된 AOSP 사용자 유형만 지원하기 때문에 OEM은 Android에서 지원되는 맞춤 프로필에 필요한 플랫폼 수정을 담당합니다.
  • 전체 사용자는 정의할 수 없으며 default-restrictions 속성만 사용자 정의할 수 있습니다.
  • 시스템 사용자는 이 메커니즘을 사용하여 사용자 지정할 수 없습니다. 이 경우 com.android.internal.R.array.config_defaultFirstUserRestrictions 를 사용하여 default-restrictions 을 설정할 수 있습니다. 자세한 내용은 config.xml 을 참조하십시오.

기존 사용자 유형 수정

기존 사용자 유형은 다음 코드 샘플과 같이 해당 속성을 재정의하여 사용자 지정할 수 있습니다.

<user-types version="0">
    <full-type name="android.os.usertype.full.SECONDARY" >
        <default-restrictions no_sms="true" />
    </full-type>

    <profile-type
        name='android.os.usertype.profile.MANAGED'
        max-allowed-per-parent='2'
        icon-badge='@android:drawable/ic_corp_icon_badge_case'
        badge-plain='@android:drawable/ic_corp_badge_case'
        badge-no-background='@android:drawable/ic_corp_badge_no_background' >
        <badge-labels>
            <item res='@android:string/managed_profile_label_badge' />
            <item res='@android:string/managed_profile_label_badge_2' />
        </badge-labels>
        <badge-colors>
            <item res='@android:color/profile_badge_1' />
            <item res='@android:color/profile_badge_2' />
        </badge-colors>
        <default-restrictions no_sms="true" no_outgoing_calls="true" />
    </profile-type>
</user-types>

이 코드 샘플에서 지원되는 속성을 수정하여 다음 AOSP 사용자 유형을 맞춤설정합니다.

  • 전체 사용자 android.os.usertype.full.SECONDARY :

    • no_sms 의 기본 제한은 default-restrictions no_sms="true" 를 지정하여 true로 설정됩니다.
  • 프로필 사용자 android.os.usertype.profile.MANAGED :

    • max-allowed-per-parent='2' 를 설정하여 각 상위 사용자에 대해 두 개의 프로필이 허용됩니다.
    • 배지 속성은 icon-badge , badge-plain , badge-no-background , badge-labels , badge-colors 을 사용하여 원하는 값으로 설정됩니다.
    • no_smsno_outgoing_calls 의 기본 제한은 default-restrictions no_sms="true" no_outgoing_calls="true" 를 지정하여 true로 설정됩니다.

이러한 속성의 의미와 기본값은 UserTypeFactory.javaUserTypeDetails.java 를 참조하십시오.

사용자 정의 프로필 유형 정의

다음 코드 샘플은 새로운 사용자 정의 프로필 유형이 정의되는 방법을 보여줍니다.

<user-types version="1">
    <profile-type
        name="com.example.profilename"
        max-allowed-per-parent="2" />

    <change-user-type
        from="android.os.usertype.profile.MANAGED"
        to="com.example.profilename"
        whenVersionLeq="1" />
</user-types>

이 코드 샘플에서 com.example.profilename 프로필 유형은 다음과 같이 정의됩니다.

  • max-allowed-per-parents 는 상위 사용자당 프로필 2개에 대해 2 로 설정됩니다.

  • change-user-type : OTA를 통해 <= 1user-type 버전에서 장치를 업그레이드할 때 android.os.usertype.profile.MANAGED 유형의 모든 기존 관리 프로필을 새로운 com.example.profilename 유형으로 변환합니다.