pookie
pookie

Reputation: 4142

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.

Upvotes: 12

Views: 8941

Answers (2)

user
user

Reputation: 25838

You can disable it using the following adb command:

adb shell appops set com.your.app.id PROJECT_MEDIA allow

To revert, set it to ignore.

Upvotes: 18

pookie
pookie

Reputation: 4142

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.

Upvotes: 1

Related Questions