使用Android服务备份(云备份)时不清楚SecurityException [英] Unclear SecurityException when using Android Service Backup (Cloud Backup)

查看:94
本文介绍了使用Android服务备份(云备份)时不清楚SecurityException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用我的应用程序,其中包含 Android备份服务和我自己的BackupAgent,位于 Android模拟器上.但是,尽管有AndroidManifest.xml中的权限,但备份不起作用.

I try to use my application, which contains usage of Android Backup Service with my own BackupAgent, on Android Emulator. But backup doesn't work, despite of permission written in AndroidManifest.xml.

权限:< uses-permission android:name ="android.permission.BACKUP"/>

Permission: <uses-permission android:name="android.permission.BACKUP"/>

警告日志::09-17 09:05:58.553:WARN/PackageManager(73):未授予对android.permission.BACKUP进行打包my.package的权限(protectionLevel = 3标志= 0x1be46 )

Warning in log: 09-17 09:05:58.553: WARN/PackageManager(73): Not granting permission android.permission.BACKUP to package my.package (protectionLevel=3 flags=0x1be46)

日志异常(当我尝试调用

Exception in log (when I try to call requestRestore()): java.lang.SecurityException: getCurrentTransport: Neither user 10040 nor current process has android.permission.BACKUP.

我的代码有什么问题?

UPD:我的清单

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.package">

<uses-permission android:name="android.permission.BACKUP"/>

<application android:name="my.package.MyApplicationName" android:backupAgent="my.package.MyBackupAgent">

<meta-data android:name="com.google.android.backup.api_key" android:value="my_backup_api_key">

</application>

</manifest>

推荐答案

因此,您应该将其从清单中删除. Android备份服务 不需要不需要其他权限.

So, you should remove it from your Manifest. Android Backup Service doesn't require additional permissions.

但是,可以使用指定的权限,但只能由系统"应用程序使用,因为它需要PROTECTION_SIGNATUREPROTECTION_SIGNATURE_OR_SYSTEM

However, specified permission can be used, but only by "system" applications, because it requires PROTECTION_SIGNATURE or PROTECTION_SIGNATURE_OR_SYSTEM level of permissions.

仅当调用方法

Such permission needed only when calling method BackupManager.dataChanged(String packageName), but usually this method is not needed when implementing Backup Service.

这篇关于使用Android服务备份(云备份)时不清楚SecurityException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆