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

Commit cafe0c13 authored by Fiona Campbell's avatar Fiona Campbell Committed by Android (Google) Code Review
Browse files

Merge "Add Package Specific Verbose Logging" into udc-qpr-dev

parents 0bfdd749 644be08a
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -587,6 +587,9 @@ public final class ViewRootImpl implements ViewParent,
    @NonNull Display mDisplay;
    final String mBasePackageName;

    // If we would like to keep a particular eye on the corresponding package.
    final boolean mExtraDisplayListenerLogging;

    final int[] mTmpLocation = new int[2];

    final TypedValue mTmpValue = new TypedValue();
@@ -1136,6 +1139,8 @@ public final class ViewRootImpl implements ViewParent,
        mWindowLayout = windowLayout;
        mDisplay = display;
        mBasePackageName = context.getBasePackageName();
        final String name = DisplayProperties.debug_vri_package().orElse(null);
        mExtraDisplayListenerLogging = !TextUtils.isEmpty(name) && name.equals(mBasePackageName);
        mThread = Thread.currentThread();
        mLocation = new WindowLeaked(null);
        mLocation.fillInStackTrace();
@@ -1577,6 +1582,10 @@ public final class ViewRootImpl implements ViewParent,
                // We should update mAttachInfo.mDisplayState after registerDisplayListener
                // because displayState might be changed before registerDisplayListener.
                mAttachInfo.mDisplayState = mDisplay.getState();
                if (mExtraDisplayListenerLogging) {
                    Slog.i(mTag, "(" + mBasePackageName + ") Initial DisplayState: "
                            + mAttachInfo.mDisplayState, new Throwable());
                }
                if ((res & WindowManagerGlobal.ADD_FLAG_USE_BLAST) != 0) {
                    mUseBLASTAdapter = true;
                }
@@ -1661,6 +1670,9 @@ public final class ViewRootImpl implements ViewParent,
     * Register any kind of listeners if setView was success.
     */
    private void registerListeners() {
        if (mExtraDisplayListenerLogging) {
            Slog.i(mTag, "Register listeners: " + mBasePackageName);
        }
        mAccessibilityManager.addAccessibilityStateChangeListener(
                mAccessibilityInteractionConnectionManager, mHandler);
        mAccessibilityManager.addHighTextContrastStateChangeListener(
@@ -1686,6 +1698,9 @@ public final class ViewRootImpl implements ViewParent,
        DisplayManagerGlobal
                .getInstance()
                .unregisterDisplayListener(mDisplayListener);
        if (mExtraDisplayListenerLogging) {
            Slog.w(mTag, "Unregister listeners: " + mBasePackageName, new Throwable());
        }
    }

    private void setTag() {
@@ -2093,9 +2108,16 @@ public final class ViewRootImpl implements ViewParent,
    private final DisplayListener mDisplayListener = new DisplayListener() {
        @Override
        public void onDisplayChanged(int displayId) {
            if (mExtraDisplayListenerLogging) {
                Slog.i(mTag, "Received onDisplayChanged - " + mView);
            }
            if (mView != null && mDisplay.getDisplayId() == displayId) {
                final int oldDisplayState = mAttachInfo.mDisplayState;
                final int newDisplayState = mDisplay.getState();
                if (mExtraDisplayListenerLogging) {
                    Slog.i(mTag, "DisplayState - old: " + oldDisplayState
                            + ", new: " + newDisplayState);
                }
                if (oldDisplayState != newDisplayState) {
                    mAttachInfo.mDisplayState = newDisplayState;
                    pokeDrawLockIfNeeded();
+9 −2
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.provider.DeviceConfigInterface;
import android.provider.Settings;
import android.sysprop.DisplayProperties;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.EventLog;
@@ -485,6 +486,9 @@ public final class DisplayManagerService extends SystemService {

    private boolean mBootCompleted = false;

    // If we would like to keep a particular eye on a package, we can set the package name.
    private boolean mExtraDisplayEventLogging;

    private final BroadcastReceiver mIdleModeReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
@@ -565,6 +569,8 @@ public final class DisplayManagerService extends SystemService {
        mOverlayProperties = SurfaceControl.getOverlaySupport();
        mSystemReady = false;
        mConfigParameterProvider = new DeviceConfigParameterProvider(DeviceConfigInterface.REAL);
        final String name = DisplayProperties.debug_vri_package().orElse(null);
        mExtraDisplayEventLogging = !TextUtils.isEmpty(name);
    }

    public void setupSchedulerPolicies() {
@@ -2874,9 +2880,10 @@ public final class DisplayManagerService extends SystemService {
    // Delivers display event notifications to callbacks.
    private void deliverDisplayEvent(int displayId, ArraySet<Integer> uids,
            @DisplayEvent int event) {
        if (DEBUG) {
        if (DEBUG || mExtraDisplayEventLogging) {
            Slog.d(TAG, "Delivering display event: displayId="
                    + displayId + ", event=" + event);
                    + displayId + ", event=" + event
                    + (uids != null ? ", uids=" + uids : ""));
        }

        // Grab the lock and copy the callbacks.