BackupAgent.onRestore not called when re-install app BUT called for bmgr restore command

975 views Asked by At

I am testing my custom BackupAgent. The below is my test in Simulator & Eclipse ADT

Test 1 backup & restore using command ---- WORK WELL

  1. adb shell bmgr enabled
  2. adb shell bmgr backup app_package
  3. adb shell bmgr run ---------------------- Run backup (BackupAgent.onBackup called)
  4. On the app, I deleted some data
  5. adb shell bmgr restore app_package ------- Restore data from backup
  6. All is restored including some data I deleted on step 4 ------ WORK WELL

Test 2 Backup / uninstall app / re-install app ---- NOT WORK

  1. adb shell bmgr enabled
  2. adb shell bmgr backup app_package
  3. adb shell bmgr run ----------------------Run backup (BackupAgent.onBackup called)
  4. adb uninstall app_package --------------- Uninstall the app after backup
  5. Debug As / Android Application again ---- Application re-installed BUT NO data is restored ( data backup at step 3)

Updated

  • I found Test 2 worked on Nexus 5 Simulator (API 19 - 4.4.2)
  • BUT Test 2 didn't work on Nexus 4 Simulator (API 16-4.1.2)

Anyone has any ideas? Thank you!

1

There are 1 answers

1
最白目 On

very late, but have you tried setting the transport service to local?

adb shell bmgr list transports

prints

android/com.android.internal.backup.LocalTransport
* com.google.android.gms/.backup.BackupTransportService

change it to the local one

adb shell bmgr transport android/com.android.internal.backup.LocalTransport