Merge "Revert "Not using shell command to enable test provider"" into sc-v2-dev am: a4937b2270 am: e1b5c7b417
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15562850
Change-Id: I4dada14d21d1d7258e0fccceb9f9aa1e46e8814e
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 522b185..6cdfd5b 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -66,6 +66,7 @@
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;
@@ -245,12 +246,16 @@
ComponentName cn = new ComponentName(pi.packageName, pi.name);
if (pm.getComponentEnabledSetting(cn) != COMPONENT_ENABLED_STATE_ENABLED) {
- mInstrumentation.getUiAutomation().adoptShellPermissionIdentity(
- android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE);
- try {
+ if (TestHelpers.isInLauncherProcess()) {
pm.setComponentEnabledSetting(cn, COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
- } finally {
- mInstrumentation.getUiAutomation().dropShellPermissionIdentity();
+ } else {
+ try {
+ final int userId = ContextUtils.getUserId(getContext());
+ mDevice.executeShellCommand(
+ "pm enable --user " + userId + " " + cn.flattenToString());
+ } catch (IOException e) {
+ fail(e.toString());
+ }
}
}
}
@@ -300,7 +305,7 @@
public boolean isTwoPanels() {
return getTestInfo(TestProtocol.REQUEST_IS_TWO_PANELS)
- .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
private void setForcePauseTimeout(long timeout) {