首页 文章

还原期间备份代理签名不匹配

提问于
浏览
2

[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

我在我的应用程序中使用Helper类实现了 BackupAgent ,因为我只想备份共享首选项文件 .

在应用程序执行 dataChanged() 后,它似乎正在执行's backup calls fine. If I do a ' bmgr run',我在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

edit3:卸载并重新安装一致地在同一个UID下添加我的应用程序的新实例 . 它是来自同一个apk的相同应用程序的相同构建,但它只是在该列表中不断创建自己的新实例 . 这是正确的行为吗?看了 BackupManager 来源后,似乎(如果我真的关心签名,这可能就是它运行正常的原因) .

3 回答

  • 2

    我有同样的问题, bmgr wipe <transport> <package> 没有解决它 .

    帮助我的是 toggle backup 来自 adb shell

    bmgr enable false
    bmgr enable true
    bmgr run
    

    顺便说一句 . 当我是“普通”用户时,它失败并出现此错误:

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

    使用 su 切换到超级用户并传递操作 .

  • 1

    从设置 - >隐私中禁用备份,它会删除所有备份 . 然后启用它,一切都会工作,再次 .

  • 1

    它只是修复了自己 . 所有多个实例都在那里,但它现在有效 . 突然停止抱怨签名不匹配 .

    我想,经验教训是,如果你确定你做得对,就等一下:P

相关问题