[编辑] 从我添加的所有信息来看,这似乎是由于我的应用程序将自身注册为同一 UID 下的新应用程序,尽管在同一个 apk 中是相同的构建。任何从哪里开始修复的想法将不胜感激
我已经BackupAgent
使用 Helper 类在我的应用程序中实现了一个,因为我只想备份一个共享的首选项文件。
它似乎正在做它的备份调用。如果我在应用程序执行 a 之后执行“bmgr run” dataChanged()
,我会在 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): awaiting 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
但是,即使立即完成,执行“bmgr restore”操作也会在 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
恢复的控制台输出是:
restoreStarting: 2 packages
onUpdate: 0 = uk.co.randomicon.rstb
restoreFinished: 0
done
有任何想法吗?这显然是相同的版本和签名,因为我没有卸载/擦除/任何东西。我都注册了备份服务,并且密钥正确,等等。
编辑:它似乎作为调试密钥签名的构建工作正常,但在导出的、混淆的、zipaligned 发布密钥签名的 apk 上失败。如果我试图将数据从调试版本恢复到发布版本中,那对我来说是有意义的,但我不是。
edit2:尝试更改助手名称等,但我仍然得到相同的行为。调试密钥签名的 apk 完美运行,可以备份、卸载、重新安装并自动恢复。每次发布密钥签名的 apk 都会这样做。尽管只有一个内部函数调用,但我仍然有点担心使用不同 @ 号码的重复备份调用。但是,调试器也这样做,因此不能完全如此。
dumpsys 备份的输出显示我的包四次...
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
编辑3:卸载和重新安装始终在同一UID下添加我的应用程序的新实例。它是来自同一个 apk 的同一个应用程序的相同版本,但它只是在该列表中不断创建自己的新实例。这是正确的行为吗?查看BackupManager
源代码后,似乎(如果我没看错的话)在调试模式下,管理器并不真正关心签名,这可能就是它运行正常的原因。