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 15179c0674
)
This commit is contained in:
parent
f25461c337
commit
14b2f9dd57
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue