resolved conflicts for merge of 91239a0b to master
Change-Id: Ib30f0631278602f0363181021f1ad364e4ec2f8d
diff --git a/services/core/java/com/android/server/policy/BurnInProtectionHelper.java b/services/core/java/com/android/server/policy/BurnInProtectionHelper.java
index b8a3155..b99c436 100644
--- a/services/core/java/com/android/server/policy/BurnInProtectionHelper.java
+++ b/services/core/java/com/android/server/policy/BurnInProtectionHelper.java
@@ -25,7 +25,11 @@
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 @@
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);
@@ -74,23 +78,19 @@
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);
@@ -175,7 +175,7 @@
}
}
// 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/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 62e7af4..29a7fd3 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -49,6 +49,7 @@
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.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 @@
}
};
+ 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 @@
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();