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

Commit f74f0c27 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Creating correct device profile when appContext and launcher context do not match

Bug: 156891776
Change-Id: If2df3a6719de4207fa15d8a416704eb8e7c136b9
parent ea928edc
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import androidx.annotation.CallSuper;
import androidx.annotation.UiThread;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.VibratorWrapper;
@@ -96,8 +95,8 @@ public abstract class BaseSwipeUpHandler<T extends StatefulActivity<?>, Q extend
     * depend on proper class initialization.
     */
    protected void initAfterSubclassConstructor() {
        initTransitionEndpoints(InvariantDeviceProfile.INSTANCE.get(mContext)
                .getDeviceProfile(mContext));
        initTransitionEndpoints(
                mTaskViewSimulator.getOrientationState().getLauncherDeviceProfile());
    }

    protected void performHapticFeedback() {
@@ -205,7 +204,7 @@ public abstract class BaseSwipeUpHandler<T extends StatefulActivity<?>, Q extend
        mRecentsAnimationController = recentsAnimationController;
        mRecentsAnimationTargets = targets;
        mTransformParams.setTargetSet(mRecentsAnimationTargets);
        DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(mContext).getDeviceProfile(mContext);
        DeviceProfile dp = mTaskViewSimulator.getOrientationState().getLauncherDeviceProfile();
        RemoteAnimationTargetCompat runningTaskTarget = targets.findTask(
                mGestureState.getRunningTaskId());

@@ -300,8 +299,7 @@ public abstract class BaseSwipeUpHandler<T extends StatefulActivity<?>, Q extend
            if (TestProtocol.sDebugTracing) {
                Log.d(TestProtocol.PAUSE_NOT_DETECTED, "BaseSwipeUpHandler.2");
            }
            initTransitionEndpoints(InvariantDeviceProfile.INSTANCE.get(mContext)
                .getDeviceProfile(mContext));
            initTransitionEndpoints(createdActivity.getDeviceProfile());
        }
        return true;
    }
+1 −2
Original line number Diff line number Diff line
@@ -139,13 +139,12 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
     */
    protected DeviceProfile createDeviceProfile() {
        DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(this).getDeviceProfile(this);
        DeviceProfile dp1 = InvariantDeviceProfile.INSTANCE.get(this).getDeviceProfile(this);

        // In case we are reusing IDP, create a copy so that we don't conflict with Launcher
        // activity.
        return (mRecentsRootView != null) && isInMultiWindowMode()
                ? dp.getMultiWindowProfile(this, getMultiWindowDisplaySize())
                : dp1.copy(this);
                : dp.copy(this);
    }

    @Override
+3 −3
Original line number Diff line number Diff line
@@ -83,15 +83,15 @@ public abstract class SwipeUpAnimationLogic {
        mGestureState = gestureState;
        mTaskViewSimulator = new TaskViewSimulator(context, gestureState.getActivityInterface());
        mTransformParams = transformParams;

        mTaskViewSimulator.setLayoutRotation(
                mDeviceState.getCurrentActiveRotation(), mDeviceState.getDisplayRotation());
    }

    protected void initTransitionEndpoints(DeviceProfile dp) {
        mDp = dp;

        mTaskViewSimulator.setDp(dp);
        mTaskViewSimulator.setLayoutRotation(
                mDeviceState.getCurrentActiveRotation(),
                mDeviceState.getDisplayRotation());
        mTransitionDragLength = mGestureState.getActivityInterface().getSwipeUpDestinationAndLength(
                dp, mContext, TEMP_RECT,
                mTaskViewSimulator.getOrientationState().getOrientationHandler());
+13 −1
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ import static android.view.Surface.ROTATION_90;
import static com.android.launcher3.logging.LoggerUtils.extractObjectNameAndAddress;
import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;

import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS;

import static java.lang.annotation.RetentionPolicy.SOURCE;

import android.content.ContentResolver;
@@ -49,6 +49,7 @@ import androidx.annotation.IntDef;
import androidx.annotation.NonNull;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Utilities;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.PagedOrientationHandler;
@@ -524,4 +525,15 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre
                + " mFlags=" + mFlags
                + "]";
    }

    /**
     * Returns the device profile based on expected launcher rotation
     */
    public DeviceProfile getLauncherDeviceProfile() {
        InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(mContext);
        // TODO also check the natural orientation is landscape or portrait
        return  (mLauncherRotation == ROTATION_90 || mLauncherRotation == ROTATION_270)
                ? idp.landscapeProfile
                : idp.portraitProfile;
    }
}