BackupAgent.onRestore is not called when you reinstall the application. BUT is invoked for the bmgr recovery command.

I am testing my custom BackupAgent. Below is my test in Simulator and Eclipse ADT

Verify 1 backup and restore using the ---- WORK WELL command

  • Enabled bmgr shell adb
  • adb shell bmgr backup app_package
  • Launch bmgr adb shell ---------------------- Start backup (called BackupAgent.onBackup)
  • In the application, I deleted some data
  • adb shell bmgr restore app_package ------- Restore data from backup
  • Everything is restored, including some data that I deleted in step 4 ------ WORK WELL

Test 2 Backing up / uninstalling the application / reinstalling the application ---- DOES NOT WORK

  • Enabled bmgr shell adb
  • adb shell bmgr backup app_package
  • Launch bmgr adb shell ---------------------- Start backup (called BackupAgent.onBackup)
  • adb uninstall app_package --------------- Uninstall the application after backup
  • Debugging As / Android Application again ---- The application is reinstalled BUT BUT the data is restored (backing up data in step 3)

Update

  • I found that Test 2 was working on a Nexus 5 simulator (API 19 - 4.4.2)
  • BUT Test 2 did not work on Nexus 4 simulator (API 16-4.1.2)

Does anyone have any ideas? Thanks!

+6
source share
1 answer

very late, but did you try to install the transport service on a local one?

bmgr command list for adb shell

prints

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

change it to local

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

+1
source

Source: https://habr.com/ru/post/984657/


All Articles