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

Commit 9fc37340 authored by Vadim Tryshev's avatar Vadim Tryshev Committed by My Name
Browse files

Clearing package data as recommended by owners of the "pm clear" command

Bug: 353541583
Test: running on abtd
Flag: NONE test change
Change-Id: I227eb145f5c2fa5c07972bae15fb66e69e623dd8
parent 779c7912
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static com.android.launcher3.testing.shared.TestProtocol.ICON_MISSING;
import static com.android.launcher3.testing.shared.TestProtocol.WIDGET_CONFIG_NULL_EXTRA_INTENT;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -64,7 +63,6 @@ import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.testcomponent.TestCommandReceiver;
import com.android.launcher3.util.LooperExecutor;
import com.android.launcher3.util.SimpleBroadcastReceiver;
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.rule.ExtendedLongPressTimeoutRule;
@@ -237,16 +235,12 @@ public abstract class AbstractLauncherUiTest<LAUNCHER_TYPE extends Launcher> {
    }

    protected void clearPackageData(String pkg) throws IOException, InterruptedException {
        final CountDownLatch count = new CountDownLatch(2);
        final SimpleBroadcastReceiver broadcastReceiver =
                new SimpleBroadcastReceiver(UI_HELPER_EXECUTOR, i -> count.countDown());
        // We OK to make binder calls on main thread in test.
        broadcastReceiver.registerPkgActions(mTargetContext, pkg,
                Intent.ACTION_PACKAGE_RESTARTED, Intent.ACTION_PACKAGE_DATA_CLEARED);

        mDevice.executeShellCommand("pm clear " + pkg);
        assertTrue(pkg + " didn't restart", count.await(20, TimeUnit.SECONDS));
        mTargetContext.unregisterReceiver(broadcastReceiver);
        assertTrue("pm clear command failed",
                mDevice.executeShellCommand("pm clear " + pkg)
                .contains("Success"));
        assertTrue("pm wait-for-handler command failed",
                mDevice.executeShellCommand("pm wait-for-handler")
                .contains("Success"));
    }

    protected TestRule getRulesInsideActivityMonitor() {