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

Commit c1256911 authored by Mark Renouf's avatar Mark Renouf
Browse files

resolved conflicts for merge of 91239a0b to master

Change-Id: Ib30f0631278602f0363181021f1ad364e4ec2f8d
parent 60cd30d9
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -25,7 +25,11 @@ import android.content.IntentFilter;
import android.content.res.Resources;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManagerInternal;
import android.os.Build;
import android.os.Handler;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.util.Log;
import android.view.Display;

import com.android.server.LocalServices;
@@ -37,7 +41,7 @@ public class BurnInProtectionHelper implements DisplayManager.DisplayListener {
    private static final String TAG = "BurnInProtection";

    // Default value when max burnin radius is not set.
    public static final int BURN_IN_RADIUS_MAX_DEFAULT = -1;
    public static final int BURN_IN_MAX_RADIUS_DEFAULT = -1;

    private static final long BURNIN_PROTECTION_WAKEUP_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
    private static final long BURNIN_PROTECTION_MINIMAL_INTERVAL_MS = TimeUnit.SECONDS.toMillis(10);
@@ -75,22 +79,18 @@ public class BurnInProtectionHelper implements DisplayManager.DisplayListener {
        }
    };
    
    public BurnInProtectionHelper(Context context) {
    public BurnInProtectionHelper(Context context, int minHorizontalOffset,
            int maxHorizontalOffset, int minVerticalOffset, int maxVerticalOffset,
            int maxOffsetRadius) {
        final Resources resources = context.getResources();
        mMinHorizontalBurnInOffset = resources.getInteger(
                com.android.internal.R.integer.config_burnInProtectionMinHorizontalOffset);
        mMaxHorizontalBurnInOffset = resources.getInteger(
                com.android.internal.R.integer.config_burnInProtectionMaxHorizontalOffset);
        mMinVerticalBurnInOffset = resources.getInteger(
                com.android.internal.R.integer.config_burnInProtectionMinVerticalOffset);
        mMaxVerticalBurnInOffset = resources.getInteger(
                com.android.internal.R.integer.config_burnInProtectionMaxVerticalOffset);
        int burnInRadiusMax = resources.getInteger(
                com.android.internal.R.integer.config_burnInProtectionMaxRadius);
        if (burnInRadiusMax != BURN_IN_RADIUS_MAX_DEFAULT) {
            mBurnInRadiusMaxSquared = burnInRadiusMax * burnInRadiusMax;
        mMinHorizontalBurnInOffset = minHorizontalOffset;
        mMaxHorizontalBurnInOffset = maxHorizontalOffset;
        mMinVerticalBurnInOffset = minVerticalOffset;
        mMaxVerticalBurnInOffset = maxHorizontalOffset;
        if (maxOffsetRadius != BURN_IN_MAX_RADIUS_DEFAULT) {
            mBurnInRadiusMaxSquared = maxOffsetRadius * maxOffsetRadius;
        } else {
            mBurnInRadiusMaxSquared = BURN_IN_RADIUS_MAX_DEFAULT;
            mBurnInRadiusMaxSquared = BURN_IN_MAX_RADIUS_DEFAULT;
        }

        mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
@@ -175,7 +175,7 @@ public class BurnInProtectionHelper implements DisplayManager.DisplayListener {
                }
            }
            // If we are outside of the radius, let's try again.
        } while (mBurnInRadiusMaxSquared != BURN_IN_RADIUS_MAX_DEFAULT
        } while (mBurnInRadiusMaxSquared != BURN_IN_MAX_RADIUS_DEFAULT
                && mLastBurnInXOffset * mLastBurnInXOffset + mLastBurnInYOffset * mLastBurnInYOffset
                        > mBurnInRadiusMaxSquared);
    }
+42 −3
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.media.IAudioService;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.media.session.MediaSessionLegacyHelper;
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.FactoryTest;
@@ -94,6 +95,7 @@ import android.view.PhoneWindow;
import android.view.Surface;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewRootImpl;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
@@ -1185,6 +1187,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    };

    private boolean isRoundWindow() {
        return mContext.getResources().getBoolean(com.android.internal.R.bool.config_windowIsRound)
                || (Build.HARDWARE.contains("goldfish")
                && SystemProperties.getBoolean(ViewRootImpl.PROPERTY_EMULATOR_CIRCULAR, false));
    }

    /** {@inheritDoc} */
    @Override
    public void init(Context context, IWindowManager windowManager,
@@ -1194,9 +1202,40 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mWindowManagerFuncs = windowManagerFuncs;
        mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
        mDreamManagerInternal = LocalServices.getService(DreamManagerInternal.class);
        if (context.getResources().getBoolean(
                com.android.internal.R.bool.config_enableBurnInProtection)){
            mBurnInProtectionHelper = new BurnInProtectionHelper(context);

        // Init display burn-in protection
        boolean burnInProtectionEnabled = context.getResources().getBoolean(
                com.android.internal.R.bool.config_enableBurnInProtection);
        // Allow a system property to override this. Used by developer settings.
        boolean burnInProtectionDevMode =
                SystemProperties.getBoolean("persist.debug.force_burn_in", false);
        if (burnInProtectionEnabled || burnInProtectionDevMode) {
            final int minHorizontal;
            final int maxHorizontal;
            final int minVertical;
            final int maxVertical;
            final int maxRadius;
            if (burnInProtectionDevMode) {
                minHorizontal = -8;
                maxHorizontal = 8;
                minVertical = -8;
                maxVertical = -4;
                maxRadius = (isRoundWindow()) ? 6 : -1;
            } else {
                Resources resources = context.getResources();
                minHorizontal = resources.getInteger(
                        com.android.internal.R.integer.config_burnInProtectionMinHorizontalOffset);
                maxHorizontal = resources.getInteger(
                        com.android.internal.R.integer.config_burnInProtectionMaxHorizontalOffset);
                minVertical = resources.getInteger(
                        com.android.internal.R.integer.config_burnInProtectionMinVerticalOffset);
                maxVertical = resources.getInteger(
                        com.android.internal.R.integer.config_burnInProtectionMaxVerticalOffset);
                maxRadius = resources.getInteger(
                        com.android.internal.R.integer.config_burnInProtectionMaxRadius);
            }
            mBurnInProtectionHelper = new BurnInProtectionHelper(
                    context, minHorizontal, maxHorizontal, minVertical, maxVertical, maxRadius);
        }

        mHandler = new PolicyHandler();