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

Commit 920ace0b authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Query users excluding any being removed

Keep track of user creation and last logged-in time.
adb shell dumpsys users
User switcher shouldn't show users about to be removed.
No need to check for singleton for activities.

Bug: 7194894
Change-Id: Ic9a59ea5bd544920479e191d1a1e8a77f8b6ddcf
parent 2f98008d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1025,7 +1025,7 @@ public final class Pm {

    public void runListUsers() {
        try {
            List<UserInfo> users = mUm.getUsers();
            List<UserInfo> users = mUm.getUsers(false);
            if (users == null) {
                System.err.println("Error: couldn't get users");
            } else {
+8 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ public class UserInfo implements Parcelable {
    public String name;
    public String iconPath;
    public int flags;
    public long creationTime;
    public long lastLoggedInTime;

    public UserInfo(int id, String name, int flags) {
        this(id, name, null, flags);
@@ -101,6 +103,8 @@ public class UserInfo implements Parcelable {
        id = orig.id;
        flags = orig.flags;
        serialNumber = orig.serialNumber;
        creationTime = orig.creationTime;
        lastLoggedInTime = orig.lastLoggedInTime;
    }

    public UserHandle getUserHandle() {
@@ -122,6 +126,8 @@ public class UserInfo implements Parcelable {
        dest.writeString(iconPath);
        dest.writeInt(flags);
        dest.writeInt(serialNumber);
        dest.writeLong(creationTime);
        dest.writeLong(lastLoggedInTime);
    }

    public static final Parcelable.Creator<UserInfo> CREATOR
@@ -140,5 +146,7 @@ public class UserInfo implements Parcelable {
        iconPath = source.readString();
        flags = source.readInt();
        serialNumber = source.readInt();
        creationTime = source.readLong();
        lastLoggedInTime = source.readLong();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ interface IUserManager {
    void setUserName(int userHandle, String name);
    void setUserIcon(int userHandle, in Bitmap icon);
    Bitmap getUserIcon(int userHandle);
    List<UserInfo> getUsers();
    List<UserInfo> getUsers(boolean excludeDying);
    UserInfo getUserInfo(int userHandle);
    void setGuestEnabled(boolean enable);
    boolean isGuestEnabled();
+17 −3
Original line number Diff line number Diff line
@@ -116,7 +116,23 @@ public class UserManager {
     */
    public List<UserInfo> getUsers() {
        try {
            return mService.getUsers();
            return mService.getUsers(false);
        } catch (RemoteException re) {
            Log.w(TAG, "Could not get user list", re);
            return null;
        }
    }

    /**
     * Returns information for all users on this device.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     * @param excludeDying specify if the list should exclude users being removed.
     * @return the list of users that were created.
     * @hide
     */
    public List<UserInfo> getUsers(boolean excludeDying) {
        try {
            return mService.getUsers(excludeDying);
        } catch (RemoteException re) {
            Log.w(TAG, "Could not get user list", re);
            return null;
@@ -271,6 +287,4 @@ public class UserManager {
        }
        return -1;
    }


}
+1 −1
Original line number Diff line number Diff line
@@ -703,7 +703,7 @@ public class KeyguardHostView extends KeyguardViewBase {
        // if there are multiple users, we need to add the multi-user switcher widget to the
        // keyguard.
        UserManager mUm = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        List<UserInfo> users = mUm.getUsers();
        List<UserInfo> users = mUm.getUsers(true);

        if (users.size() > 1) {
            KeyguardWidgetFrame userSwitcher = (KeyguardWidgetFrame)
Loading