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

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

Merge "Ensure DDC is not null" into sc-dev

parents 972aacc0 bc5281cc
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.display;

import android.content.Context;
import android.graphics.Rect;
import android.hardware.display.DisplayViewport;
import android.os.IBinder;
@@ -38,12 +39,14 @@ abstract class DisplayDevice {
    private final IBinder mDisplayToken;
    private final String mUniqueId;

    protected DisplayDeviceConfig mDisplayDeviceConfig;
    // The display device does not manage these properties itself, they are set by
    // the display manager service.  The display device shouldn't really be looking at these.
    private int mCurrentLayerStack = -1;
    private int mCurrentOrientation = -1;
    private Rect mCurrentLayerStackRect;
    private Rect mCurrentDisplayRect;
    private final Context mContext;

    // The display device owns its surface, but it should only set it
    // within a transaction from performTraversalLocked.
@@ -53,10 +56,13 @@ abstract class DisplayDevice {
    // Do not use for any other purpose.
    DisplayDeviceInfo mDebugLastLoggedDeviceInfo;

    public DisplayDevice(DisplayAdapter displayAdapter, IBinder displayToken, String uniqueId) {
    public DisplayDevice(DisplayAdapter displayAdapter, IBinder displayToken, String uniqueId,
            Context context) {
        mDisplayAdapter = displayAdapter;
        mDisplayToken = displayToken;
        mUniqueId = uniqueId;
        mDisplayDeviceConfig = null;
        mContext = context;
    }

    /**
@@ -74,7 +80,10 @@ abstract class DisplayDevice {
     * @return The DisplayDeviceConfig; {@code null} if not overridden.
     */
    public DisplayDeviceConfig getDisplayDeviceConfig() {
        return null;
        if (mDisplayDeviceConfig == null) {
            mDisplayDeviceConfig = loadDisplayDeviceConfig();
        }
        return mDisplayDeviceConfig;
    }

    /**
@@ -292,4 +301,8 @@ abstract class DisplayDevice {
        pw.println("mCurrentDisplayRect=" + mCurrentDisplayRect);
        pw.println("mCurrentSurface=" + mCurrentSurface);
    }

    private DisplayDeviceConfig loadDisplayDeviceConfig() {
        return DisplayDeviceConfig.create(mContext, false);
    }
}
+14 −1
Original line number Diff line number Diff line
@@ -120,7 +120,20 @@ public class DisplayDeviceConfig {
        // If no config can be loaded from any ddc xml at all,
        // prepare a whole config using the global config.xml.
        // Guaranteed not null
        if (isDefaultDisplay) {
        return create(context, isDefaultDisplay);
    }

    /**
     * Creates an instance using global values since no display device config xml exists.
     * Uses values from config or PowerManager.
     *
     * @param context
     * @param useConfigXml
     * @return A configuration instance.
     */
    public static DisplayDeviceConfig create(Context context, boolean useConfigXml) {
        DisplayDeviceConfig config;
        if (useConfigXml) {
            config = getConfigFromGlobalXml(context);
        } else {
            config = getConfigFromPmValues(context);
+5 −6
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import android.view.SurfaceControl;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.display.BrightnessSynchronizer;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.LocalServices;
import com.android.server.lights.LightsManager;
@@ -213,7 +212,6 @@ final class LocalDisplayAdapter extends DisplayAdapter {
        private SurfaceControl.DisplayMode mActiveSfDisplayMode;
        private Spline mSystemBrightnessToNits;
        private Spline mNitsToHalBrightness;
        private DisplayDeviceConfig mDisplayDeviceConfig;

        private DisplayEventReceiver.FrameRateOverride[] mFrameRateOverrides =
                new DisplayEventReceiver.FrameRateOverride[0];
@@ -222,7 +220,8 @@ final class LocalDisplayAdapter extends DisplayAdapter {
                SurfaceControl.StaticDisplayInfo staticDisplayInfo,
                SurfaceControl.DynamicDisplayInfo dynamicInfo,
                SurfaceControl.DesiredDisplayModeSpecs modeSpecs, boolean isDefaultDisplay) {
            super(LocalDisplayAdapter.this, displayToken, UNIQUE_ID_PREFIX + physicalDisplayId);
            super(LocalDisplayAdapter.this, displayToken, UNIQUE_ID_PREFIX + physicalDisplayId,
                    getContext());
            mPhysicalDisplayId = physicalDisplayId;
            mIsDefaultDisplay = isDefaultDisplay;
            updateDisplayPropertiesLocked(staticDisplayInfo, dynamicInfo, modeSpecs);
@@ -232,9 +231,6 @@ final class LocalDisplayAdapter extends DisplayAdapter {
            mAllmSupported = SurfaceControl.getAutoLowLatencyModeSupport(displayToken);
            mGameContentTypeSupported = SurfaceControl.getGameContentTypeSupport(displayToken);
            mDisplayDeviceConfig = null;
            // Defer configuration file loading
            BackgroundThread.getHandler().sendMessage(PooledLambda.obtainMessage(
                    LocalDisplayDevice::loadDisplayConfiguration, this));
        }

        @Override
@@ -413,6 +409,9 @@ final class LocalDisplayAdapter extends DisplayAdapter {

        @Override
        public DisplayDeviceConfig getDisplayDeviceConfig() {
            if (mDisplayDeviceConfig == null) {
                loadDisplayConfiguration();
            }
            return mDisplayDeviceConfig;
        }

+2 −1
Original line number Diff line number Diff line
@@ -281,7 +281,8 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
                List<OverlayMode> modes, int activeMode, int defaultMode,
                float refreshRate, long presentationDeadlineNanos,
                OverlayFlags flags, int state, SurfaceTexture surfaceTexture, int number) {
            super(OverlayDisplayAdapter.this, displayToken, UNIQUE_ID_PREFIX + number);
            super(OverlayDisplayAdapter.this, displayToken, UNIQUE_ID_PREFIX + number,
                    getContext());
            mName = name;
            mRefreshRate = refreshRate;
            mDisplayPresentationDeadlineNanos = presentationDeadlineNanos;
+1 −1
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ public class VirtualDisplayAdapter extends DisplayAdapter {
                int ownerUid, String ownerPackageName, Surface surface, int flags,
                Callback callback, String uniqueId, int uniqueIndex,
                VirtualDisplayConfig virtualDisplayConfig) {
            super(VirtualDisplayAdapter.this, displayToken, uniqueId);
            super(VirtualDisplayAdapter.this, displayToken, uniqueId, getContext());
            mAppToken = appToken;
            mOwnerUid = ownerUid;
            mOwnerPackageName = ownerPackageName;
Loading