Skip to content

Commit af1cce6

Browse files
pswaminathanBencodes
authored andcommitted
Fix: pass adb path to mobile-install launcher and canonicalize
Path to `adb` was not being sent to MI launcher. This caused it to use the default `/usr/bin/adb`, which is not always valid. stacked-branch: mi-adb-path
1 parent 418e4d7 commit af1cce6

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

mobile_install/launcher_direct.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
load("//rules:visibility.bzl", "PROJECT_VISIBILITY")
1717
load("//rules/flags:flags.bzl", "flags")
18+
load("//rules:utils.bzl", "get_android_toolchain")
1819
load(":deploy_info.bzl", "make_deploy_info_pb")
1920
load(":providers.bzl", "MIAppLaunchInfo")
2021
load(":utils.bzl", "utils")
@@ -65,6 +66,7 @@ def _make_app_runner(
6566
manifest_package_name_path,
6667
out_launcher,
6768
out_launcher_flags,
69+
adb_path,
6870
splits = None,
6971
deploy_info_pb = None,
7072
test_apk = None,
@@ -89,6 +91,7 @@ def _make_app_runner(
8991
args["studio_deployer"] = getattr(ctx.file._studio_deployer, path_type)
9092
args["use_adb_root"] = str(use_adb_root).lower()
9193
args["use_studio_deployer"] = str(use_studio_deployer).lower()
94+
args["adb"] = adb_path
9295

9396
if test_data:
9497
args["data_files"] = ",".join([f.short_path for f in test_data])
@@ -146,6 +149,9 @@ def make_direct_launcher(
146149

147150
runfiles.extend([launcher, launcher_flags])
148151

152+
adb = get_android_toolchain(ctx).adb
153+
runfiles.extend(adb.files.to_list())
154+
149155
runfiles.append(ctx.file._studio_deployer)
150156
if getattr(mi_app_info, "merged_manifest", None):
151157
runfiles.append(mi_app_info.merged_manifest)
@@ -178,6 +184,7 @@ def make_direct_launcher(
178184
mi_app_info.manifest_package_name,
179185
launcher,
180186
launcher_flags,
187+
adb.files_to_run.executable.path,
181188
splits = splits,
182189
deploy_info_pb = deploy_info_pb,
183190
test_apk = test_apk,

src/tools/mi/deployment_oss/deploy_binary.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"log"
2323
"os"
2424
"os/exec"
25+
"path/filepath"
2526
"strings"
2627
"time"
2728

@@ -122,6 +123,18 @@ func main() {
122123

123124
flag.Parse()
124125

126+
var (
127+
realPath string
128+
err error
129+
)
130+
if realPath, err = filepath.EvalSymlinks(*adbPath); err != nil {
131+
glog.Exitf("Unable to dereference adb path: %s", err.Error())
132+
}
133+
if realPath, err = filepath.Abs(realPath); err != nil {
134+
glog.Exitf("Unable to canonicalize adb path: %s", err.Error())
135+
}
136+
*adbPath = realPath
137+
125138
pprint.Info("Deploying using OSS mobile-install!")
126139

127140
if *noDeploy {

0 commit comments

Comments
 (0)