Android Mobile Management

I do not want to advertise, but an example application for the behavior of my application is ESET antivirus.

One requested feature of my application is that a password is required to delete. I am adding my application to the list of device administrators and it cannot be deleted. But you can deactivate the application as an administrator device. What do you do in settings> Location and Security> Select device administrators, and you try to deactivate ESET Security, it will start its activity (I think from DeviceAdminReceiver.onDisableRequested ()), which is waiting for a password and your mobile phone is locked. Home button, Back button, and even SwitchOff button do not respond =>

How is it possible that the Home, Back, SwitchOff, and Camera button is not responding?

EDIT - the second question has been removed (After I took out the battery from my phone - ESET was not a device administrator either)

Thanks for the ideas.

+6
source share
1 answer

Ok, sorry ESET, but this feature looks very interesting, so I looked at the decompiled sources :)

The main workflow is as follows:

  • Subclass
com.eset.ems.antitheft.receiver.AdminReceiver DeviceAdminReceiver registered for translational actions DEVICE_ADMIN_ENABLED and DEVICE_ADMIN_DISABLED When the device administrator is disconnected com.eset.ems.antitheft.receiver.AdminReceiver.onDisabled() is called com.eset.ems.antitheft.LockActivity AdminReceiver.onDisabled() LockActivity shows com.eset.ems.antitheft.LockingDialog where the most blocking magic happens

As for the Home antivirus and other buttons, do the following trick: it uses an ActivityManagerNative from Android internal systems. To keep LockActivity at the top of all other actions, it starts a thread, which usually calls ActivityManagerNative.moveTaskToFront() with the LockActivity task LockActivity . Prior to reflection, the API level 10 is used to access the hidden moveTaskToFront() from the ActivityManager , and after API 10 it simply uses the ActivityManagerNative code from the Android code to access it. Also, both the LockActivity and LockingDialog call the ActivityManagerNative.closeSystemDialogs() method many times. This is probably done in order to cancel the system dialog that occurs after a long press of the power button.

Regarding the termination of DeviceAdminReceiver.onDisableRequested , in fact, I did not notice anything special in this code. It starts activity only after the device administrator is disconnected and that’s it. And on my phone, the admin device turned off after I took out the battery.

+2
source

Source: https://habr.com/ru/post/922826/


All Articles