androidandroid-instrumentationaws-device-farm

AWS Device Farm - permissions for Android Instrumented test


Is it possible to grant secured permission for espresso instumented test in AWS device farm? I need to grant "android.permission.ACCESS_BACKGROUND_LOCATION", in Android 10 and above it's secured and can be granted only in the system settings for the app.


Solution

  • You can grant secured permission for espresso instumented test within custom YML File using below sample commands in pre_test phase

    # These next lines set the permissions of the app
    - adb shell pm grant io.appium.settings android.permission.ACCESS_COARSE_LOCATION
    - adb shell pm grant io.appium.settings android.permission.ACCESS_FINE_LOCATION
    - adb shell pm grant io.appium.settings android.permission.CHANGE_CONFIGURATION
    - adb shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000
    - adb shell appops set io.appium.settings android:mock_location allow