Thursday, April 23, 2015

5.0 lollipop - Session logout on device with multiple users?


There is an option to switch between users, but there isn't an option to logout from an active user session. The background apps and services for inactive users (once logged in and switched out) continue to run draining the battery.


The only way i think, is to reboot the device and not login the user.


So, is there any way that the owner can force subsequent inactive users to logout of their session? I have superuser access to the owner with android-5.0.2.



Answer




In a terminal app on Android, enter (requires root access) :


su
am stop-user USER_ID

E.g. For a Guest user, its USER_ID in my device is 11 so the command would be am stop-user 11.


am stop-user doesn't process multiple input so you've to execute the command for every secondary user which you want to pause.


This is bit different from restarting the device. If you check am's usage you would see,


am stop-user: stop execution of USER_ID, not allowing it to run any code until a later explicit start or switch to it.

As said, it simply pauses all the activities associated to that user account, so whenever an explicit start or switch is provided your session would resume rather than starting from scratch.



For confirmation that the user indeed has paused or is not running, see my answer for How to find out currently running user name/ID from ADB?


Briefly, pm list users or dumpsys activity would tell you whether the user is RUNNING or SHUTDOWN. The latter command is better. If the user-session is indeed put on halt by am stop-user, you would see mState=SHUTDOWN for that user. However, if the user hasn't been activated even once since the reboot, you wouldn't see any of its entry.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...