Skip to content

Commit c016b7a

Browse files
ted-xiecopybara-github
authored andcommitted
Parse --tool_tag flag in OSS mobile-install
The --tool_tag flag is passed to Bazel mobile-install when invoked through Android Studio. When the flag is passed and equal to "AndroidStudio", MI should only _sync_ the sharded APKs to the test device, and not launch the app. PiperOrigin-RevId: 743665786 Change-Id: Ie3340c595606fac201da783bf56d9b12b293a732
1 parent 52b4de5 commit c016b7a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/tools/mi/deployment_oss/deploy_binary.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var (
4343
splits = flags.NewStringList("splits", "The list of split apk paths.")
4444
start = flag.String("start", "", "start_type from mobile-install.")
4545
startType = flag.String("start_type", "", "start_type (deprecated, use --start).")
46+
toolTag = flag.String("tool_tag", "", "tool_tag from blaze.")
4647
useADBRoot = flag.Bool("use_adb_root", true, "whether (true) or not (false) to use root permissions.")
4748
userID = flag.Int("user", 0, "User id to install the app for.")
4849

@@ -61,6 +62,8 @@ var (
6162
buildID = flag.String("build_id", "", "The id of the build. Set by Bazel, the user should not use this flag.")
6263
)
6364

65+
func isAndroidStudio() bool { return strings.Contains(*toolTag, "AndroidStudio") }
66+
6467
func resolveDeviceSerialAndPort(ctx context.Context, device string) (deviceSerialFlag, port string) {
6568
switch {
6669
case strings.Contains(device, ":tcp:"):
@@ -192,10 +195,10 @@ func main() {
192195
}
193196
}
194197

195-
if *launchApp {
198+
if *launchApp && !isAndroidStudio() {
196199
pprint.Info("Finished deploying changes. Launching app")
197200

198-
var stopCmd = exec.Command(*adbPath, "-s", deviceSerial, "shell", "am", "force-stop", appPackage)
201+
stopCmd := exec.Command(*adbPath, "-s", deviceSerial, "shell", "am", "force-stop", appPackage)
199202
if err := stopCmd.Run(); err != nil {
200203
pprint.Error("Unable to stop app: %s", err.Error())
201204
}

0 commit comments

Comments
 (0)