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

Commit fa56d3ed authored by vadimt's avatar vadimt
Browse files

Waiting for Launcher to restart after enabling test provider

Bug: 188806432
Test: presubmit
Change-Id: Ie821c7641c351e0926fff1b7218c4ed745d2dd8f
parent 69f2dc2b
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -251,8 +251,19 @@ public final class LauncherInstrumentation {
            } else {
                try {
                    final int userId = ContextUtils.getUserId(getContext());
                    final String launcherPidCommand = "pidof " + pi.packageName;
                    final String initialPid = mDevice.executeShellCommand(launcherPidCommand)
                            .replaceAll("\\s", "");
                    mDevice.executeShellCommand(
                            "pm enable --user " + userId + " " + cn.flattenToString());
                    // Wait for Launcher restart after enabling test provider.
                    for (int i = 0; i < 100; ++i) {
                        final String currentPid = mDevice.executeShellCommand(launcherPidCommand)
                                .replaceAll("\\s", "");
                        if (!currentPid.isEmpty() && !currentPid.equals(initialPid)) break;
                        if (i == 99) fail("Launcher didn't restart after enabling test provider");
                        SystemClock.sleep(100);
                    }
                } catch (IOException e) {
                    fail(e.toString());
                }