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

Commit f2d695e6 authored by Julia Tuttle's avatar Julia Tuttle Committed by Android (Google) Code Review
Browse files

Merge changes from topic "cherrypicker-L46800030003199711:N12400030051438895" into 24D1-dev

* changes:
  NSSL: requestLayout on split shade change
  NSSL: Apply skinny notifs based on split shade state
  NSSL: Log more about side padding decisions
  NSSL: Log actual orientation on updateSidePadding
parents 2792547d 4dbe7a4c
Loading
Loading
Loading
Loading
+53 −10
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.Trace;
import android.provider.Settings;
import android.util.AttributeSet;
@@ -221,6 +222,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private float mQsExpansionFraction;
    private final int mSplitShadeMinContentHeight;
    private String mLastUpdateSidePaddingDumpString;
    private long mLastUpdateSidePaddingElapsedRealtime;
    private String mLastInitViewDumpString;
    private long mLastInitViewElapsedRealtime;

    /**
     * The algorithm which calculates the properties for our children
@@ -1094,17 +1098,34 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mOverflingDistance = configuration.getScaledOverflingDistance();

        Resources res = context.getResources();
        final boolean isSmallScreenLandscape = res.getBoolean(R.bool.is_small_screen_landscape);
        boolean useSmallLandscapeLockscreenResources = mIsSmallLandscapeLockscreenEnabled
                && res.getBoolean(R.bool.is_small_screen_landscape);
                && isSmallScreenLandscape;
        // TODO (b/293252410) remove condition here when flag is launched
        //  Instead update the config_skinnyNotifsInLandscape to be false whenever
        //  is_small_screen_landscape is true. Then, only use the config_skinnyNotifsInLandscape.
        final boolean configSkinnyNotifsInLandscape = res.getBoolean(
                R.bool.config_skinnyNotifsInLandscape);
        if (useSmallLandscapeLockscreenResources) {
            mSkinnyNotifsInLandscape = false;
        } else {
            mSkinnyNotifsInLandscape = res.getBoolean(
                    R.bool.config_skinnyNotifsInLandscape);
            mSkinnyNotifsInLandscape = configSkinnyNotifsInLandscape;
        }

        mLastInitViewDumpString =
                "mIsSmallLandscapeLockscreenEnabled=" + mIsSmallLandscapeLockscreenEnabled
                        + " isSmallScreenLandscape=" + isSmallScreenLandscape
                        + " useSmallLandscapeLockscreenResources="
                        + useSmallLandscapeLockscreenResources
                        + " skinnyNotifsInLandscape=" + configSkinnyNotifsInLandscape
                        + " mSkinnyNotifsInLandscape=" + mSkinnyNotifsInLandscape;
        mLastInitViewElapsedRealtime = SystemClock.elapsedRealtime();

        if (DEBUG_UPDATE_SIDE_PADDING) {
            Log.v(TAG, "initView @ elapsedRealtime " + mLastInitViewElapsedRealtime + ": "
                    + mLastInitViewDumpString);
        }

        mGapHeight = res.getDimensionPixelSize(R.dimen.notification_section_divider_height);
        mStackScrollAlgorithm.initView(context);
        mStateAnimator.initView(context);
@@ -1127,24 +1148,34 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    void updateSidePadding(int viewWidth) {
        final boolean portrait =
                getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
        final int orientation = getResources().getConfiguration().orientation;

        mLastUpdateSidePaddingDumpString = "viewWidth=" + viewWidth
                + " skinnyNotifsInLandscape=" + mSkinnyNotifsInLandscape
                + " portrait=" + portrait;
                + " orientation=" + orientation;
        mLastUpdateSidePaddingElapsedRealtime = SystemClock.elapsedRealtime();

        if (DEBUG_UPDATE_SIDE_PADDING) {
            Log.v(TAG, "updateSidePadding: " + mLastUpdateSidePaddingDumpString);
            Log.v(TAG,
                    "updateSidePadding @ elapsedRealtime " + mLastUpdateSidePaddingElapsedRealtime
                            + ": " + mLastUpdateSidePaddingDumpString);
        }

        if (viewWidth == 0 || !mSkinnyNotifsInLandscape) {
        if (viewWidth == 0) {
            Log.e(TAG, "updateSidePadding: viewWidth is zero");
            mSidePaddings = mMinimumPaddings;
            return;
        }

        // Portrait is easy, just use the dimen for paddings
        if (portrait) {
        if (orientation == Configuration.ORIENTATION_PORTRAIT) {
            mSidePaddings = mMinimumPaddings;
            return;
        }

        if (mShouldUseSplitNotificationShade) {
            if (mSkinnyNotifsInLandscape) {
                Log.e(TAG, "updateSidePadding: mSkinnyNotifsInLandscape has betrayed us!");
            }
            mSidePaddings = mMinimumPaddings;
            return;
        }
@@ -5313,6 +5344,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable

    public void dump(PrintWriter pwOriginal, String[] args) {
        IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal);
        final long elapsedRealtime = SystemClock.elapsedRealtime();
        pw.println("Internal state:");
        DumpUtilsKt.withIncreasedIndent(pw, () -> {
            println(pw, "pulsing", mPulsing);
@@ -5343,7 +5375,17 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            println(pw, "minimumPaddings", mMinimumPaddings);
            println(pw, "qsTilePadding", mQsTilePadding);
            println(pw, "sidePaddings", mSidePaddings);
            println(pw, "elapsedRealtime", elapsedRealtime);
            println(pw, "lastInitView", mLastInitViewDumpString);
            println(pw, "lastInitViewElapsedRealtime", mLastInitViewElapsedRealtime);
            println(pw, "lastInitViewMillisAgo", elapsedRealtime - mLastInitViewElapsedRealtime);
            println(pw, "shouldUseSplitNotificationShade", mShouldUseSplitNotificationShade);
            println(pw, "lastUpdateSidePadding", mLastUpdateSidePaddingDumpString);
            println(pw, "lastUpdateSidePaddingElapsedRealtime",
                    mLastUpdateSidePaddingElapsedRealtime);
            println(pw, "lastUpdateSidePaddingMillisAgo",
                    elapsedRealtime - mLastUpdateSidePaddingElapsedRealtime);
            println(pw, "isSmallLandscapeLockscreenEnabled", mIsSmallLandscapeLockscreenEnabled);
            mNotificationStackSizeCalculator.dump(pw, args);
        });
        pw.println();
@@ -5922,6 +5964,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            mAmbientState.setUseSplitShade(split);
            updateDismissBehavior();
            updateUseRoundedRectClipping();
            requestLayout();
        }
    }