Need to set application in device administration and provide rights

Hello,

Currently I am testing an application in which I need to set the application to the device administration. Only after that I can access the application. Also once the application is under device administration, I cannot clear app manually.

Please help me in following.

  • How to set application in device administration section through appium.
  • How to remove application from device administration section through appium.
  • Is there any way to clear the data of the application through appium, if the application is already there in the device administration.?

Thanks in advance.
-Mashkur

@mashkurm, we have similar requirements, but had no solution available with the utilities provided with Appium. We had to do the following:

  1. Create an adb module that would allow us to start arbitrary applications. Appium has since added routines to start other applciations, but we haven’t converted. The adb command to start the settings screen with access to device admin is:

    adb shell am start -S -n com.android.settings/.DeviceAdminSettings

  2. modify our screen factory to detect the different settings screens – this is not a small amount of work to support all the different settings layouts among android devices. If this is the only settings screen you need, then this work becomes far simpler. Once you are on the screen, you detect the application name and enable/disable the checkbox or switch.

1 Like

Thanks @willosser - It seems that we need to do it manually once we are landed on that screen. I landed on the screen by the command you mentioned. However it becomes partial automation, but still, it saves a lot of time since finding device admins in various devices itself is a tedious work if you are automation engineer specifically. :slight_smile:

We modify numerous settings for our product, so we’ve built out a whole infrastructure for the settings screens. As such, adding code to handle the device admin screen was just an extension. The main thing we had to do to support this was create an xpath that searches for a checkbox sibling to the app name, and if and when that fails, use an xpath that searches for a switch in the position. There’s a possibility that you might have enough apps on the device to have to scroll on the device admin screen, but I haven’t seen that use case yet. Then, once you click enable or disable, you may have to handle the confirmation screen.