Search code examples
androidadbrobotframework

How to check if an Android App is a device owner?


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.


Solution

  • 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"