[MOD] Add multi-user support to Android 4.2 roms using device overlay (phone)

Search This thread

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
447
plus.google.com
I dont know if this has already been posted, but I could not find anything that enabled multi-user support directly.

It is fairly simple to add multi-user support to your Android 4.2 rom using the device overlay.

To enable multi-user support you will have to add the following to your config.xml:
<integer name="config_multiuserMaximumUsers">8</integer>

This will enable the Users section in Settings to add/remove new users.

Additionally you will have to modify layout-port/keyguard_host_view.xml, because the layout-port version of keyguard_host_view.xml does not have the multi-user selector.

You will need to add the following to the layout:
<include layout="@layout/keyguard_multi_user_selector"/>

Instead of modifying the layout xml directly you can also just add a modified version of the .xml to your device overlay.

That will add the user selector to the keyguard/lockscreen.

The changes can be found here:
https://github.com/adrian-bl-hox-jb...mmit/ba74d22a7e88f73c0c639ed23aac8617cc9abc9f

12+-+2
12+-+1


In case there is just one user it will not show the user selector in the keyguard/lockscreen.

Known issues:

* The dialer only works in the main user and and trying to dial in any other user will result in a crash, because the dialer does not support multi-user yet.
 
Last edited:

lokeshsaini94

Senior Member
May 1, 2012
1,777
3,984
Behind you!!!
This can be usefull when you have others Using your phone then you can set password for main acc and when others ask your phone they can open guest account or other...
this will get better...

Sent from my GT-S7500 using xda premium
 
  • Like
Reactions: emd2009

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
447
plus.google.com
Cool, thanks for sharing! (Although, I think having more users on an android device is kinda useless, but very nice that its possible)

I used to agree about it being useless for phones, but I also share a family gmail account and I like having that completely seperated from my own user so that I don't have calendars etc mixed in one user.

And in case you only have one user everything is the same as without the multiple user ability so it kinda made sense just adding it and let the user decide.
 
  • Like
Reactions: overground

runandhide05

Senior Member
Apr 3, 2011
2,968
2,606
would someone do me a favor and attempt to make a phone call in a user profile that is not the main user, i added this in and i get fc when i attempt to make a call. just wondering what others are experiencing


Edit
So.I've had a few devs including myself add this to a quick build. All of us of different sources have the same issue and I would highly recommend not adding it because if someone had to dial out the phone FC when u press call
So imagine having to call 911. And you can't until your switch users... Probably not a good idea.
Its a great find. But that could cause some real problems
 
Last edited:

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
447
plus.google.com
We have implemented this change in our AOSP build on the HTC One X without any issues.

If you could get me a logcat of the crash I can take a look, but I cant think it has to do with multi-user support as it is already baked into JB yet only 1 user is enabled by default.

Are you sure you have only added:
<integer name="config_multiuserMaximumUsers">8</integer>

to your config.xml and did not add anything else?
 
Last edited:

runandhide05

Senior Member
Apr 3, 2011
2,968
2,606
We have implemented this change in our AOSP build on the HTC One X without any issues.

If you could get me a logcat of the crash I can take a look, but I cant think it has to do with multi-user support as it is already baked into JB yet only 1 user is enabled by default.

Are you sure you have only added:
<integer name="config_multiuserMaximumUsers">8</integer>

to your config.xml and did not add anything else?

Correct. And that was the only thing I changed. Keep in mind yes its built into aosp but only for phones. No log cat cause as soon as I ran into that problem I didn't bother to continue and just abandoned the changes. I did add the changes to aosp as well as a custom source and both had the same result as did a few other devs I had try it.
No worry's tho.
 

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
447
plus.google.com
Correct. And that was the only thing I changed. Keep in mind yes its built into aosp but only for phones. No log cat cause as soon as I ran into that problem I didn't bother to continue and just abandoned the changes. I did add the changes to aosp as well as a custom source and both had the same result as did a few other devs I had try it.
No worry's tho.

K if you ever decide to give it another try and run into the same issue just post a logcat and ill be happy to look into it... as said we have this change applied in our aosp build and have no issues with calling or any other crash related to multi-user support
 

runandhide05

Senior Member
Apr 3, 2011
2,968
2,606
K if you ever decide to give it another try and run into the same issue just post a logcat and ill be happy to look into it... as said we have this change applied in our aosp build and have no issues with calling or any other crash related to multi-user support

OK I probably still have the zip laying around, I may through it on to.pull a log.
 

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
447
plus.google.com
nvm i now know what you mean... trying to call with a user other then the device owner FCs... Ill see if that can be fixed

Just looking at Phone package source:
* Returns the singleton instance of the PhoneApp if running as the
* primary user, otherwise null.

So then it crashes because it has no PhoneGlobals for the non-primary user.

Most probably the Phone app does not support multi-users because it would register the broadcast receiver for handling calls multiple times... If this can be fixed easily I cant answer immediatly
 
Last edited:

runandhide05

Senior Member
Apr 3, 2011
2,968
2,606
nvm i now know what you mean... trying to call with a user other then the device owner FCs... Ill see if that can be fixed

Just looking at Phone package source:
* Returns the singleton instance of the PhoneApp if running as the
* primary user, otherwise null.

So then it crashes because it has no PhoneGlobals for the non-primary user.

Most probably the Phone app does not support multi-users because it would register the broadcast receiver for handling calls multiple times... If this can be fixed easily I cant answer immediatly

That's what I was talking about. You only have that problem on none main user and only when u make a call. Ie dial number and press call button.
 

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
447
plus.google.com
Indeed... The phone app does check if its running on the first user:
Code:
        if (UserHandle.myUserId() == 0) {
            // We are running as the primary user, so should bring up the
            // global phone state.
            mPhoneGlobals = new PhoneGlobals(this);
            mPhoneGlobals.onCreate();
        }

But instead of throwing a nice message when opening the dialer it crashes when making a call...
 

Edge-Case

Senior Member
Jul 10, 2013
97
25
Is it possible that this bit of code in system/core/include/private/android_filesystem_config.h might have something to do with it....?
Code:
#define android_id_count \
    (sizeof(android_ids) / sizeof(android_ids[0])) ###EDIT: oops, I had it changed to 10 to see what would happen.

struct fs_path_config {
    unsigned mode;
    unsigned uid;
    unsigned gid;
    const char *prefix;

Edit: Now that I am looking at it, it may just be the creation of an empy array that will get populated later, I may be wrong though, I am just learning C, kinda becoming a Jack-of-all-Trades-Master-of-Puppets.

it also states this closer to the top...
Code:
/* This is the master Users and Groups config for the platform.
** DO NOT EVER RENUMBER.
*/

#define AID_ROOT             0  /* traditional unix root user */

#define AID_SYSTEM        1000  /* system server */

I believe these setting get baked into the ramdisk during a build, a few lines here also cause new unkown files and folders to be created as 0644 root root I believe and results in them not being executable.

I think I am going to have to edit this file quite a bit, I am trying to get glibc based services to start, some do like apache2 and rpcbind, the nfs-common is giving me trouble as well as postgresql, pgsql complains about not being able to open a listening socket, permission denied, so I added a postgres user to this file and some folder and file permissions for it,

Code:
 # ./postgresql start -p 5432
 # ./postgresql status       
Running clusters:

#pg_lsclusters   
Version Cluster   Port Status Owner    Data directory                     Log file
9.1     main      5432 down   postgres /var/lib/postgresql/9.1/main       /var/log/postgresql/postgresql-9.1-main.log

postgres@localhost:/root$ createuser msf_user -P
could not change directory to "/root"
Enter password for new role: 
Enter it again: 
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
createuser: could not connect to database postgres: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?


postgres@localhost:/root$ createdb --owner=msf_user msf_database
could not change directory to "/root"
createdb: could not connect to database postgres: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Been trying for a while to get this to work but I think I need to create a bridge for Androids User, UID, GID , stuff with Debian's whole /etc/passwd /etc/shadow scheme, one that allows both lists to become synchronized adding to eachother what was missing and preventing user creating with identical uid's. I wonder what init's uid is, cuz I think daemon's is set to 1 in /etc/passwd . Not sure.

It would be greate if we had user authentication to use commands like su or even port over sudo for one shot su service of a command like 'cp'.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    I dont know if this has already been posted, but I could not find anything that enabled multi-user support directly.

    It is fairly simple to add multi-user support to your Android 4.2 rom using the device overlay.

    To enable multi-user support you will have to add the following to your config.xml:
    <integer name="config_multiuserMaximumUsers">8</integer>

    This will enable the Users section in Settings to add/remove new users.

    Additionally you will have to modify layout-port/keyguard_host_view.xml, because the layout-port version of keyguard_host_view.xml does not have the multi-user selector.

    You will need to add the following to the layout:
    <include layout="@layout/keyguard_multi_user_selector"/>

    Instead of modifying the layout xml directly you can also just add a modified version of the .xml to your device overlay.

    That will add the user selector to the keyguard/lockscreen.

    The changes can be found here:
    https://github.com/adrian-bl-hox-jb...mmit/ba74d22a7e88f73c0c639ed23aac8617cc9abc9f

    12+-+2
    12+-+1


    In case there is just one user it will not show the user selector in the keyguard/lockscreen.

    Known issues:

    * The dialer only works in the main user and and trying to dial in any other user will result in a crash, because the dialer does not support multi-user yet.
    3
    config.xml is not something you can edit on your phone.

    Its an overlay file that has to be edited when building a custom android 4.2 rom.
    3
    Thanks man for letting us all know
    1
    Cool, thanks for sharing! (Although, I think having more users on an android device is kinda useless, but very nice that its possible)
    1
    This can be usefull when you have others Using your phone then you can set password for main acc and when others ask your phone they can open guest account or other...
    this will get better...

    Sent from my GT-S7500 using xda premium