恢复期间备份代理签名不匹配

发布于 2024-11-16 01:10:02 字数 7907 浏览 4 评论 0原文

[编辑] 从我添加的所有信息来看,这似乎是由于我的应用程序将自身注册为同一 UID 下的新应用程序造成的,尽管它是同一 apk 中的相同版本。任何从哪里开始修复这个问题的想法将不胜感激

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

它的备份呼叫似乎做得很好。如果我在应用执行 dataChanged() 后执行“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

有什么想法吗?这显然是相同的版本和签名,因为我没有卸载/擦除/任何东西。我都注册了备份服务,并且密钥正确,等等。

编辑:看起来它作为调试密钥签名构建工作正常,但在导出的、模糊的、压缩对齐的发布密钥签名的 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 源代码后,似乎(如果我没读错的话)在调试模式下,管理器并不真正关心签名,这可能就是它运行正常的原因。

[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): 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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

自此以后,行同陌路 2024-11-23 01:10:02

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

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

蓝海 2024-11-23 01:10:02

我遇到了同样的问题,并且 bmgrWipe 没有解决。

对我有帮助的是从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 切换到超级用户并通过操作。

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.

探春 2024-11-23 01:10:02

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

我想,吸取的教训是,如果您确定自己做对了,请等待:P

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文