A bit of a technical question.
I am having several user profiles for different activities, and it is a bit inconvenient to switch between these profiles by opening notification center (swiping down twice), pressing the "user account icon", selecting an account.
I was wondering whether it would be possible to make a shortcut on the desktop to directly take me to the lock screen of a specific user profile?
Perhaps not out of box, but is there's some kind of API that would allow me to logout and open lock screen for a specific user from a lightweight app/widget on the screen (which I could make myself)?
Thank you
A shortcut to quickly open specific user account
I'll start with the short answer: no, it's not possible unless it's added by the GrapheneOS team, or you make your own implementation, build your own OS and include this app yourself... Anyway, here's stuff I found out while figuring out the answer to your question:
From what I can tell, the Android SystemUI and Settings packages both use ActivityManager.switchUser(userId)
to switch to another user, which requires MANAGE_USERS
or CREATE_USERS
permissions, both of which are restricted permissions.
I'm not sure about SystemUI using this still because the filename has "old" in it, but here it is in Settings and here's ActivityManager
's switchUser.
I didn't really spend more time figuring out how SystemUI gets and displays each user, but I recall seeing Settings uses UserManager.getUsers()
to get a list of users (link to getUsers()
), which requires one of the same two permissions listed above.
Both permissions are protected permissions. Basically, the app would have to be signed by the same certificate that was used when building the OS, otherwise it would have to be added to an allowlist (https://source.android.com/docs/core/permissions/perms-allowlist).
unwat thanks for doing such a research!
- Edited
A quick follow up question - could you please point out where the bottom panel of the "Control Center" src code may be located? I am looking at systemui/statusbar/policy but can't find neither "power" nor "settings" buttons. I was hoping I could programmatically invoke the "Switch user" dialog, if that's possible at all.
I'm not too sure if you can or not. It looks like the dialog box we see after tapping the button just responds to an on click listener, so I don't know if it's possible to "click" that programmatically. (By the way, those buttons are located in systemui/qs/footer
.)
Apparently there's a full screen activity that can be launched, though. It's mentioned in this doc. I don't think it's possible to launch the activity from an external app based on its entry in the AndroidManifest.xml file. I tried launching it via ADB anyway but it didn't work (I forget the exact error, but it had something to do with permissions).
Here are some other links that might be helpful:
- FooterActionsController
- UserSwitchDialogController
- UserSwitcherActivity
- and there's another thing about user switching here, but it looks like it's disabled here
So, I'm still thinking the only way to achieve what you're describing is by either building your own app and OS and including the app as a privileged app or it looks like you'd have to make modification to SystemUI. Though maybe after you take a look at all this you might find a way that I didn't see or understand.
Only a macro that actually simulates input actions can do this. AutoInput can do it.
- Edited
Graphite unwat
Very thankful for the research shared above.
For now would it make sense to chip away at this incrementally from another angle, perhaps using widgets?
I have noticed that it's possible to create the following widget:
swipe up for apps list ->
long press "Settings" app ->
select "Widgets" ->
touch, hold, and drag "Settings shortcut 1 x 1" ->
drop on homescreen ->
select the "System" widget (located at the bottom of the list)
Then you can access the user profiles from the homescreen using tapping only, no swipes:
select the "System" widget on homescreen (created via instructions above) ->
select "Multiple users" ->
select "[profile]" of choice ->
select "Switch to [profile]"
[at lockscreen of new profile]
^ That's 4x taps total
Compare to the swiping method:
2x swipe down ->
select current profile's icon ->
select target profile's icon
[at lockscreen of new profile]
^ That's [2x swipes + 2x taps]
For some reason, I find [4x taps] to be just a tiny bit more fluid than [2x swipes + 2x taps]. Not much, but a little.
Could it be taken further though, to 3x taps via the widget on the homescreen??
How hard would it be to create a widget that shortcuts you one menu deeper into the Settings menu?
Essentially, allow the widget to jump to Settings -> System -> Multiple users
instead of just Settings -> System
?
That would shave down the workflow to just 3x taps to get the target profile's lock screen. That's a fair bit better than the [4x taps] or [2x swipes + 2x taps] options above.
Of course [2x taps] or [1x tap] from the homescreen is ideal, but that sounds like a ways off from official release.
IMO whittling it down to just 1x tap would be a great improvement for newbie retention & promote better profile hygiene habits for almost any user. The less friction there is to switch profiles, the more profiles one can easily manage. More compartmentalization -> the whole boat can get just a little less leaky.
Still much to be thankful for though. It's a blessing to have the profiles feature at all.
Thanks again ~
zzz
Thanks for the idea with the widget, it does make it easier to switch users than swiping.
Also, in general, allowing settings widget perform certain preprogrammed settings changes would make things much more convenient for the end user. Connect Wifi to to specific hotspot, quickly switch between user accounts, enabling/disabling certain developer options (like, allow/disallow USB debugging), activate/deactivate MTP file transfer, etc.
Something similar to iOS shortcuts, but for the Settings.
But that's probably more of an ask for AOSP dev team than Graphene.
[deleted]
From Aurora or Google Play download following app
https://play.google.com/store/apps/details?id=de.szalkowski.activitylauncher
Use search function on top to find "Multiple users" activity.
Tap three dots on the right and create shortcut on home screen.
Congrats, now you are one tap away from switching users!
[deleted] Good catch, Sarge! And thanks for including clear instructions on what could be a confusing installation!!
[deleted]
newbie24689 Thank you, and let's not forget that this app can be used for linking to other activities that are not available via Settings widget. BTW I subsequently found out that this app is available on FDroid also (for those who shy away from Google services):
https://f-droid.org/packages/de.szalkowski.activitylauncher/
Link to use with Obtainium: https://github.com/butzist/ActivityLauncher
Is it possible to launch the correct profile directly using this?
Atm it opens the profile launcher, which and then I needs to select the profile I want to switch to. If it was possible to eliminate last step and have launcher pick correct profile it would be perfect world :)
Doesn't work in my case. Got "App isn't installed." error. Same issue with Create Shortcut App
- Edited
i have 5 profiles and everyday i have to switch on then many times, every time i have to swipe down the screen, press the icon from the current user then choose the profile i want on that moment to login.
i think graphene developers could add the SWITCH PROFILE OPTION on power button. so if power button pressed (two times or three times) it would show up a menu with all the profiles to choose. or another way.. like swipe screen to left with 3 fingers or.. up/down with 4 fingers.. shows this menu to switch user..
[deleted]
mclsza this is no problem with GOS but with the way you use your device. Apparently you switched to better OS but intend to keep your old habits, therefore the need to lock privacy invasive apps away in different profiles. This is just my guess but I bet I am not far off. I think of each profile as a different device albeit with the same IMEI. There is something called cross device tracking. https://en.wikipedia.org/wiki/Cross-device_tracking Maybe this is a good time for you to stop, think and have a little detox.
+1 for a Feature to switch users via widget or open the user select window via 1 click (instead of swipe, swipe, click).