To grant and revoke permissions via Terminal (ADB Shell), run your app on an emulator (I haven’t personally tried on a device but it should work there too).
Open your Terminal, and then enter the following command:
adb shell
Once you’re in, you may use the following syntax for granting or revoking your Android device’s permissions:
pm grant <package-name> <permission>
For example, to grant a permission:
pm grant net.catzie.myapp android.permission.READ_EXTERNAL_STORAGE
pm grant net.catzie.myapp android.permission.WRITE_EXTERNAL_STORAGE
And to revoke a permission:
pm revoke net.catzie.myapp android.permission.READ_EXTERNAL_STORAGE
pm revoke net.catzie.myapp android.permission.WRITE_EXTERNAL_STORAGE
Now there’s no need to open the settings screen on your device to play with your Android permissions!