From 896cd6592d4301381932011b8884852028db91c0 Mon Sep 17 00:00:00 2001 From: Jonas Lochmann Date: Mon, 13 Feb 2023 01:00:00 +0100 Subject: [PATCH] Fix AndroidDeviceOwnerApi.getDelegations --- .../integration/platform/android/AndroidDeviceOwnerApi.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/timelimit/android/integration/platform/android/AndroidDeviceOwnerApi.kt b/app/src/main/java/io/timelimit/android/integration/platform/android/AndroidDeviceOwnerApi.kt index 5599b5e..58fc263 100644 --- a/app/src/main/java/io/timelimit/android/integration/platform/android/AndroidDeviceOwnerApi.kt +++ b/app/src/main/java/io/timelimit/android/integration/platform/android/AndroidDeviceOwnerApi.kt @@ -87,9 +87,9 @@ class AndroidDeviceOwnerApi( if (VERSION.SDK_INT <= VERSION_CODES.O) throw IllegalStateException() return delegationList.map { (scope, delegation) -> - devicePolicyManager.getDelegatedScopes(componentName, scope).map { packageName -> + devicePolicyManager.getDelegatePackages(componentName, scope)?.map { packageName -> Pair(packageName, delegation) - } + } ?: emptyList() }.flatten().groupBy { it.first }.mapValues { entry -> entry.value.map { it.second } }