Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

nitiwari-dev commented Oct 19, 2016

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

This comment has been minimized.

Copy link

vikasrairajput commented Jan 24, 2017

where i should put this file??

@nitiwari-dev

This comment has been minimized.

Copy link
Owner Author

nitiwari-dev commented Mar 3, 2017

@vikasrairajput. You can run with following command on shell i.e $sh grant_all_permissions.sh .So this script will ensure all the permissions are granted without the user intervention. Note: This is only for developer who do not wanted to click allow button every time. Let me know in case of any issue.

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