hide some entries if permission is not enough

This commit is contained in:
BinTianqi
2024-06-04 13:47:35 +08:00
parent 45317e3975
commit c8e7b23cd8
9 changed files with 56 additions and 70 deletions

View File

@@ -1,7 +1,9 @@
package com.bintianqi.owndroid.dpm
import android.app.admin.DevicePolicyManager
import android.content.ComponentName
import android.content.Intent
import android.os.Build.VERSION
import androidx.activity.result.ActivityResultLauncher
import kotlinx.coroutines.flow.MutableStateFlow
@@ -16,3 +18,7 @@ fun isDeviceOwner(dpm: DevicePolicyManager): Boolean {
fun isProfileOwner(dpm: DevicePolicyManager): Boolean {
return dpm.isProfileOwnerApp("com.bintianqi.owndroid")
}
fun DevicePolicyManager.isOrgProfile(receiver: ComponentName):Boolean {
return VERSION.SDK_INT >= 30 && isProfileOwner(this) && isManagedProfile(receiver) && isOrganizationOwnedDeviceWithManagedProfile
}