소스 검색

Fixed adb executable location

Vadik Sirekanyan 2 년 전
부모
커밋
9d53da6943
2개의 변경된 파일11개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 1
      app/build.gradle
  2. 9 3
      app/grant.sh

+ 2 - 1
app/build.gradle

@@ -38,9 +38,10 @@ dependencies {
 afterEvaluate {
     def grantSystemPermissions = {
         exec {
+            def adbExecutable = android.properties['adbExecutable']
             def defaultPackage = android.defaultConfig.applicationId
             def debugSuffix = android.buildTypes['debug'].applicationIdSuffix
-            commandLine('./grant.sh', defaultPackage + debugSuffix)
+            commandLine('./grant.sh', adbExecutable, defaultPackage + debugSuffix)
         }
     }
     assembleDebug.doLast { grantSystemPermissions() }

+ 9 - 3
app/grant.sh

@@ -1,12 +1,18 @@
 #!/usr/bin/env bash
 
-PACKAGE_NAME="$1"
+if [ "$#" -ne 2 ] || [ ! -x "$1" ]; then
+  echo "Usage: $0 ADB_EXECUTABLE PACKAGE_NAME"
+  exit 1
+fi
+
+ADB_EXECUTABLE="$1"
+PACKAGE_NAME="$2"
 
 grant() {
-  adb -s "$device" shell pm grant "$PACKAGE_NAME" "android.permission.$1" >/dev/null 2>&1
+  "$ADB_EXECUTABLE" -s "$device" shell pm grant "$PACKAGE_NAME" "android.permission.$1" >/dev/null 2>&1
 }
 
-DEVICES=$(adb devices | grep device | grep -v devices | cut -f1)
+DEVICES=$("$ADB_EXECUTABLE" devices | grep device | grep -v devices | cut -f1)
 
 for device in ${DEVICES}; do
   grant WRITE_SECURE_SETTINGS