Search code examples
androidandroid-permissions

Android stop permission promt for screen recording


I am running some experiments where I need my workflow to be automated. One of the tasks involves launching an android application I've made. This app records the display of the device and then after a minute or so, the app is killed via ADB.

Because the app is recording the screen, it prompts the user, saying:

enter image description here

I get that it is a security feature, but for testing or experimental purposes, is there any way to disable it or perhaps simulate the "Start now" click?

I've tried <uses-permission android:name="android.permission.PROJECT_MEDIA"/> but it has no effect.


Solution

  • Solved. Can't get rid of the dialog, but I can simulate a tap event at the location of the "Start now" button.

    To do this, go to Developer Options and enable Pointer Location. This will show the coordinates of touch events in the top menu bar.

    Open the app showing the dialog, tap the "Start now" button and note the coordinates of the touch event.

    Now when you need to automatically accept the permissions, run the following ADB command:

    adb shell input tap x y where x and y are the coordinates of the touch event.