I'm quite new in Java and Android dev coming from a more c++ background. I've created a Kiosk/COSU app using this question as guidance. I set the app as device admin using
adb shell dpm set-device-owner ...../.AppAdminReceiver
I'd like to disable the active device owner without factory resetting the device. I've tried programatically using questions like this
and a few others but it doesn't seem to work. The code executes but the app is still the device owner. I've also tried adding android:testOnly="true"
to the AndroidManifest.xml and then using adb shell dpm remove-active-admin ...../.AppAdminReceiver
as seen here but I get the error
java.lang.SecurityException: Attempt to remove non-test admin ComponentInfo{....AppAdminReceiver} 0
.
The method described in the previous link seems to be deprecated in Android Oreo which is the OS I'm building my app for.
How can I remove the device owner in Oreo? I don't mind if it's done via adb or programmatically, as long as I don't need to factory reset the device.