diff options
author | Winson Chung <winsonc@google.com> | 2019-03-25 14:26:29 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2019-03-26 14:54:35 -0700 |
commit | 14b2f9dd57216e4443bed8300b8464c2f50162c0 (patch) | |
tree | 0f64b932348e5dc72baab612c19e2bd860492c1c /tests/tapl | |
parent | f25461c337c9883d180479557ba5592115a5384e (diff) | |
download | android_packages_apps_Trebuchet-14b2f9dd57216e4443bed8300b8464c2f50162c0.tar.gz android_packages_apps_Trebuchet-14b2f9dd57216e4443bed8300b8464c2f50162c0.tar.bz2 android_packages_apps_Trebuchet-14b2f9dd57216e4443bed8300b8464c2f50162c0.zip |
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)
Diffstat (limited to 'tests/tapl')
-rw-r--r-- | tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 3dd14676a..fd6ddce5d 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.Instrumentation; 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 @@ public final class LauncherInstrumentation { } 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) { |