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

Commit a1568c29 authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Add VisualStabilityLog

Bug: 332558345
Test: manual: `adb shell cmd statusbar echo -t VisualStability:v`, turn screen on and off, open and close shade
Flag: EXEMPT logging
Change-Id: I930d63067f95ec499d6e97b3344854febbf45036
parent 489fdc05
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
    @Mock private HeadsUpManager mHeadsUpManager;
    @Mock private VisibilityLocationProvider mVisibilityLocationProvider;
    @Mock private VisualStabilityProvider mVisualStabilityProvider;
    @Mock private VisualStabilityCoordinatorLogger mLogger;

    @Captor private ArgumentCaptor<WakefulnessLifecycle.Observer> mWakefulnessObserverCaptor;
    @Captor private ArgumentCaptor<StatusBarStateController.StateListener> mSBStateListenerCaptor;
@@ -128,7 +129,8 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
                mVisibilityLocationProvider,
                mVisualStabilityProvider,
                mWakefulnessLifecycle,
                mKosmos.getCommunalInteractor());
                mKosmos.getCommunalInteractor(),
                mLogger);
        mCoordinator.attach(mNotifPipeline);
        mTestScope.getTestScheduler().runCurrent();

+8 −0
Original line number Diff line number Diff line
@@ -169,6 +169,14 @@ public class LogModule {
        return factory.create("NotifRemoteInputLog", 50 /* maxSize */, false /* systrace */);
    }

    /** Provides a logging buffer for all logs related to notification visual stability. */
    @Provides
    @SysUISingleton
    @VisualStabilityLog
    public static LogBuffer provideVisualStabilityLogBuffer(LogBufferFactory factory) {
        return factory.create("VisualStabilityLog", 50 /* maxSize */, false /* systrace */);
    }

    /** Provides a logging buffer for all logs related to keyguard media controller. */
    @Provides
    @SysUISingleton
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 javax.inject.Qualifier

/** A [com.android.systemui.log.LogBuffer] for visual stability-related messages. */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class VisualStabilityLog
+10 −12
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ package com.android.systemui.statusbar.notification.collection.coordinator;

import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;

@@ -41,7 +39,6 @@ import com.android.systemui.statusbar.notification.collection.provider.VisualSta
import com.android.systemui.statusbar.notification.domain.interactor.SeenNotificationsInteractor;
import com.android.systemui.statusbar.notification.shared.NotificationMinimalismPrototype;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.util.Compile;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.kotlin.JavaAdapter;

@@ -61,8 +58,6 @@ import javax.inject.Inject;
// TODO(b/204468557): Move to @CoordinatorScope
@SysUISingleton
public class VisualStabilityCoordinator implements Coordinator, Dumpable {
    public static final String TAG = "VisualStability";
    public static final boolean DEBUG = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE);
    private final DelayableExecutor mDelayableExecutor;
    private final HeadsUpManager mHeadsUpManager;
    private final SeenNotificationsInteractor mSeenNotificationsInteractor;
@@ -73,6 +68,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
    private final VisualStabilityProvider mVisualStabilityProvider;
    private final WakefulnessLifecycle mWakefulnessLifecycle;
    private final CommunalInteractor mCommunalInteractor;
    private final VisualStabilityCoordinatorLogger mLogger;

    private boolean mSleepy = true;
    private boolean mFullyDozed;
@@ -109,7 +105,8 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
            VisibilityLocationProvider visibilityLocationProvider,
            VisualStabilityProvider visualStabilityProvider,
            WakefulnessLifecycle wakefulnessLifecycle,
            CommunalInteractor communalInteractor) {
            CommunalInteractor communalInteractor,
            VisualStabilityCoordinatorLogger logger) {
        mHeadsUpManager = headsUpManager;
        mShadeAnimationInteractor = shadeAnimationInteractor;
        mJavaAdapter = javaAdapter;
@@ -120,6 +117,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
        mStatusBarStateController = statusBarStateController;
        mDelayableExecutor = delayableExecutor;
        mCommunalInteractor = communalInteractor;
        mLogger = logger;

        dumpManager.registerDumpable(this);
    }
@@ -221,12 +219,12 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
        boolean wasReorderingAllowed = mReorderingAllowed;
        mPipelineRunAllowed = !isPanelCollapsingOrLaunchingActivity();
        mReorderingAllowed = isReorderingAllowed();
        if (DEBUG && (wasPipelineRunAllowed != mPipelineRunAllowed
                || wasReorderingAllowed != mReorderingAllowed)) {
            Log.d(TAG, "Stability allowances changed:"
                    + "  pipelineRunAllowed " + wasPipelineRunAllowed + "->" + mPipelineRunAllowed
                    + "  reorderingAllowed " + wasReorderingAllowed + "->" + mReorderingAllowed
                    + "  when setting " + field + "=" + value);
        if (wasPipelineRunAllowed != mPipelineRunAllowed
                || wasReorderingAllowed != mReorderingAllowed) {
            mLogger.logAllowancesChanged(
                    wasPipelineRunAllowed, mPipelineRunAllowed,
                    wasReorderingAllowed, mReorderingAllowed,
                    field, value);
        }
        if (mPipelineRunAllowed && mIsSuppressingPipelineRun) {
            mNotifStabilityManager.invalidateList("pipeline run suppression ended");
+56 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.statusbar.notification.collection.coordinator

import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel
import com.android.systemui.log.dagger.VisualStabilityLog
import javax.inject.Inject

private const val TAG = "VisualStability"

class VisualStabilityCoordinatorLogger
@Inject
constructor(@VisualStabilityLog private val buffer: LogBuffer) {
    fun logAllowancesChanged(
        wasRunAllowed: Boolean,
        isRunAllowed: Boolean,
        wasReorderingAllowed: Boolean,
        isReorderingAllowed: Boolean,
        field: String,
        value: Boolean
    ) {
        buffer.log(
            TAG,
            LogLevel.DEBUG,
            {
                bool1 = wasRunAllowed
                bool2 = isRunAllowed
                bool3 = wasReorderingAllowed
                bool4 = isReorderingAllowed
                str1 = field
                str2 = value.toString()
            },
            {
                "stability allowances changed:" +
                    " pipelineRunAllowed $bool1->$bool2" +
                    " reorderingAllowed $bool3->$bool4" +
                    " when setting $str1=$str2"
            }
        )
    }
}