LauncherInstrumentation enables even when non-system user

Attempting to run a tapl test while the device is in a secondary user
currently fails because the test app doesn't get enabled for
this secondary user. We fix that (at least one issue with it) in this cl.

Test: make PlatformScenarioTests; adb root && adb install -r -g ${ANDROID_PRODUCT_OUT}/testcases/PlatformScenarioTests/$(get_build_var TARGET_ARCH)/PlatformScenarioTests.apk
adb shell am instrument -w -r -e class android.platform.test.scenario.chrome.OpenApp android.platform.test.scenario/androidx.test.runner.AndroidJUnitRunner
(Do this while the current user is SYSTEM as well as Guest)

Bug: 162454040
Change-Id: If6d8e545b41eb20e3fed2935c39069ce97d8b6cd
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index a77c1c6..92ab9b8 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -64,6 +64,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;
@@ -238,11 +239,12 @@
 
         if (pm.getComponentEnabledSetting(cn) != COMPONENT_ENABLED_STATE_ENABLED) {
             if (TestHelpers.isInLauncherProcess()) {
-                getContext().getPackageManager().setComponentEnabledSetting(
-                        cn, COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
+                pm.setComponentEnabledSetting(cn, COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
             } else {
                 try {
-                    mDevice.executeShellCommand("pm enable " + cn.flattenToString());
+                    final int userId = ContextUtils.getUserId(getContext());
+                    mDevice.executeShellCommand(
+                            "pm enable --user " + userId + " " + cn.flattenToString());
                 } catch (IOException e) {
                     fail(e.toString());
                 }