After properly adding it as an admin app, other DPM functions work fine (such as dpm.lockNow()).
I can also wipe the data on android 10. The issues occur on android 14,13.
fun wipeData() {
var flags = 0
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
flags = flags.or(DevicePolicyManager.WIPE_SILENTLY)
if (prefs.isWipeEmbeddedSim && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
flags = flags.or(DevicePolicyManager.WIPE_EUICC)
dpm?.wipeData(flags)
}
Faced with following error.
java.lang.SecurityException : User 0 can not be removed .