Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6738a47 authored by Tetiana Meronyk's avatar Tetiana Meronyk
Browse files

Add UI for multiple admins on Headless

In a series of CLs under topic add_ui_for_hsum_admins, UI and functionality for allowing multiple admins on HSUM build is added. In User settings and User switcher when creating a new user there is a new dialog prompting to choose admin status of the user to be created. In User details view there is a toggle that is visible to admin users that allows to modify admin status of existing users. This toggle is only applicable to full users that are not supervised, guests or a main device user.

Bug: 252790451
Test: croot && make RunSettingsRoboTests -j40 ROBOTEST_FILTER="com.android.settings.users.UserDetailsSettingsTest"
Change-Id: I34a6d223c009b7217e5e85077c886241ff06a2cb
parent cb7dd5c6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ interface IUserManager {
    String[] getPreInstallableSystemPackages(in String userType);
    void setUserEnabled(int userId);
    void setUserAdmin(int userId);
    void revokeUserAdmin(int userId);
    void evictCredentialEncryptionKey(int userId);
    boolean removeUser(int userId);
    boolean removeUserEvenWhenDisallowed(int userId);
+20 −0
Original line number Diff line number Diff line
@@ -4101,6 +4101,26 @@ public class UserManager {
        }
    }

    /**
     * Revokes admin privileges from the user, if such a user exists.
     *
     * <p>Note that this does not alter the user's pre-existing user restrictions.
     *
     * @param userId the id of the user to revoke admin rights from
     * @hide
     */
    @RequiresPermission(allOf = {
            Manifest.permission.INTERACT_ACROSS_USERS_FULL,
            Manifest.permission.MANAGE_USERS
    })
    public void revokeUserAdmin(@UserIdInt int userId) {
        try {
            mService.revokeUserAdmin(userId);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Evicts the user's credential encryption key from memory by stopping and restarting the user.
     *
+37 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2022 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:padding="@dimen/grant_admin_dialog_padding">
    <RadioGroup
        android:id="@+id/choose_admin"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <RadioButton
            android:id="@+id/grant_admin_yes"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/grant_admin"/>
        <RadioButton
            android:id="@+id/grant_admin_no"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/not_grant_admin"/>
    </RadioGroup>
</LinearLayout>
+3 −0
Original line number Diff line number Diff line
@@ -109,4 +109,7 @@
    <dimen name="broadcast_dialog_btn_text_size">16sp</dimen>
    <dimen name="broadcast_dialog_btn_minHeight">44dp</dimen>
    <dimen name="broadcast_dialog_margin">16dp</dimen>

    <!-- Size of grant admin privileges dialog padding -->
    <dimen name="grant_admin_dialog_padding">16dp</dimen>
</resources>
+8 −0
Original line number Diff line number Diff line
@@ -1368,6 +1368,10 @@
    <string name="user_add_user_message_long">You can share this device with other people by creating additional users. Each user has their own space, which they can customize with apps, wallpaper, and so on. Users can also adjust device settings like Wi\u2011Fi that affect everyone.\n\nWhen you add a new user, that person needs to set up their space.\n\nAny user can update apps for all other users. Accessibility settings and services may not transfer to the new user.</string>
    <!-- Message for add user confirmation dialog - short version. [CHAR LIMIT=none] -->
    <string name="user_add_user_message_short">When you add a new user, that person needs to set up their space.\n\nAny user can update apps for all other users. </string>
    <!-- Title for grant user admin privileges dialog [CHAR LIMIT=30] -->
    <string name="user_grant_admin_title">Give this user admin privileges?</string>
    <!-- Message for grant admin privileges dialog. [CHAR LIMIT=none] -->
    <string name="user_grant_admin_message">As an admin, they will be able to manage other users, modify device settings and factory reset the device.</string>
    <!-- Title of dialog to setup a new user [CHAR LIMIT=30] -->
    <string name="user_setup_dialog_title">Set up user now?</string>
    <!-- Message in dialog to setup a new user after creation [CHAR LIMIT=none] -->
@@ -1434,6 +1438,10 @@
    <!-- Dialog message on action exit guest (ephemeral guest) [CHAR LIMIT=80] -->
    <string name="guest_exit_dialog_message">This will delete
        apps and data from the current guest session</string>
    <!-- Dialog message on action grant admin privileges [CHAR LIMIT=60] -->
    <string name="grant_admin">Give this user admin privileges</string>
    <!-- Dialog message on action not grant admin privileges [CHAR LIMIT=60] -->
    <string name="not_grant_admin">Do not give user admin privileges</string>
    <!-- Dialog button on action exit guest (ephemeral guest) [CHAR LIMIT=80] -->
    <string name="guest_exit_dialog_button">Exit</string>
    <!-- Dialog title on action exit guest (non-ephemeral guest) [CHAR LIMIT=32] -->
Loading