Disable a device owner app from android terminal - android

well, my problem is: I have an application which is set as the device owner of a device (my tablet in this case). I did it from the terminal in Ubuntu, connecting the tablet to my PC and executting this line in the adb shell:
dpm set-device-owner my.app.package/my.app.route.MyAdmin
So, I want to disable the device owner app without restoring the device, just executing a line similar to the last one. Me and my coworker have been researching for a long time and we've never found anything about this, so I would like to know if it is possible or not, and if it is, how to do that.
Thanks!

you can use the following ADB shell command to remove device owner
adb shell dpm remove-active-admin com.example.app/.AdminReceiver
Disables an active admin, the admin must have declared android:testOnly in the application in its manifest. This will also remove device owner and profile owners

You can use DevicePolicyManager.clearDeviceOwnerApp() from your device owner app.
However note that this method has been deprecated in Android Oreo, you can still use it on Oreo devices but it might be removed in future Android versions.

Related

How to make my app device owner through code

I want to develop a kiosk mode app and need my app to be device owner. I have tried the command adb shell dpm set-device-owner and it works. But I want to publish this app so I can't obviously do this to all the devices. I have read in some posts that I can write
Runtime.getRuntime().exec("dpm set-device-owner ...");
I wrote this in my onCreate but it doesn't do anything. Is it related to my device not being rooted or am I missing something?

enable adb via adb sideload

Following scenario:
I have a unrooted (stock) android phone (Samsung) and I need to enable adb, but I don't have access to the device (forgot the lock code).
Is it possible to enable adb debugging via adb sideload from recovery?
For example creating a update.zip, that enables adb or installs an app, that enables adb on boot?
Thanks
Is it possible to enable adb debugging via adb sideload from recovery?
No. Your app would need special permissions to do such a thing. Obviously if an arbitrary app was able to turn on adb debugging without asking the user that'd be a bad thing.
As a side note, this sounds like what someone would ask if they had acquired a phone that didn't belong to them. Not that this would change the validity of my answer.

can not Deactivate this device Administrator

Have an application granted device administration, while trying to uninstall went to device Administrator screen, but the option to Deactivate this device administrator text's visibility is dim and i can not deactivate.
an app which is provisioned to be be device owner can not be removed as device owner by the user.
i think it make sense.
once the Device Owner application is set, it cannot be unset with the adb dpm command. it can be programmatically done by this code called by owner app itself.
DevicePolicyManager.clearDeviceOwnerApp()
or it has to be factory reset your device.
Run the following command in terminal.
adb shell dpm remove-active-admin com.your.App.Package/.DevAdminReceiver 0

Remove Google Glass apk without having root access?

I was testing out the Glass quickstart and chose COMPASS to "re-upload" as a test (tutorial: https://developers.google.com/glass/develop/gdk/quick-start#for_android_beginners)
Now that it worked, I'm stuck with 2x "Compass - sample" and can't call either one by voice commands.
Compass isn't important to me but I am in the process of making an apps for the medical field and I would like to be able to remove it.
Is it possible to remove an .apk from Glass without rooting the device? I have Glass in debug mode and I'm capable of uploading apk's.
Thanks for the help!
You can remove it via the standard way over ADB:
adb shell pm uninstall com.example.MyApp
(where com.example.MyApp is the package name defined in the manifest).
If you have more than one device connected the command will fail - you can direct it to the only attached emulator via the -e flag, the only attached USB device via the -d flag, or a specific device via its serial number and the -s flag (serial numbers as listed in adb devices).

Android: Add app to firmware, use WRITE_SECURE_SETTINGS

I'm trying to write an app that can turn my mobile data connection on and off.
Already got the source and built my own sdk, where I removed the #hide statements so I can use the relevant function
cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
cm.setMobileDataEnabled(true);
Also found out which permissions I need, in particular WRITE_SECURE_SETTINGS, which is only available to system apps. I read adamk's comment and now need to know how to do what he suggested (add the app to system or sign it with the platform key).
At first I would like to do that on the emulator only, and then on my phone (which is rooted and using a custom ROM).
I tried pushing it to the system directory on the emulator:
adb remount
adb push app.apk /system/app/
adb sync
which did not work, the app was not found and installed.
What did I forget? How is the proper way to do this?
So, I finally found the problem and solved it.
I was actually quite close:
adb remount
adb push app.apk /system/app/
This is the correct way to do it on the emulator (no adb sync needed). I watched the logcat, and found out that you need to sign your .apk file so the system does not reject it, even if that does not add any validity in this case.
If you push a signed .apk this way, it will get the needed permissions and work as expected — in my case, turning the mobile data connection on and off.
For the phone part (using ClockworkMod):
Boot into recovery mode, mount the /system folder and enable USB storage. Then proceed in the same way as with the emulator, reboot the phone, and you are good to go.
Hope this helps someone who encounters the same problem.

Categories

Resources