Use own context instead of app context to get overlay resources

Bug: 129270535
Test: adb shell am instrument -w -r -e package android.platform.test.scenario.launcher android.platform.test.scenario/androidx.test.runner.AndroidJUnitRunner
Change-Id: Iff2921cafcdb933566b5eb76670facc844bc7fd9
(cherry picked from commit 15179c0674b2cd20c252205673b338300b4fa48c)
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 3dd1467..fd6ddce 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -23,6 +23,7 @@
 import android.app.UiAutomation;
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.pm.PackageManager;
 import android.graphics.Point;
 import android.net.Uri;
 import android.os.Build;
@@ -173,7 +174,15 @@
     }
 
     private boolean isSwipeUpEnabled() {
-        return !QuickStepContract.isLegacyMode(mInstrumentation.getTargetContext());
+        final Context baseContext = mInstrumentation.getTargetContext();
+        try {
+            // Workaround, use constructed context because both the instrumentation context and the
+            // app context are not constructed with resources that take overlays into account
+            Context ctx = baseContext.createPackageContext(getLauncherPackageName(), 0);
+            return !QuickStepContract.isLegacyMode(ctx);
+        } catch (PackageManager.NameNotFoundException e) {
+            return false;
+        }
     }
 
     static void log(String message) {