From c0ea7962cd92b463fd367bd5ec723cf239485897 Mon Sep 17 00:00:00 2001 From: Jonas Lochmann Date: Mon, 15 Apr 2024 02:00:00 +0200 Subject: [PATCH] Disable AndroidDeviceOwnerApi for store builds --- .../integration/platform/android/AndroidDeviceOwnerApi.kt | 4 ++++ 1 file changed, 4 insertions(+) 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 ef8e12b..34a5814 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 @@ -71,6 +71,7 @@ class AndroidDeviceOwnerApi( override val delegations: List = delegationList.map { it.second } override fun setDelegations(packageName: String, scopes: List) { + if (BuildConfig.storeCompilant) throw IllegalStateException() if (VERSION.SDK_INT <= VERSION_CODES.O) throw IllegalStateException() val resolvedScopes = scopes.map { scope -> @@ -89,6 +90,7 @@ class AndroidDeviceOwnerApi( } override fun getDelegations(): Map> { + if (BuildConfig.storeCompilant) return emptyMap() if (VERSION.SDK_INT <= VERSION_CODES.O) throw IllegalStateException() return delegationList.map { (scope, delegation) -> @@ -109,6 +111,7 @@ class AndroidDeviceOwnerApi( } override fun transferOwnership(packageName: String, dryRun: Boolean) { + if (BuildConfig.storeCompilant) throw IllegalStateException() if (VERSION.SDK_INT < VERSION_CODES.P) throw IllegalStateException() if (!devicePolicyManager.isDeviceOwnerApp(componentName.packageName)) throw SecurityException() @@ -127,6 +130,7 @@ class AndroidDeviceOwnerApi( } override fun grantLocationAccess(): Boolean { + if (BuildConfig.storeCompilant) return false if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP) return false if (!devicePolicyManager.isDeviceOwnerApp(componentName.packageName)) return false