Multi-user Android

Submitted by olaf on 2013-11-04

I always wanted to have a multi-user Android on my tablet. But I have Android 3.2 and the only update available is Android 4.0, which additionally has some reports about performance and stability issues.

So, I went on and investigated, if this is possible with a stock Android system. I already rooted my tablet early on, installed busybox (binaries at /downloads/binaries), and so I could poke and play with the system in every aspect. Doing so is very easy, just attach it to a USB port and start an adb shell

adb shell

The primary idea was to have a /data partition for every user. As it turns out, you only need a separate /data/data subdirectory. After looking into /init.rc, my first test was to move /data/data away and reboot to see, if the system recreates everything

mkdir /data/home
mv /data/data /data/home
reboot

This works pretty well. After reboot all the data was gone, of course (safely put away into /data/home/data), and everything reinitialized. The next step was to check, if a symbolic link into my new home directory would work as a means to switch between different users

mv /data/data /data/home/data.recreated
ln -s /data/home/data /data/data
reboot

Unfortunately, this doesn’t work and results in an endless loop of launcher crashes. Moving the original data directory back, resolves the crashes immediately and the system comes back with all data intact

mv /data/home/data /data

In order to change users, it seems, I have to move directories around. With

mv /data/data /data/home
mv /data/home/data.recreated /data/data
reboot

I can switch between two or more configurations. But rebooting for every user switch is very cumbersome.

The process zygote is the parent process for all the app and UI processes. When you kill zygote, all currently running apps are terminated too. Then the UI is restarted after a while. This is a lot shorter than a full reboot

ps | grep zygote
root      6165  1     422904 24744 c00dea70 afb0c584 S zygote
kill 6165

As a final step, I must put all these steps together into an app, because attaching the tablet to USB and start a shell to switch users isn’t really convenient.

Although you can have multiple configurations and app data with this method, there is at least one drawback. You still have only one account on your tablet. If you want to have separate accounts as well, you must duplicate /data/system too.

So, to have fully separate accounts, a complete duplicate of /data might be still necessary, after all.

Post a comment

All comments are held for moderation; Markdown and basic HTML formatting accepted. If you want to stay anonymous, leave name, e-mail and website empty.