I try to suspend some apps on a fully managed device (Android 7.1.2) using the setPackagesSuspended()
method (link to the reference). According to the documentation, the first parameter of the method is a ComponentName
:
ComponentName: The name of the admin component to check, or null if the caller is a package access delegate. This value must never be null.
Despite the documentation a bit paradoxal, I set the value to null, since my app has the special delegation from the Android Device Policy:
"applications": [
{
"packageName": "our.business.app",
"installType": "REQUIRED_FOR_SETUP",
"defaultPermissionPolicy": "GRANT",
"managedConfiguration": {
xxx
},
"delegatedScopes": [
"ENABLE_SYSTEM_APP",
"PACKAGE_ACCESS"
],
"accessibleTrackIds": [
"4699927753xxx"
]
}
],
Unfortunately, I get an exception when I call the method:
NullPointerException: ComponentName is null
Besides that, I don't know if this is related, but I have some weird logs from the Android Device Policy:
2020-01-22 15:38:27.835 7741-11774/? I/clouddpc: [CloudDpsClientImpl] Install app request, packagesToInstall: [our.business.app], packagesToUninstall: []
2020-01-22 15:38:33.217 7741-11774/? I/clouddpc: [PlaySyncUtils] Install error. Package name: [our.business.app]. Reason [TRANSIENT_ERROR]. Delay before retry: [0].
2020-01-22 15:38:33.219 7741-11780/? I/clouddpc: [PlaySyncUtils] Install error. Package name: [our.business.app]. Reason [TRANSIENT_ERROR]. Delay before retry: [0].
Thanks in advance for your help.
The setPackagesSuspended()
has been added in API level 24 (ie Android 7.0), which should work on my device. BUT the DELEGATION_PACKAGE_ACCESS
has been added in API 26 (ie Android 8.0). That's why it doesn't work on my device.
It works well on a device with API level 27.