7

I really did spend some time researching this and was surprised to not find any answers (this great thread doesn't address this problem at all.... I'm trying to recover from my unfortunate situation: I set up a secondary user on my Nexus 7 4.2.2 and my device is not (yet) rooted. Now I like many others realise that rooting will wipe everything in order to unlock (if I had only read that first), and I'm trying to backup all app data for the secondary user.

When I try to run any adb-based backup on the secondary user, it just hangs and then times out, creating an empty .ab file. The owner's user account backs up just fine.

Any ideas? Is the multi user just too new? I have run into other annoying things with it (no VPN client will connect, can't get into developper settings, can't even change the TIME settings, etc...)

Thanks!

4
  • Is the secondary user still set up after a wipe? Or did I understand wrong that you already performed the wipe/unlock? If you didn't do so already, is USB Debugging enabled when you try connecting to the secondary user? Does adb devices list the Nexus?
    – Izzy
    Commented Apr 4, 2013 at 21:13
  • This is all pre-wipe! Everything is still stock, two users total. Since I cannot enable USB debugging as the secondary user, I enabled it as the owner. When I plug in as the secondary user USB Debugging Connected is displayed on the tablet's status bar and I do see my device listed in adb devices - but when I run adb backup... and it says "unlock your device and confirm..." nothing is ever displayed on the tablet. Again, as owner the message is displayed and the backup works. Commented Apr 4, 2013 at 22:03
  • Have you authorized that device with ADB? 4.2.2 onwards will ask for an RSA confirmation the first time you connect, and that dialog only opens if you are in the main user. It works across all users after authorized though. Commented Apr 7, 2013 at 20:46
  • 1
    I'm not sure what you mean by authorize outside of the typical adb connection... When the owner's profile is active, the backup works fine as stated above: the pre-defined encrypted device password is asked for and when entered allows the backup to complete. Once I switch to the non-owner account, my computer counts it as the device being disconnected and reconnected, and then, as stated, I am never asked for confirmation and adb hangs until it times out leaving an empty .ab file. Commented Apr 8, 2013 at 11:43

3 Answers 3

2

If you are on Android 4.2.2 there is a way of unlocking the bootloader without wiping the device. Use towelroot to root your device. (It works on a neuxs 7 as long as you have a kernel build < Jun 3). Afterwards you can use the following app to unlock the bootloader (It doesn't wipe the device). Then you can use titanium backup to backup everything on your device, even when logged in as a secondary user.

0
1

It would be helpful to be more explicit in what you're doing, like specific adb commands, although I think I'm running into the same issue.

I believe what's happening in your situation is that you're (unintentionally) taking a backup of the Owner user. Since you are in the secondary user profile, you will not see the prompt to start the backup for the Owner user. So adb hangs waiting for a confirmation that you never see.

An important thing to note is that adb sessions always run in the context of the Owner user. So if you are not passing a user id to the backup process, it will be doing a backup of the Owner profile.


So how does one initiate a backup/restore to a non-Owner profile? It helps to know that the adb backup and restore commands end up executing bu on the system. When you run bu help from the adb shell here's the output I get:

sunfish:/ $ bu help
 backup [-user USER_ID] [-f FILE] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared]
        [-all] [-system|-nosystem] [-keyvalue|-nokeyvalue] [PACKAGE...]
     write an archive of the device's data to FILE [default=backup.adb]
     package list optional if -all/-shared are supplied
     -user: user ID for which to perform the operation (default - system user)
     -apk/-noapk: do/don't back up .apk files (default -noapk)
     -obb/-noobb: do/don't back up .obb files (default -noobb)
     -shared|-noshared: do/don't back up shared storage (default -noshared)
     -all: back up all installed applications
     -system|-nosystem: include system apps in -all (default -system)
     -keyvalue|-nokeyvalue: include apps that perform key/value backups.
         (default -nokeyvalue)
 restore [-user USER_ID] FILE       restore device contents from FILE
     -user: user ID for which to perform the operation (default - system user)

Okay great, so apparently there is a -user option. Great! So now I try running a restore for a secondary user from adb and here's what I get:

$ ./platform-tools/adb restore -user 11 <path to android backup>
WARNING: adb restore is deprecated and may be removed in a future release
adb: restore requires an argument

Okay, maybe its finicky and wants the backup file as the first argument. But this results in the same output. I haven't figured out why adb won't take the -user argument.


But there's another option, we can run bu directly from the adb shell. Unfortunately, I've yet to get this to work either, but I get farther along. I first upload the backup to the Owner profile and run bu from the Owner profile using the adb shell. I know of no way to get an adb shell on a non-Owner profile. This shouldn't be a problem though because that's what the -user argument is for. I've tried two scenarios to no avail.

  1. Run bu -user <uid> <backup file> while logged in to the profile of that uid, in this case uid 11. I see no restore confirmation prompt or anything visually happen. Here are relevant logcat lines:
03-14 17:58:29.286 11753 11753 D AndroidRuntime: Calling main entry com.android.commands.bu.Backup
03-14 17:58:29.288 11753 11753 D bu      : Beginning: restore
03-14 17:58:29.289  1493  1731 I BackupManagerService: [UserID:11] Beginning restore...
03-14 17:58:29.289  1493  1731 D BackupManagerService: [UserID:11] Starting restore confirmation UI, token=30388736403-14 17:58:29.289  1493  1731 I ActivityTaskManager: START u0 {act=fullrest flg=0x20000000 cmp=com.android.backupconfirm/.BackupRestoreConfirmation (has extras)} from uid 1000
03-14 17:58:29.289  1493  1731 W ActivityTaskManager: startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent {act=fullrest flg=0x20800000 cmp=com.android.backupconfirm/.BackupRestoreConfirmation (has extras) }
03-14 17:58:29.293  1493  1731 D BackupManagerService: [UserID:11] Waiting for restore completion...
03-14 17:59:29.388  1493 25093 I BackupManagerService: Full backup/restore timedout waiting for user confirmation
03-14 17:59:29.388  1493  1731 I BackupManagerService: [UserID:11] adb restore processing complete.
03-14 17:59:29.388 11753 11753 D bu      : Finished.

As can be seen, the BackupManagerService knows that I'm requesting a restore of uid 11. Also it says its starting the confirmation UI, even though I see nothing come up. Eventually the requests times out.

  1. Run bu -user <uid> <backup file> while logged in to the Owner profile. Here are relevant logcat lines:
03-14 18:00:39.448 11948 11948 D AndroidRuntime: Calling main entry com.android.commands.bu.Backup
03-14 18:00:39.450 11948 11948 D bu      : Beginning: restore
03-14 18:00:39.451  1493  2786 I BackupManagerService: [UserID:11] Beginning restore...
03-14 18:00:39.451  1493  2786 D BackupManagerService: [UserID:11] Starting restore confirmation UI, token=606614021
03-14 18:00:39.451  1493  2786 I ActivityTaskManager: START u0 {act=fullrest flg=0x20000000 cmp=com.android.backupconfirm/.BackupRestoreConfirmation (has extras)} from uid 1000
03-14 18:00:39.451  1493  2786 W ActivityTaskManager: startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=fullrest flg=0x20800000 cmp=com.android.backupconfirm/.BackupRestoreConfirmation (has extras) }
03-14 18:00:39.459  1493  1994 W ActivityTaskManager: Tried to set launchTime (0) < mLastActivityLaunchTime (22366588)
03-14 18:00:39.462  1493  2786 D BackupManagerService: [UserID:11] Waiting for restore completion...
03-14 18:00:39.572  1493  1757 I ActivityTaskManager: Displayed com.android.backupconfirm/.BackupRestoreConfirmation: +112ms
03-14 18:00:43.431  1493  5565 D BackupManagerService: [UserID:0] acknowledgeAdbBackupOrRestore : token=606614021 allow=true
03-14 18:00:43.432  1493  5565 W BackupManagerService: [UserID:0] Attempted to ack full backup/restore with invalid token
03-14 18:00:46.213  1493  2063 D InputDispatcher: Waiting to send key to Window{200410c u0 com.android.backupconfirm/com.android.backupconfirm.BackupRestoreConfirmation} because there are unprocessed events that may cause focus to change
03-14 18:01:39.563  1493 25093 I BackupManagerService: Full backup/restore timed out waiting for user confirmation
03-14 18:01:39.563  1493  2786 I BackupManagerService: [UserID:11] adb restore processing complete.
03-14 18:01:39.564 11948 11948 D bu      : Finished.

As in the first attempt, we see that the BackupManagerService is trying to do a restore for uid 11. It starts the confirmation UI, which does pop up. I then confirm the restore. But then we see that its uid 0 which confirms the restore and I believe that's why the resulting token is invalid. Makes sense, why should one profile be able to cnofirm the backup/restore of another? (make a little more sense for the Owner profile to be able to do that)

So I think I've hit a roadblock here. I'm not sure how to get the confirmation UI to run in the correct user. I suspect this has (still!) not been tested by the android community, though why have a -user option at all?


Here are some other log messages that may be clues to a way forward:

03-14 18:00:28.422  1493  5597 W WindowManager: Attempted to set replacing window on app token with no content Token{b3c5879 ActivityRecord{23cb9be u0 com.android.backupconfirm/.BackupRestoreConfirmation t1100006}}
03-14 18:00:28.610  1493  2786 I ActivityTaskManager: Activity reported stop, but no longer stopping: ActivityRecord{23cb9be u0 com.android.backupconfirm/.BackupRestoreConfirmation t1100006}
03-14 18:00:37.042  1493  2063 D InputDispatcher: Waiting to send key to Window{6f7d966 u0 com.android.backupconfirm/com.android.backupconfirm.BackupRestoreConfirmation} because there are unprocessed events that may cause focus to change

1
  • Did you check whether backupmanager service was running for your user 11? What did dumpsys backup users report? In my Android, backupmamager service was not running for my secondary user account even when such user account was active in the device. Hence, -user didn't work IMO.
    – Firelord
    Commented Jul 5, 2021 at 8:26
0

I don't think there is a way short of finding a root enabling exploit. adb backup -apk -shared -all only backs up for user 0 for both /data/user/ and /storage/emulated/ (For non devices without expandable storage). No luck with 4.4 either.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .