Create a gist now

Instantly share code, notes, and snippets.

How to grant all permissions at once in marshmallow using shell script
#!/bin/sh
#Author - Nitesh Tiwari
#Github - https://github.com/nitiwari-dev
#add your package_name
PACKAGE=com.code2concept
#create array with all the permission you need to enabled
PKG_ARRAY='android.permission.CALL_PHONE
android.permission.GET_ACCOUNTS
android.permission.READ_SMS
android.permission.READ_CONTACTS
android.permission.ACCESS_FINE_LOCATION
android.permission.CAMERA
android.permission.WRITE_EXTERNAL_STORAGE'
#lets exceute our command
for permissions in $PKG_ARRAY;
do
echo $permissions + ' granted'
adb shell pm grant $PACKAGE $permissions
done
echo 'Bingo its done'
# Output
# $ sh grant_all_permissions.sh
# android.permission.CALL_PHONE + granted
# android.permission.GET_ACCOUNTS + granted
# android.permission.READ_SMS + granted
# android.permission.READ_CONTACTS + granted
# android.permission.ACCESS_FINE_LOCATION + granted
# android.permission.CAMERA + granted
# android.permission.WRITE_EXTERNAL_STORAGE + granted
# Bingo its done'
@nitiwari-dev
Owner
nitiwari-dev commented Oct 19, 2016 edited

The above shell script allow all the permission at once without clicking at 'allow' button every time. Really helpful to get rid of clicking the dialogs.

Before
before_permission

After
af_permisio

@vikasrairajput

where i should put this file??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment