Well, as it turned out, this is not so easy to solve. I finished registering one device, and then pulled out a user file from it. Location of the user file: /data/system/users/0/accounts.db (if the device has several user profiles, the last directory may differ depending on the profile).
I saved this file in my application assets (gzipped, make sure that the extension is not something. Gz, because it is lost during packaging - I did not bother to check why).
First I check if my user exists:
AccountManager mgr = AccountManager.get(this); for (Account acc: mgr.getAccountsByType("com.google")) { if (acc.name.equalsIgnoreCase(" email@gmail.com ")) return; }
If so, I will just skip the step. Otherwise, I will unzip the user file and overwrite the existing one (using su ). Then I also reboot to make sure the changes are logged.
velis source share