自从新的ADT预览版本(版本21)以来,他们有一个新的lint警告,告诉我清单文件(在应用程序标签中)的下一件事:
应该显式设置android:allowBackup为true或false(默认为true,这可能对应用程序的数据有一些安全隐患)
在官方网站上,他们写道:
一些新的检查:你必须明确决定你的应用程序是否允许备份,以及标签检查。有一个新的命令行标志用于设置库路径。对编辑时的增量绒线分析进行了许多改进。
这个警告是什么?什么是备份功能,如何使用它?
另外,为什么警告告诉我它有安全隐患?禁用此功能的缺点和优点是什么?
清单的备份有两个概念:
"android:allowBackup"允许通过adb进行备份和恢复,如下所示:
是否允许应用程序参与备份和
恢复基础设施。如果此属性设置为false,则不备份
或应用程序的恢复将永远被执行,即使由
全系统备份,否则会导致所有应用程序数据
通过adb拯救。此属性的默认值为true。
这被认为是一个安全问题,因为人们可以通过ADB备份应用程序,然后将应用程序的私人数据保存到他们的PC中。
然而,我认为这不是一个问题,因为大多数用户不知道什么是adb,如果他们知道,他们也会知道如何根设备。ADB功能只有在设备启用调试功能时才能工作,这需要用户启用它。
因此,只有将设备连接到PC并启用调试功能的用户才会受到影响。如果他们的PC上有一个使用ADB工具的恶意应用程序,这可能会有问题,因为应用程序可以读取私有存储数据。
我认为谷歌应该添加一个默认禁用的功能,在开发人员类别中,允许通过ADB备份和恢复应用程序。
“android:backupAgent”允许使用云的备份和恢复功能,如下所示:
实现应用程序备份代理的类的名称,
BackupAgent的子类。属性值应该是full
限定类名(例如,“com.example.project.MyBackupAgent”)。
但是,作为一种简写,如果名称的第一个字符是
周期(例如,“.MyBackupAgent”),它被追加到包中
元素中指定的名称。没有违约。的
必须指定名称。
这不是一个安全问题。
对于这个lint警告,就像所有其他lint警告一样,请注意,您可以得到一个更完整的解释,而不仅仅是在一行错误消息中;你不需要在网上搜索更多信息。
If you are using lint via Eclipse, either open the lint warnings view, where you can select the lint error and see a longer explanation, or invoke the quick fix (Ctrl-1) on the error line, and one of the suggestions is "Explain this issue", which will also pop up a fuller explanation. If you are not using Eclipse, you can generate an HTML report from lint (lint --html <filename>) which includes full explanations next to the warnings, or you can ask lint to explain a particular issue. For example, the issue related to allowBackup has the id AllowBackup (shown at the end of the error message), so the fuller explanation is:
$ ./lint --show AllowBackup
AllowBackup
-----------
Summary: Ensure that allowBackup is explicitly set in the application's
manifest
Priority: 3 / 10
Severity: Warning
Category: Security
allowBackup属性决定应用程序的数据是否可以备份和恢复,如本文所述。
By default, this flag is set to true. When this flag is set to true, application data can be backed up and restored by the user using adb backup and adb restore.
This may have security consequences for an application. adb backup allows users who have enabled USB debugging to copy application data off of the device. Once backed up, all application data can be read by the user. adb restore allows creation of application data from a source specified by the user. Following a restore, applications should not assume that the data, file permissions, and directory permissions were created by the application itself.
Setting allowBackup="false" opts an application out of both backup and restore.
To fix this warning, decide whether your application should support backup and explicitly set android:allowBackup=(true|false)
点击这里获取更多信息
对于这个lint警告,就像所有其他lint警告一样,请注意,您可以得到一个更完整的解释,而不仅仅是在一行错误消息中;你不需要在网上搜索更多信息。
If you are using lint via Eclipse, either open the lint warnings view, where you can select the lint error and see a longer explanation, or invoke the quick fix (Ctrl-1) on the error line, and one of the suggestions is "Explain this issue", which will also pop up a fuller explanation. If you are not using Eclipse, you can generate an HTML report from lint (lint --html <filename>) which includes full explanations next to the warnings, or you can ask lint to explain a particular issue. For example, the issue related to allowBackup has the id AllowBackup (shown at the end of the error message), so the fuller explanation is:
$ ./lint --show AllowBackup
AllowBackup
-----------
Summary: Ensure that allowBackup is explicitly set in the application's
manifest
Priority: 3 / 10
Severity: Warning
Category: Security
allowBackup属性决定应用程序的数据是否可以备份和恢复,如本文所述。
By default, this flag is set to true. When this flag is set to true, application data can be backed up and restored by the user using adb backup and adb restore.
This may have security consequences for an application. adb backup allows users who have enabled USB debugging to copy application data off of the device. Once backed up, all application data can be read by the user. adb restore allows creation of application data from a source specified by the user. Following a restore, applications should not assume that the data, file permissions, and directory permissions were created by the application itself.
Setting allowBackup="false" opts an application out of both backup and restore.
To fix this warning, decide whether your application should support backup and explicitly set android:allowBackup=(true|false)
点击这里获取更多信息