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

Commit 9b07c0e6 authored by Lyn Han's avatar Lyn Han Committed by Automerger Merge Worker
Browse files

Merge "Add bufferlogs for setExpandedHeight call stack" into tm-qpr-dev am:...

Merge "Add bufferlogs for setExpandedHeight call stack" into tm-qpr-dev am: b2d959cd am: 40fb9a81

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20500478



Change-Id: I2997e620a5e63dbb69bd94e3078cbcf4c1a177c3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7d61b28f 40fb9a81
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -102,6 +102,15 @@ public class LogModule {
        return factory.create("ShadeLog", 500, false);
        return factory.create("ShadeLog", 500, false);
    }
    }


    /** Provides a logging buffer for Shade height messages. */
    @Provides
    @SysUISingleton
    @ShadeHeightLog
    public static LogBuffer provideShadeHeightLogBuffer(LogBufferFactory factory) {
        return factory.create("ShadeHeightLog", 500 /* maxSize */);
    }


    /** Provides a logging buffer for all logs related to managing notification sections. */
    /** Provides a logging buffer for all logs related to managing notification sections. */
    @Provides
    @Provides
    @SysUISingleton
    @SysUISingleton
+33 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.log.dagger;

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

import com.android.systemui.plugins.log.LogBuffer;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;

import javax.inject.Qualifier;

/** A {@link LogBuffer} for Shade height changes. */
@Qualifier
@Documented
@Retention(RUNTIME)
public @interface ShadeHeightLog {
}
+17 −1
Original line number Original line Diff line number Diff line
@@ -634,6 +634,7 @@ public final class NotificationPanelViewController implements Dumpable {
    private final KeyguardBottomAreaViewModel mKeyguardBottomAreaViewModel;
    private final KeyguardBottomAreaViewModel mKeyguardBottomAreaViewModel;
    private final KeyguardBottomAreaInteractor mKeyguardBottomAreaInteractor;
    private final KeyguardBottomAreaInteractor mKeyguardBottomAreaInteractor;
    private float mMinExpandHeight;
    private float mMinExpandHeight;
    private ShadeHeightLogger mShadeHeightLogger;
    private boolean mPanelUpdateWhenAnimatorEnds;
    private boolean mPanelUpdateWhenAnimatorEnds;
    private boolean mHasVibratedOnOpen = false;
    private boolean mHasVibratedOnOpen = false;
    private int mFixedDuration = NO_FIXED_DURATION;
    private int mFixedDuration = NO_FIXED_DURATION;
@@ -713,6 +714,7 @@ public final class NotificationPanelViewController implements Dumpable {
            KeyguardUpdateMonitor keyguardUpdateMonitor,
            KeyguardUpdateMonitor keyguardUpdateMonitor,
            MetricsLogger metricsLogger,
            MetricsLogger metricsLogger,
            ShadeLogger shadeLogger,
            ShadeLogger shadeLogger,
            ShadeHeightLogger shadeHeightLogger,
            ConfigurationController configurationController,
            ConfigurationController configurationController,
            Provider<FlingAnimationUtils.Builder> flingAnimationUtilsBuilder,
            Provider<FlingAnimationUtils.Builder> flingAnimationUtilsBuilder,
            StatusBarTouchableRegionManager statusBarTouchableRegionManager,
            StatusBarTouchableRegionManager statusBarTouchableRegionManager,
@@ -774,6 +776,7 @@ public final class NotificationPanelViewController implements Dumpable {
        mLockscreenGestureLogger = lockscreenGestureLogger;
        mLockscreenGestureLogger = lockscreenGestureLogger;
        mShadeExpansionStateManager = shadeExpansionStateManager;
        mShadeExpansionStateManager = shadeExpansionStateManager;
        mShadeLog = shadeLogger;
        mShadeLog = shadeLogger;
        mShadeHeightLogger = shadeHeightLogger;
        mGutsManager = gutsManager;
        mGutsManager = gutsManager;
        mView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
        mView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
            @Override
            @Override
@@ -1819,6 +1822,7 @@ public final class NotificationPanelViewController implements Dumpable {
            waiting = true;
            waiting = true;
        } else {
        } else {
            resetViews(false /* animate */);
            resetViews(false /* animate */);
            mShadeHeightLogger.logFunctionCall("collapsePanel");
            setExpandedFraction(0); // just in case
            setExpandedFraction(0); // just in case
        }
        }
        if (!waiting) {
        if (!waiting) {
@@ -3695,6 +3699,7 @@ public final class NotificationPanelViewController implements Dumpable {
                                    beginJankMonitoring();
                                    beginJankMonitoring();
                                    fling(0  /* expand */);
                                    fling(0  /* expand */);
                                } else {
                                } else {
                                    mShadeHeightLogger.logFunctionCall("expand");
                                    setExpandedFraction(1f);
                                    setExpandedFraction(1f);
                                }
                                }
                                mInstantExpanding = false;
                                mInstantExpanding = false;
@@ -4759,6 +4764,7 @@ public final class NotificationPanelViewController implements Dumpable {
        mInitialTouchFromKeyguard = mKeyguardStateController.isShowing();
        mInitialTouchFromKeyguard = mKeyguardStateController.isShowing();
        if (startTracking) {
        if (startTracking) {
            mTouchSlopExceeded = true;
            mTouchSlopExceeded = true;
            mShadeHeightLogger.logFunctionCall("startExpandMotion");
            setExpandedHeight(mInitialOffsetOnTouch);
            setExpandedHeight(mInitialOffsetOnTouch);
            onTrackingStarted();
            onTrackingStarted();
        }
        }
@@ -4904,6 +4910,7 @@ public final class NotificationPanelViewController implements Dumpable {
    @VisibleForTesting
    @VisibleForTesting
    void setExpandedHeight(float height) {
    void setExpandedHeight(float height) {
        debugLog("setExpandedHeight(%.1f)", height);
        debugLog("setExpandedHeight(%.1f)", height);
        mShadeHeightLogger.logFunctionCall("setExpandedHeight");
        setExpandedHeightInternal(height);
        setExpandedHeightInternal(height);
    }
    }


@@ -4927,10 +4934,13 @@ public final class NotificationPanelViewController implements Dumpable {
            return;
            return;
        }
        }


        mShadeHeightLogger.logFunctionCall("updateExpandedHeightToMaxHeight");
        setExpandedHeight(currentMaxPanelHeight);
        setExpandedHeight(currentMaxPanelHeight);
    }
    }


    private void setExpandedHeightInternal(float h) {
    private void setExpandedHeightInternal(float h) {
        mShadeHeightLogger.logSetExpandedHeightInternal(h, mSystemClock.currentTimeMillis());

        if (isNaN(h)) {
        if (isNaN(h)) {
            Log.wtf(TAG, "ExpandedHeight set to NaN");
            Log.wtf(TAG, "ExpandedHeight set to NaN");
        }
        }
@@ -4987,7 +4997,9 @@ public final class NotificationPanelViewController implements Dumpable {


    /** Sets the expanded height relative to a number from 0 to 1. */
    /** Sets the expanded height relative to a number from 0 to 1. */
    public void setExpandedFraction(float frac) {
    public void setExpandedFraction(float frac) {
        setExpandedHeight(getMaxPanelTransitionDistance() * frac);
        final int maxDist = getMaxPanelTransitionDistance();
        mShadeHeightLogger.logFunctionCall("setExpandedFraction");
        setExpandedHeight(maxDist * frac);
    }
    }


    float getExpandedHeight() {
    float getExpandedHeight() {
@@ -5049,6 +5061,7 @@ public final class NotificationPanelViewController implements Dumpable {
    /** Collapses the shade instantly without animation. */
    /** Collapses the shade instantly without animation. */
    public void instantCollapse() {
    public void instantCollapse() {
        abortAnimations();
        abortAnimations();
        mShadeHeightLogger.logFunctionCall("instantCollapse");
        setExpandedFraction(0f);
        setExpandedFraction(0f);
        if (mExpanding) {
        if (mExpanding) {
            notifyExpandingFinished();
            notifyExpandingFinished();
@@ -5165,6 +5178,7 @@ public final class NotificationPanelViewController implements Dumpable {
                                        animator.getAnimatedFraction()));
                                        animator.getAnimatedFraction()));
                        setOverExpansionInternal(expansion, false /* isFromGesture */);
                        setOverExpansionInternal(expansion, false /* isFromGesture */);
                    }
                    }
                    mShadeHeightLogger.logFunctionCall("height animator update");
                    setExpandedHeightInternal((float) animation.getAnimatedValue());
                    setExpandedHeightInternal((float) animation.getAnimatedValue());
                });
                });
        return animator;
        return animator;
@@ -5639,6 +5653,7 @@ public final class NotificationPanelViewController implements Dumpable {
        mStatusBarStateController.setUpcomingState(KEYGUARD);
        mStatusBarStateController.setUpcomingState(KEYGUARD);
        mStatusBarStateListener.onStateChanged(KEYGUARD);
        mStatusBarStateListener.onStateChanged(KEYGUARD);
        mStatusBarStateListener.onDozeAmountChanged(1f, 1f);
        mStatusBarStateListener.onDozeAmountChanged(1f, 1f);
        mShadeHeightLogger.logFunctionCall("showAodUi");
        setExpandedFraction(1f);
        setExpandedFraction(1f);
    }
    }


@@ -6185,6 +6200,7 @@ public final class NotificationPanelViewController implements Dumpable {
                        // otherwise {@link NotificationStackScrollLayout}
                        // otherwise {@link NotificationStackScrollLayout}
                        // wrongly enables stack height updates at the start of lockscreen swipe-up
                        // wrongly enables stack height updates at the start of lockscreen swipe-up
                        mAmbientState.setSwipingUp(h <= 0);
                        mAmbientState.setSwipingUp(h <= 0);
                        mShadeHeightLogger.logFunctionCall("ACTION_MOVE");
                        setExpandedHeightInternal(newHeight);
                        setExpandedHeightInternal(newHeight);
                    }
                    }
                    break;
                    break;
+52 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.android.systemui.shade

import com.android.systemui.log.dagger.ShadeHeightLog
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel.DEBUG
import java.text.SimpleDateFormat
import javax.inject.Inject

private const val TAG = "ShadeHeightLogger"

/**
 * Log the call stack for [NotificationPanelViewController] setExpandedHeightInternal.
 *
 * Tracking bug: b/261593829
 */
class ShadeHeightLogger
@Inject constructor(
    @ShadeHeightLog private val buffer: LogBuffer,
) {

    private val dateFormat = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS")

    fun logFunctionCall(functionName: String) {
        buffer.log(TAG, DEBUG, {
            str1 = functionName
        }, {
            "$str1"
        })
    }

    fun logSetExpandedHeightInternal(h: Float, time: Long) {
        buffer.log(TAG, DEBUG, {
            double1 = h.toDouble()
            long1 = time
        }, {
            "setExpandedHeightInternal=$double1 time=${dateFormat.format(long1)}"
        })
    }
}
 No newline at end of file
+2 −0
Original line number Original line Diff line number Diff line
@@ -220,6 +220,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
    @Mock private KeyguardStateController mKeyguardStateController;
    @Mock private KeyguardStateController mKeyguardStateController;
    @Mock private DozeLog mDozeLog;
    @Mock private DozeLog mDozeLog;
    @Mock private ShadeLogger mShadeLog;
    @Mock private ShadeLogger mShadeLog;
    @Mock private ShadeHeightLogger mShadeHeightLogger;
    @Mock private CommandQueue mCommandQueue;
    @Mock private CommandQueue mCommandQueue;
    @Mock private VibratorHelper mVibratorHelper;
    @Mock private VibratorHelper mVibratorHelper;
    @Mock private LatencyTracker mLatencyTracker;
    @Mock private LatencyTracker mLatencyTracker;
@@ -457,6 +458,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
                mLatencyTracker, mPowerManager, mAccessibilityManager, 0, mUpdateMonitor,
                mLatencyTracker, mPowerManager, mAccessibilityManager, 0, mUpdateMonitor,
                mMetricsLogger,
                mMetricsLogger,
                mShadeLog,
                mShadeLog,
                mShadeHeightLogger,
                mConfigurationController,
                mConfigurationController,
                () -> flingAnimationUtilsBuilder, mStatusBarTouchableRegionManager,
                () -> flingAnimationUtilsBuilder, mStatusBarTouchableRegionManager,
                mConversationNotificationManager, mMediaHierarchyManager,
                mConversationNotificationManager, mMediaHierarchyManager,