Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 669
Humble_PrOgRaMeR Avatar asked Jun 30 '17 10:06

Humble_PrOgRaMeR


People also ask

Is device owner an app?

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.

What is Android device owner mode?

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.

What is device admin apps?

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.


2 Answers

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"

like image 74
Mário Gago Avatar answered Oct 19 '22 07:10

Mário Gago


adb shell getprop ro.device_owner

returns true if device owner mode is enabled.

like image 38
fcarpen Avatar answered Oct 19 '22 07:10

fcarpen