开发者

Backup Agent signature mismatch during restore

[Edit] From all the information I've added it seems likely that this is caused by my app registering itself as a new app under the same UID despite being the same build in the same apk. Any ideas where to start fixing that would be greatly appreciated

I have implemented a BackupAgent in my app using the Helper class as I only want to back up a shared preferences file.

It seems to be doing it's backup calls fine. If I do a 'bmgr run' after the app does a dataChanged(), I get the following in logcat:

06-17 09:58:41.618: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d66190 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.618: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d66190 uk.co.randomicon.rstb}
06-17 09:58:41.628: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@408864e8
06-17 09:58:41.628: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40b2f328
06-17 09:58:41.638: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d75cc0 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.648: DEBUG/BackupManagerService(303): awai开发者_如何转开发ting agent for ApplicationInfo{40d75cc0 uk.co.randomicon.rstb}
06-17 09:58:41.648: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@40708660
06-17 09:58:41.648: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40b08e50
06-17 09:58:41.668: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d6b420 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.668: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d6b420 uk.co.randomicon.rstb}
06-17 09:58:41.668: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@40789930
06-17 09:58:41.668: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40ae3b70
06-17 09:58:41.688: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d92b38 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.688: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d92b38 uk.co.randomicon.rstb}
06-17 09:58:41.688: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@408521c0
06-17 09:58:41.688: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40acfd20
06-17 09:58:41.708: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40dd4c50 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.708: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40dd4c50 uk.co.randomicon.rstb}
06-17 09:58:41.708: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40ababb0
06-17 09:58:41.718: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@40887ee0
06-17 09:58:41.728: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d725b0 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.728: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d725b0 uk.co.randomicon.rstb}
06-17 09:58:41.728: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40aaa058
06-17 09:58:41.728: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@40835bd0
06-17 09:58:41.738: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40da2cd8 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.748: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40da2cd8 uk.co.randomicon.rstb}
06-17 09:58:41.748: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@408769b8
06-17 09:58:41.748: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40a99a20
06-17 09:58:41.768: DEBUG/PerformBackupThread(303): starting agent for backup of BackupRequest{app=ApplicationInfo{40d451b8 uk.co.randomicon.rstb} full=false}
06-17 09:58:41.768: DEBUG/BackupManagerService(303): awaiting agent for ApplicationInfo{40d451b8 uk.co.randomicon.rstb}
06-17 09:58:41.768: DEBUG/BackupHelperDispatcher(6720): handling existing helper 'rstb_prefs' android.app.backup.SharedPreferencesBackupHelper@40708440
06-17 09:58:41.768: DEBUG/BackupManagerService(303): agentConnected pkg=uk.co.randomicon.rstb agent=android.os.BinderProxy@40a89c58

However, even if done immediately, doing a 'bmgr restore' action results in the following in logcat:

06-17 09:38:36.002: DEBUG/BackupManagerService(303): MSG_RUN_RESTORE observer=android.app.backup.IRestoreObserver$Stub$Proxy@40c0ec50
06-17 09:38:36.682: WARN/BackupManagerService(303): Signature mismatch restoring uk.co.randomicon.rstb

The console output for the restore is:

restoreStarting: 2 packages
onUpdate: 0 = uk.co.randomicon.rstb
restoreFinished: 0
done

Any ideas? It's obviously the same version and signature, as I've not uninstalled/wiped/anything. I'm all signed up for the backup service, and the key is in correctly, etc.

edit: It seems it works fine as a debug key signed build, but fails like this on an exported, obfuscated, zipaligned release key signed apk. That would make sense to me if I was trying to restore data from the debug build into the release build, but I'm not.

edit2: Have tried changing the helper names, etc and I still get the same behaviour. Debug key signed apk works perfectly, can backup, uninstall, reinstall and it restores automatically. Release key signed apk does this every time. I'm still a little concerned at the repeated backup calls with different @ numbers despite only one internal function call. The debug one does this too, however, so it can't entirely be that.

Output of dumpsys backup shows my package four times...

Backup Manager is enabled / provisioned / not pending init
Auto-restore is enabled
Last backup pass: 1308330167956 (now = 1308330359754)
  next scheduled: 1308333767956
Available transports:
  * com.google.android.backup/.BackupTransportService
       com.android.inputmethod.latin - 112 state bytes
       com.android.browser - 20 state bytes
       com.android.providers.userdictionary - 8 state bytes
       com.android.vending - 0 state bytes
       android - 172 state bytes
       com.zegoggles.smssync - 100 state bytes
       com.smartandroidapps.audiowidgetpro - 416 state bytes
       org.connectbot - 260 state bytes
       net.cachapa.libra - 96 state bytes
       com.icenta.sudoku.ui - 52 state bytes
       com.android.providers.settings - 36 state bytes
       @pm@ - 378 state bytes
       uk.co.randomicon.rstb - 164 state bytes
    android/com.android.internal.backup.LocalTransport
Pending init: 0
Participants:
  uid: 1000
    com.android.providers.settings
    android
  uid: 10000
    com.android.providers.userdictionary
  uid: 10002
    com.android.browser
  uid: 10022
    com.android.inputmethod.latin
  uid: 10045
    com.android.vending
  uid: 10050
    uk.co.randomicon.rstb
    uk.co.randomicon.rstb
    uk.co.randomicon.rstb
    uk.co.randomicon.rstb
  uid: 10058
    com.zegoggles.smssync
  uid: 10063
    org.connectbot
  uid: 10084
    net.cachapa.libra
  uid: 10094
    com.smartandroidapps.audiowidgetpro
  uid: 10111
    com.icenta.sudoku.ui
Ancestral packages: 8
    com.android.browser
    com.zegoggles.smssync
    org.connectbot
    android
    com.android.vending
    com.android.providers.userdictionary
    com.android.inputmethod.latin
    com.android.providers.settings
Ever backed up: 12
    org.connectbot
    com.zegoggles.smssync
    com.android.browser
    com.icenta.sudoku.ui
    com.smartandroidapps.audiowidgetpro
    com.android.vending
    android
    net.cachapa.libra
    uk.co.randomicon.rstb
    com.android.providers.userdictionary
    com.android.inputmethod.latin
    com.android.providers.settings
Pending backup: 0

edit3: Uninstalling and reinstalling consistently keeps adding new instances of my app under the same UID. It's the same build of the same app from the same apk, but it just keeps making new instances of itself in that list. Is that correct behaviour? Having looked over the BackupManager source, it would seem (if I've read it right) that in debug mode the manager doesn't really care about signatures, which is probably why it runs okay then.


Disable Backup from settings -> privacy, it deletes all backups. Then enable it and everything will work, again.


I had the same problem and bmgr wipe <transport> <package> did not solve it.

What helped me was to toggle backup from adb shell:

bmgr enable false
bmgr enable true
bmgr run

Btw. while I was "normal" user it failed with this error:

java.lang.SecurityException: uid 2000 does not have android.permission.UPDATE_APP_OPS_STATS.

Switched to superuser with su and operations passed.


It just fixed itself. All the multiple instances are there, but it works now. Just suddenly stopped complaining about signature mismatches.

Lesson learnt, I guess, is if you're sure you've done it right, just wait :P

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜