I can’t, @kskrishnan, because our code is written in Ruby
Appium gives you an API that detects the activity. Depending upon the device, you could get two different activities - the package name may get stripped off or not:
‘com.android.packageinstaller.permission.ui.GrantPermissionsActivity’,
‘.permission.ui.GrantPermissionsActivity’
When you detect this activity, you need to find an element by id:
‘com.android.packageinstaller:id/permission_message’
Then you can obtain the text of that message if you are interested in it. If you care which permission it is, you can match it against expected strings or regular expressions. If not, you can blindly accept by finding and clicking the element by id:
‘com.android.packageinstaller:id/permission_allow_button’
If you’d rather not click ‘allow’ on all those windows, you can use adb to add all the permissions at once before you start testing (but after Appium has installed your app). If you know all the perms your app will need, you can add them with one command:
pm grant $app_name $space_delimited_set_of_perms
Or you can add all perms one at a time, which takes 1.5-2 seconds per attempt.