Created
July 4, 2020 02:49
-
-
Save yangweigbh/7e563ce715dd2b43f06393a88c176749 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val dest = "/data/local/tmp/lockClocks.sh" | |
| val source = javaClass.classLoader.getResource("scripts/lockClocks.sh") | |
| val tmpSource = Files.createTempFile("lockClocks.sh", null).toString() | |
| Files.copy( | |
| source.openStream(), | |
| Paths.get(tmpSource), | |
| StandardCopyOption.REPLACE_EXISTING | |
| ) | |
| adb.execSync("push $tmpSource $dest") | |
| // Files pushed by adb push don't always preserve file permissions. | |
| adb.execSync("shell chmod 700 $dest") | |
| // Forward gradle arguments to lockClocks.sh. | |
| val coresArg = project.findProperty("androidx.benchmark.lockClocks.cores") | |
| if (!isAdbdRoot) { | |
| // Default shell is not running as root, escalate with su 0. Although the root group is | |
| // su's default, using syntax different from "su gid cmd", can cause the adb shell | |
| // command to hang on some devices. | |
| adb.execSync("shell su 0 $dest ${coresArg ?: ""}") | |
| } else { | |
| adb.execSync("shell $dest ${coresArg ?: ""}") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment