Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a915697 authored by Nicolas Geoffray's avatar Nicolas Geoffray
Browse files

Escape "$" in script generated when simpleperf_app is true.

bug: 80265465
Test: adb shell "am instrument -e simpleperf_app true -e apps com.google.android.youtube^Youtube -e launch_directory /data/local/tmp -w  com.android.tests.applaunch com.android.tests.applaunch/android.test.InstrumentationTestRunner"

Change-Id: I6d0113019c019dac856bf613408d278713ca8585
parent 5cbad094
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -184,7 +184,8 @@ public class AppLaunch extends InstrumentationTestCase {
        if (null != launchDirectory && !launchDirectory.isEmpty()) {
            launchRootDir = new File(launchDirectory);
            if (!launchRootDir.exists() && !launchRootDir.mkdirs()) {
                throw new IOException("Unable to create the destination directory");
                throw new IOException("Unable to create the destination directory "
                    + launchRootDir + ". Try disabling selinux.");
            }
        }

@@ -192,7 +193,8 @@ public class AppLaunch extends InstrumentationTestCase {
            File launchSubDir = new File(launchRootDir, LAUNCH_SUB_DIRECTORY);

            if (!launchSubDir.exists() && !launchSubDir.mkdirs()) {
                throw new IOException("Unable to create the lauch file sub directory");
                throw new IOException("Unable to create the lauch file sub directory "
                    + launchSubDir + ". Try disabling selinux.");
            }
            File file = new File(launchSubDir, LAUNCH_FILE);
            FileOutputStream outputStream = new FileOutputStream(file);
@@ -769,6 +771,8 @@ public class AppLaunch extends InstrumentationTestCase {
                             BufferedWriter writer =
                                new BufferedWriter(new OutputStreamWriter(stream))) {
                            String cmd = String.format(SIMPLEPERF_APP_CMD, packageName, launchCmd);
                            // In the file, we need to escape any "$".
                            cmd = cmd.replace("$", "\\$");
                            writer.write(cmd);
                        }
                        launchCmd = launchFile.getAbsolutePath();