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

Commit d35a89cd authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Helper method to check if current user is a demo user

Bug: 27280140
Change-Id: I7f6ed3198a42b4f8b81b54764e0b73499a94f77c
parent e8b8f1b4
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -789,7 +789,7 @@ public class UserManager {
     */
    public boolean isPrimaryUser() {
        UserInfo user = getUserInfo(UserHandle.myUserId());
        return user != null ? user.isPrimary() : false;
        return user != null && user.isPrimary();
    }

    /**
@@ -855,7 +855,19 @@ public class UserManager {
     */
    public boolean isGuestUser() {
        UserInfo user = getUserInfo(UserHandle.myUserId());
        return user != null ? user.isGuest() : false;
        return user != null && user.isGuest();
    }

    /**
     * Checks if the calling app is running in a demo user.
     * <p>
     * Caller must hold the MANAGE_USERS permission.
     * @return whether the caller is a demo user.
     * @hide
     */
    public boolean isDemoUser() {
        UserInfo user = getUserInfo(UserHandle.myUserId());
        return user != null && user.isDemo();
    }

    /**