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

Commit e712ea68 authored by JW Wang's avatar JW Wang
Browse files

Enable root before listing files

It needs root for `ls /data/apex/active` to work.

Bug: 209544705
Test: atest StagedInstallInternalTest StagedRollbackTest

Change-Id: I267b027d233f0b815b39f4c7e8920795bc99a761
parent 1700991d
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -106,6 +106,8 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
     * @param files the paths of files which might contain wildcards
     */
    private void deleteFiles(String... files) throws Exception {
        try {
            getDevice().enableAdbRoot();
            boolean found = false;
            for (String file : files) {
                CommandResult result = getDevice().executeShellV2Command("ls " + file);
@@ -116,17 +118,15 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
            }

            if (found) {
            try {
                getDevice().enableAdbRoot();
                getDevice().remountSystemWritable();
                for (String file : files) {
                    getDevice().executeShellCommand("rm -rf " + file);
                }
                getDevice().reboot();
            }
        } finally {
            getDevice().disableAdbRoot();
        }
            getDevice().reboot();
        }
    }

    private void waitForDeviceNotAvailable(long timeout, TimeUnit unit) {
+4 −3
Original line number Diff line number Diff line
@@ -112,6 +112,10 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test {
     * @param files the paths of files which might contain wildcards
     */
    private void deleteFiles(String... files) throws Exception {
        if (!getDevice().isAdbRoot()) {
            getDevice().enableAdbRoot();
        }

        boolean found = false;
        for (String file : files) {
            CommandResult result = getDevice().executeShellV2Command("ls " + file);
@@ -122,9 +126,6 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test {
        }

        if (found) {
            if (!getDevice().isAdbRoot()) {
                getDevice().enableAdbRoot();
            }
            getDevice().remountSystemWritable();
            for (String file : files) {
                getDevice().executeShellCommand("rm -rf " + file);