I am executing one test case using robot framework where I have to install an app and make it as device owner and then check if the same app has become a device owner or not. I have searched though Stack Overflow and other search engine results but there, they have mentioned on how to make an app as device owner but not the way how to check if an app is a device owner.
I have used following command to make my app as device owner :
adb shell dpm set-device-owner com.myapp.package/.main.receiver.DeviceAdminReceiver
Now, I wanted to validate whether it is a device owner or now using ADB command.
What is a Device Owner in Android? A Device Owner is an application that runs as a device administrator on your Android 5.0+ device. The Device Owner app can use the programming methods in the DevicePolicyManager class to take control of the configuration, security and other applications on the device.
Device Owner mode gives options to configure policies and customize hardware and software functions for Android devices. You will also need a Mobile Device Management solution like Hexnode to set up, secure and manage Android Enterprise devices for your organization.
The device admin app enforces the desired policies. Here's how it works: A system administrator writes a device admin app that enforces remote/local device security policies. These policies could be hard-coded into the app, or the app could dynamically fetch policies from a third-party server.
adb shell dumpsys device_policy
This command will give you a bunch of policies including the device owner (it's the first policy) with the package name and the corresponding receiver.
To make it easier to check it use adb shell dumpsys device_policy | grep "admin"
adb shell getprop ro.device_owner
returns true
if device owner mode is enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With