Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
975 views
in Technique[技术] by (71.8m points)

adb - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...