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

Commit 7d87779d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Not using shell command to enable test provider" into sc-v2-dev

parents e0c4a090 5f80e92b
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ import androidx.test.uiautomator.Until;

import com.android.launcher3.ResourceUtils;
import com.android.launcher3.testing.TestProtocol;
import com.android.systemui.shared.system.ContextUtils;
import com.android.systemui.shared.system.QuickStepContract;

import org.junit.Assert;
@@ -246,16 +245,12 @@ public final class LauncherInstrumentation {
        ComponentName cn = new ComponentName(pi.packageName, pi.name);

        if (pm.getComponentEnabledSetting(cn) != COMPONENT_ENABLED_STATE_ENABLED) {
            if (TestHelpers.isInLauncherProcess()) {
                pm.setComponentEnabledSetting(cn, COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
            } else {
            mInstrumentation.getUiAutomation().adoptShellPermissionIdentity(
                    android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE);
            try {
                    final int userId = ContextUtils.getUserId(getContext());
                    mDevice.executeShellCommand(
                            "pm enable --user " + userId + " " + cn.flattenToString());
                } catch (IOException e) {
                    fail(e.toString());
                }
                pm.setComponentEnabledSetting(cn, COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
            } finally {
                mInstrumentation.getUiAutomation().dropShellPermissionIdentity();
            }
        }
    }