Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15179c06 authored by Winson Chung's avatar Winson Chung
Browse files

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
parent 18841823
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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.Bundle;
@@ -160,7 +161,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) {