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.