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

Commit aceb6ed4 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of [16663837, 16663579, 16682031, 16458641] into sc-v2-release.

Change-Id: I8ce0dc7b246a5679496cb09166a636d7d51acddc
parents f13716cb c03eca68
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@
    <!-- PiP minimum size, which is a % based off the shorter side of display width and height -->
    <fraction name="config_pipShortestEdgePercent">40%</fraction>

    <!-- Show PiP enter split icon, which allows apps to directly enter splitscreen from PiP. -->
    <bool name="config_pipEnableEnterSplitButton">false</bool>

    <!-- Animation duration when using long press on recents to dock -->
    <integer name="long_press_dock_anim_duration">250</integer>

+3 −3
Original line number Diff line number Diff line
@@ -104,8 +104,6 @@ public class PipMenuView extends FrameLayout {
    private static final float MENU_BACKGROUND_ALPHA = 0.3f;
    private static final float DISABLED_ACTION_ALPHA = 0.54f;

    private static final boolean ENABLE_ENTER_SPLIT = true;

    private int mMenuState;
    private boolean mAllowMenuTimeout = true;
    private boolean mAllowTouches = true;
@@ -277,6 +275,8 @@ public class PipMenuView extends FrameLayout {
            boolean resizeMenuOnShow, boolean withDelay, boolean showResizeHandle) {
        mAllowMenuTimeout = allowMenuTimeout;
        mDidLastShowMenuResize = resizeMenuOnShow;
        final boolean enableEnterSplit =
                mContext.getResources().getBoolean(R.bool.config_pipEnableEnterSplitButton);
        if (mMenuState != menuState) {
            // Disallow touches if the menu needs to resize while showing, and we are transitioning
            // to/from a full menu state.
@@ -297,7 +297,7 @@ public class PipMenuView extends FrameLayout {
                    mDismissButton.getAlpha(), 1f);
            ObjectAnimator enterSplitAnim = ObjectAnimator.ofFloat(mEnterSplitButton, View.ALPHA,
                    mEnterSplitButton.getAlpha(),
                    ENABLE_ENTER_SPLIT && mFocusedTaskAllowSplitScreen ? 1f : 0f);
                    enableEnterSplit && mFocusedTaskAllowSplitScreen ? 1f : 0f);
            if (menuState == MENU_STATE_FULL) {
                mMenuContainerAnimator.playTogether(menuAnim, settingsAnim, dismissAnim,
                        enterSplitAnim);
+21 −2
Original line number Diff line number Diff line
@@ -16,12 +16,15 @@

package com.android.systemui.flags;

import android.content.res.Resources;
import android.util.SparseBooleanArray;

import androidx.annotation.BoolRes;
import androidx.annotation.NonNull;

import com.android.systemui.Dumpable;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;

import java.io.FileDescriptor;
@@ -38,8 +41,11 @@ import javax.inject.Inject;
@SysUISingleton
public class FeatureFlagManager implements FlagReader, FlagWriter, Dumpable {
    SparseBooleanArray mAccessedFlags = new SparseBooleanArray();
    private Resources mResources;

    @Inject
    public FeatureFlagManager(DumpManager dumpManager) {
    public FeatureFlagManager(DumpManager dumpManager, @Main Resources resources) {
        mResources = resources;
        dumpManager.registerDumpable("SysUIFlags", this);
    }

@@ -51,7 +57,20 @@ public class FeatureFlagManager implements FlagReader, FlagWriter, Dumpable {

    @Override
    public boolean isEnabled(BooleanFlag flag) {
        return isEnabled(flag.getId(), flag.getDefault());
        boolean def = flag.getDefault();
        if (flag.hasResourceOverride()) {
            try {
                def = isEnabledInOverlay(flag.getResourceOverride());
            } catch (Resources.NotFoundException e) {
                // no-op
            }
        }

        return isEnabled(flag.getId(), def);
    }

    private boolean isEnabledInOverlay(@BoolRes int resId) {
        return mResources.getBoolean(resId);
    }

    @Override
+22 −5
Original line number Diff line number Diff line
@@ -25,15 +25,14 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

import android.content.Context;
import android.content.res.Resources;

import androidx.test.filters.SmallTest;

import com.android.systemui.SysuiTestCase;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.util.settings.SecureSettings;

import org.junit.After;
import org.junit.Before;
@@ -53,14 +52,14 @@ import java.io.StringWriter;
public class FeatureFlagManagerTest extends SysuiTestCase {
    FeatureFlagManager mFeatureFlagManager;

    @Mock private Context mContext;
    @Mock private DumpManager mDumpManager;
    @Mock private Resources mResources;

    @Before
    public void setup() {
        MockitoAnnotations.initMocks(this);

        mFeatureFlagManager = new FeatureFlagManager(mDumpManager);
        mFeatureFlagManager = new FeatureFlagManager(mDumpManager, mResources);
    }

    @After
@@ -70,6 +69,24 @@ public class FeatureFlagManagerTest extends SysuiTestCase {
        verifyNoMoreInteractions(mDumpManager);
    }


    @Test
    public void testSimpleFlag() {
        BooleanFlag flagA = new BooleanFlag(100, false);
        BooleanFlag flagB = new BooleanFlag(200, true);

        assertThat(mFeatureFlagManager.isEnabled(flagA)).isFalse();
        assertThat(mFeatureFlagManager.isEnabled(flagB)).isTrue();
    }

    @Test
    public void testResourceOverride() {
        when(mResources.getBoolean(1)).thenReturn(true);
        BooleanFlag flag = new BooleanFlag(100, false, 1);

        assertThat(mFeatureFlagManager.isEnabled(flag)).isTrue();
    }

    @Test
    public void testIsEnabled() {
        mFeatureFlagManager.setEnabled(1, true);
+20 −5
Original line number Diff line number Diff line
@@ -2722,9 +2722,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    boolean isResizeable() {
        return isResizeable(/* checkPictureInPictureSupport */ true);
    }

    boolean isResizeable(boolean checkPictureInPictureSupport) {
        return mAtmService.mForceResizableActivities
                || ActivityInfo.isResizeableMode(info.resizeMode)
                || info.supportsPictureInPicture()
                || (info.supportsPictureInPicture() && checkPictureInPictureSupport)
                // If the activity can be embedded, it should inherit the bounds of task fragment.
                || isEmbedded();
    }
@@ -7679,10 +7683,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            // orientation with insets applied.
            return;
        }
        // Activity should be resizable if the task is.
        // Not using Task#isResizeable() or ActivityRecord#isResizeable() directly because app
        // compatibility testing showed that android:supportsPictureInPicture="true" alone is not
        // sufficient signal for not letterboxing an app.
        // TODO(214602463): Remove multi-window check since orientation and aspect ratio
        // restrictions should always be applied in multi-window.
        final boolean isResizeable = task != null
                ? task.isResizeable() || isResizeable()
                : isResizeable();
                // Activity should be resizable if the task is.
                ? task.isResizeable(/* checkPictureInPictureSupport */ false)
                        || isResizeable(/* checkPictureInPictureSupport */ false)
                : isResizeable(/* checkPictureInPictureSupport */ false);
        if (WindowConfiguration.inMultiWindowMode(windowingMode) && isResizeable) {
            // Ignore orientation request for resizable apps in multi window.
            return;
@@ -8211,8 +8221,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final float maxAspectRatio = info.getMaxAspectRatio();
        final Task rootTask = getRootTask();
        final float minAspectRatio = getMinAspectRatio();
        // Not using ActivityRecord#isResizeable() directly because app compatibility testing
        // showed that android:supportsPictureInPicture="true" alone is not sufficient signal for
        // not letterboxing an app.
        // TODO(214602463): Remove multi-window check since orientation and aspect ratio
        // restrictions should always be applied in multi-window.
        if (task == null || rootTask == null
                || (inMultiWindowMode() && !shouldCreateCompatDisplayInsets()
                || (inMultiWindowMode() && isResizeable(/* checkPictureInPictureSupport */ false)
                && !fixedOrientationLetterboxed)
                || (maxAspectRatio < 1 && minAspectRatio < 1 && desiredAspectRatio < 1)
                || isInVrUiMode(getConfiguration())) {
Loading