设备所有者现在禁用备份服务 [英] Device-Owner now disables the Backup service
问题描述
我的设备所有者应用程序出现问题:在Android 5.1之前,它运行良好,但是现在更新到Android 5.1之后,安装设备所有者应用程序会禁用备份服务。
I've had an issue with my device-owner App : before Android 5.1 it was working nicely, but now after the update to Android 5.1, installing a device-owner App disables the Backup Service.
现在进入备份&重置选项,备份服务显示为灰色,表示:备份服务未激活。这是由您的设备政策设置的
Now in the device settings, when going into the Backup & reset option, the Backup service is greyed out, saying this: Backup service is inactive. This is set by your device policy
我可以找到此源 ...代码不是很长且不易理解,他们使用android.app.backup.IBackupManager来禁用服务...但是提交注释更容易:
I could find this source on the google git repository... The code is not very long and easy to understand, they use android.app.backup.IBackupManager to disable the service... But easier is the commit comment:
设置设备所有者时关闭备份管理器服务
Shutdown backup manager service when device owner is set
这是他们的工作:
import android.app.backup.IBackupManager;
// Shutting down backup manager service permanently.
long ident = Binder.clearCallingIdentity();
try {
IBackupManager ibm = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
ibm.setBackupServiceActive(UserHandle.USER_OWNER, false);
} catch (RemoteException e) {
throw new IllegalStateException("Failed deactivating backup service.", e);
} finally {
Binder.restoreCallingIdentity(ident);
}
哇...这对我的项目来说是一个严重的缺陷!别开玩笑:现在安装设备所有者应用程序时,用户真的不可能备份他的数据吗?
Wow... this makes a serious flaw for my project! No kidding: is it now really impossible for a user to have his data backed up while a device-owner App is installed ?
因此,希望这里有人可以提供信息或经验分享一下?遗憾的是,我对此并不熟悉,但是也许可以通过 reflection 来解决。
So, hopefully someone here could have infos or experience to share about this ? Sadly I'm not familiar with this but maybe with reflection this could be fixed afterwards ?
感谢您阅读!
推荐答案
因为这是Google搜索设备所有者和备份的最佳方式
Because this is a top Google search for device owner and backup
从Android开始O您可以使用 DevicePolicyManager
Starting with Android O you can enable it using the DevicePolicyManager
setBackupServiceEnabled (ComponentName admin, Boolean enabled)
https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html
您可以检查是否通过 isBackupServiceEnabled
启用或设置它
这篇关于设备所有者现在禁用备份服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!