Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove set-device-owner in Android DPM?

I have made an app device owner using ADB, by following this link : How to make my app a device owner?

but now, I'm not able to revert this.

In the device administration Tab, this option is disabled. Not able to change the value of this app.

like image 550
KKSINGLA Avatar asked Mar 06 '18 10:03

KKSINGLA


People also ask

How do I force deactivate a device administrator?

Go to your phone's settings and then click on “Security.” You'll see “Device Administration” as a security category. Click on it to see a list of apps that have been given administrator privileges. Click the app you want to remove and confirm that you want to deactivate administrator privileges.

What is DPM in Android?

To help you develop and test your device management (or other enterprise) apps, you can issue commands to the device policy manager (dpm) tool. Use the tool to control the active admin app or change a policy's status data on the device.


2 Answers

By specifying the android:testOnly="true" attribute in the AndroidManifest.xml it will be possible to uninstall the app or remove admin with:

adb shell dpm remove-active-admin package.name/MyDeviceAdminReceiver

But on a production device, this attribute should not be included and the app will be a non-test admin. From that point, it will not be possible to remove it or uninstall the application without wipe/factory reset.

Thankfully, updates can be done when the app is signed with the same key and when the version code is equal or greater:

adb install -r path/to/kiosk.apk

If you would like to get rid of admin and application on a production device programatically you have to reinstall it with a few new changes. Firstly you can wipe data programmatically if you have permission <wipe-data \> in device_admin_receiver.xml with:

devicePolicyManager.wipeData(DevicePolicyManager.WIPE_RESET_PROTECTION_DATA)

If you don’t have this permission new version should not start LockTask and remove its package from default Home app list with:

devicePolicyManager.clearPackagePersistentPreferredActivities(adminComponentName, packageName)

You could then manually go to Settings to perform a wipe/factory reset.

Information found on https://snow.dog/blog/kiosk-mode-android

like image 92
nilsi Avatar answered Oct 08 '22 03:10

nilsi


This is crazy. I have been able to remove Device Admin (uninstall or disable) on my S7 and S5 forever. I don't understand why I cannot disable/remove a Package Disabler app as is malfunctioning on my S10 w/ OS 11.

Surely there is a way to remove it via ADB? I added it via ADB.

I wish people would write complete instructions WITH warnings that you will not be able to remove it after install without factory reset! (all my apps + data lost!)

Hmm... Please provide a solution for stock non-root users :D Thanks!

like image 32
do loop Avatar answered Oct 08 '22 02:10

do loop