diff options
-rw-r--r-- | policy/src/com/android/internal/policy/impl/BurnInProtectionHelper.java | 32 | ||||
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 45 |
2 files changed, 57 insertions, 20 deletions
diff --git a/policy/src/com/android/internal/policy/impl/BurnInProtectionHelper.java b/policy/src/com/android/internal/policy/impl/BurnInProtectionHelper.java index 19fe262..ed9a16f 100644 --- a/policy/src/com/android/internal/policy/impl/BurnInProtectionHelper.java +++ b/policy/src/com/android/internal/policy/impl/BurnInProtectionHelper.java @@ -9,8 +9,10 @@ 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; @@ -23,7 +25,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); @@ -60,23 +62,19 @@ public class BurnInProtectionHelper implements DisplayManager.DisplayListener { updateBurnInProtection(); } }; - - 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); @@ -161,7 +159,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); } diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index ccbef6b..37d34f5 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -47,6 +47,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; @@ -91,6 +92,7 @@ import android.view.MotionEvent; 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; @@ -1175,6 +1177,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, @@ -1184,9 +1192,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(); |