Loading packages/SystemUI/res/values/dimens.xml +2 −4 Original line number Diff line number Diff line Loading @@ -650,7 +650,6 @@ <dimen name="keyguard_affordance_icon_width">24dp</dimen> <dimen name="keyguard_indication_margin_bottom">65dp</dimen> <dimen name="keyguard_indication_margin_bottom_ambient">16dp</dimen> <!-- The text size for battery level --> <dimen name="battery_level_text_size">12sp</dimen> Loading Loading @@ -939,9 +938,8 @@ burn-in on AOD. --> <dimen name="burn_in_prevention_offset_y">50dp</dimen> <!-- The maximum offset in either direction that the charging indication moves vertically to prevent burn-in on AOD. --> <dimen name="charging_indication_burn_in_prevention_offset_y">5dp</dimen> <!-- The maximum offset in either direction that icons move to prevent burn-in on AOD. --> <dimen name="default_burn_in_prevention_offset">5dp</dimen> <dimen name="corner_size">8dp</dimen> <dimen name="top_padding">0dp</dimen> Loading packages/SystemUI/src/com/android/systemui/doze/util/BurnInHelper.kt 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.doze.util import android.util.MathUtils private const val MILLIS_PER_MINUTES = 1000 * 60f private const val BURN_IN_PREVENTION_PERIOD_Y = 521f private const val BURN_IN_PREVENTION_PERIOD_X = 83f /** * Returns the translation offset that should be used to avoid burn in at * the current time (in pixels.) * * @param amplitude Maximum translation that will be interpolated. * @param xAxis If we're moving on X or Y. */ fun getBurnInOffset(amplitude: Int, xAxis: Boolean): Int { return zigzag(System.currentTimeMillis() / MILLIS_PER_MINUTES, amplitude.toFloat(), if (xAxis) BURN_IN_PREVENTION_PERIOD_X else BURN_IN_PREVENTION_PERIOD_Y).toInt() } /** * Implements a continuous, piecewise linear, periodic zig-zag function * * Can be thought of as a linear approximation of abs(sin(x))) * * @param period period of the function, ie. zigzag(x + period) == zigzag(x) * @param amplitude maximum value of the function * @return a value between 0 and amplitude */ private fun zigzag(x: Float, amplitude: Float, period: Float): Float { val xprime = x % period / (period / 2) val interpolationAmount = if (xprime <= 1) xprime else 2 - xprime return MathUtils.lerp(0f, amplitude, interpolationAmount) } No newline at end of file packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +0 −21 Original line number Diff line number Diff line Loading @@ -298,27 +298,6 @@ public class KeyguardIndicationController { if (mVisible) { // Walk down a precedence-ordered list of what indication // should be shown based on user or device state if (mDozing) { mTextView.setTextColor(Color.WHITE); if (!TextUtils.isEmpty(mTransientIndication)) { // When dozing we ignore any text color and use white instead, because // colors can be hard to read in low brightness. mTextView.switchIndication(mTransientIndication); } else if (mPowerPluggedIn) { String indication = computePowerIndication(); if (animate) { animateText(mTextView, indication); } else { mTextView.switchIndication(indication); } } else { String percentage = NumberFormat.getPercentInstance() .format(mBatteryLevel / 100f); mTextView.switchIndication(percentage); } return; } KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); int userId = KeyguardUpdateMonitor.getCurrentUser(); String trustGrantedIndication = getTrustGrantedIndication(); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +9 −15 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone; import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK; import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_BUTTON; import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_UNLOCK; import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_RIGHT_BUTTON; Loading Loading @@ -171,7 +172,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger(); private boolean mDozing; private int mIndicationBottomMargin; private int mIndicationBottomMarginAmbient; private float mDarkAmount; private int mBurnInXOffset; private int mBurnInYOffset; Loading Loading @@ -246,10 +246,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL mIndicationText = findViewById(R.id.keyguard_indication_text); mIndicationBottomMargin = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom); mIndicationBottomMarginAmbient = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom_ambient); mBurnInYOffset = getResources().getDimensionPixelSize( R.dimen.charging_indication_burn_in_prevention_offset_y); R.dimen.default_burn_in_prevention_offset); updateCameraVisibility(); mUnlockMethodCache = UnlockMethodCache.getInstance(getContext()); mUnlockMethodCache.addListener(this); Loading Loading @@ -320,10 +318,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL super.onConfigurationChanged(newConfig); mIndicationBottomMargin = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom); mIndicationBottomMarginAmbient = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom_ambient); mBurnInYOffset = getResources().getDimensionPixelSize( R.dimen.charging_indication_burn_in_prevention_offset_y); R.dimen.default_burn_in_prevention_offset); MarginLayoutParams mlp = (MarginLayoutParams) mIndicationArea.getLayoutParams(); if (mlp.bottomMargin != mIndicationBottomMargin) { mlp.bottomMargin = mIndicationBottomMargin; Loading Loading @@ -567,9 +563,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL return; } mDarkAmount = darkAmount; mIndicationArea.setAlpha(MathUtils.lerp(1f, 0.7f, darkAmount)); mIndicationArea.setTranslationY(MathUtils.lerp(0, mIndicationBottomMargin - mIndicationBottomMarginAmbient, darkAmount)); mIndicationArea.setAlpha(1f - darkAmount); } private static boolean isSuccessfulLaunch(int result) { Loading Loading @@ -842,10 +836,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL public void dozeTimeTick() { if (mDarkAmount == 1) { // Move indication every minute to avoid burn-in int dozeTranslation = mIndicationBottomMargin - mIndicationBottomMarginAmbient; int burnInYOffset = (int) (-mBurnInYOffset + Math.random() * mBurnInYOffset * 2); mIndicationArea.setTranslationY(dozeTranslation + burnInYOffset); // Move views every minute to avoid burn-in int burnInYOffset = getBurnInOffset(mBurnInYOffset * 2, false /* xAxis */) - mBurnInYOffset; mLockIcon.setTranslationY(burnInYOffset); } } Loading @@ -854,7 +848,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL return; } mBurnInXOffset = burnInXOffset; mIndicationArea.setTranslationX(burnInXOffset); mLockIcon.setTranslationX(burnInXOffset); } private class DefaultLeftButton implements IntentButton { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +3 −25 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.phone; import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; import static com.android.systemui.statusbar.notification.NotificationUtils.interpolate; import android.content.res.Resources; Loading @@ -30,10 +31,6 @@ import com.android.systemui.R; */ public class KeyguardClockPositionAlgorithm { private static final long MILLIS_PER_MINUTES = 1000 * 60; private static final float BURN_IN_PREVENTION_PERIOD_Y = 521; private static final float BURN_IN_PREVENTION_PERIOD_X = 83; /** * How much the clock height influences the shade position. * 0 means nothing, 1 means move the shade up by the height of the clock Loading Loading @@ -228,34 +225,15 @@ public class KeyguardClockPositionAlgorithm { } private float burnInPreventionOffsetY() { return zigzag(System.currentTimeMillis() / MILLIS_PER_MINUTES, mBurnInPreventionOffsetY * 2, BURN_IN_PREVENTION_PERIOD_Y) return getBurnInOffset(mBurnInPreventionOffsetY * 2, false /* xAxis */) - mBurnInPreventionOffsetY; } private float burnInPreventionOffsetX() { return zigzag(System.currentTimeMillis() / MILLIS_PER_MINUTES, mBurnInPreventionOffsetX * 2, BURN_IN_PREVENTION_PERIOD_X) return getBurnInOffset(mBurnInPreventionOffsetX * 2, true /* xAxis */) - mBurnInPreventionOffsetX; } /** * Implements a continuous, piecewise linear, periodic zig-zag function * * Can be thought of as a linear approximation of abs(sin(x))) * * @param period period of the function, ie. zigzag(x + period) == zigzag(x) * @param amplitude maximum value of the function * @return a value between 0 and amplitude */ private float zigzag(float x, float amplitude, float period) { float xprime = (x % period) / (period / 2); float interpolationAmount = (xprime <= 1) ? xprime : (2 - xprime); return interpolate(0, amplitude, interpolationAmount); } public static class Result { /** Loading Loading
packages/SystemUI/res/values/dimens.xml +2 −4 Original line number Diff line number Diff line Loading @@ -650,7 +650,6 @@ <dimen name="keyguard_affordance_icon_width">24dp</dimen> <dimen name="keyguard_indication_margin_bottom">65dp</dimen> <dimen name="keyguard_indication_margin_bottom_ambient">16dp</dimen> <!-- The text size for battery level --> <dimen name="battery_level_text_size">12sp</dimen> Loading Loading @@ -939,9 +938,8 @@ burn-in on AOD. --> <dimen name="burn_in_prevention_offset_y">50dp</dimen> <!-- The maximum offset in either direction that the charging indication moves vertically to prevent burn-in on AOD. --> <dimen name="charging_indication_burn_in_prevention_offset_y">5dp</dimen> <!-- The maximum offset in either direction that icons move to prevent burn-in on AOD. --> <dimen name="default_burn_in_prevention_offset">5dp</dimen> <dimen name="corner_size">8dp</dimen> <dimen name="top_padding">0dp</dimen> Loading
packages/SystemUI/src/com/android/systemui/doze/util/BurnInHelper.kt 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.doze.util import android.util.MathUtils private const val MILLIS_PER_MINUTES = 1000 * 60f private const val BURN_IN_PREVENTION_PERIOD_Y = 521f private const val BURN_IN_PREVENTION_PERIOD_X = 83f /** * Returns the translation offset that should be used to avoid burn in at * the current time (in pixels.) * * @param amplitude Maximum translation that will be interpolated. * @param xAxis If we're moving on X or Y. */ fun getBurnInOffset(amplitude: Int, xAxis: Boolean): Int { return zigzag(System.currentTimeMillis() / MILLIS_PER_MINUTES, amplitude.toFloat(), if (xAxis) BURN_IN_PREVENTION_PERIOD_X else BURN_IN_PREVENTION_PERIOD_Y).toInt() } /** * Implements a continuous, piecewise linear, periodic zig-zag function * * Can be thought of as a linear approximation of abs(sin(x))) * * @param period period of the function, ie. zigzag(x + period) == zigzag(x) * @param amplitude maximum value of the function * @return a value between 0 and amplitude */ private fun zigzag(x: Float, amplitude: Float, period: Float): Float { val xprime = x % period / (period / 2) val interpolationAmount = if (xprime <= 1) xprime else 2 - xprime return MathUtils.lerp(0f, amplitude, interpolationAmount) } No newline at end of file
packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +0 −21 Original line number Diff line number Diff line Loading @@ -298,27 +298,6 @@ public class KeyguardIndicationController { if (mVisible) { // Walk down a precedence-ordered list of what indication // should be shown based on user or device state if (mDozing) { mTextView.setTextColor(Color.WHITE); if (!TextUtils.isEmpty(mTransientIndication)) { // When dozing we ignore any text color and use white instead, because // colors can be hard to read in low brightness. mTextView.switchIndication(mTransientIndication); } else if (mPowerPluggedIn) { String indication = computePowerIndication(); if (animate) { animateText(mTextView, indication); } else { mTextView.switchIndication(indication); } } else { String percentage = NumberFormat.getPercentInstance() .format(mBatteryLevel / 100f); mTextView.switchIndication(percentage); } return; } KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); int userId = KeyguardUpdateMonitor.getCurrentUser(); String trustGrantedIndication = getTrustGrantedIndication(); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +9 −15 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone; import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK; import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_BUTTON; import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_UNLOCK; import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_RIGHT_BUTTON; Loading Loading @@ -171,7 +172,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger(); private boolean mDozing; private int mIndicationBottomMargin; private int mIndicationBottomMarginAmbient; private float mDarkAmount; private int mBurnInXOffset; private int mBurnInYOffset; Loading Loading @@ -246,10 +246,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL mIndicationText = findViewById(R.id.keyguard_indication_text); mIndicationBottomMargin = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom); mIndicationBottomMarginAmbient = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom_ambient); mBurnInYOffset = getResources().getDimensionPixelSize( R.dimen.charging_indication_burn_in_prevention_offset_y); R.dimen.default_burn_in_prevention_offset); updateCameraVisibility(); mUnlockMethodCache = UnlockMethodCache.getInstance(getContext()); mUnlockMethodCache.addListener(this); Loading Loading @@ -320,10 +318,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL super.onConfigurationChanged(newConfig); mIndicationBottomMargin = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom); mIndicationBottomMarginAmbient = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom_ambient); mBurnInYOffset = getResources().getDimensionPixelSize( R.dimen.charging_indication_burn_in_prevention_offset_y); R.dimen.default_burn_in_prevention_offset); MarginLayoutParams mlp = (MarginLayoutParams) mIndicationArea.getLayoutParams(); if (mlp.bottomMargin != mIndicationBottomMargin) { mlp.bottomMargin = mIndicationBottomMargin; Loading Loading @@ -567,9 +563,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL return; } mDarkAmount = darkAmount; mIndicationArea.setAlpha(MathUtils.lerp(1f, 0.7f, darkAmount)); mIndicationArea.setTranslationY(MathUtils.lerp(0, mIndicationBottomMargin - mIndicationBottomMarginAmbient, darkAmount)); mIndicationArea.setAlpha(1f - darkAmount); } private static boolean isSuccessfulLaunch(int result) { Loading Loading @@ -842,10 +836,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL public void dozeTimeTick() { if (mDarkAmount == 1) { // Move indication every minute to avoid burn-in int dozeTranslation = mIndicationBottomMargin - mIndicationBottomMarginAmbient; int burnInYOffset = (int) (-mBurnInYOffset + Math.random() * mBurnInYOffset * 2); mIndicationArea.setTranslationY(dozeTranslation + burnInYOffset); // Move views every minute to avoid burn-in int burnInYOffset = getBurnInOffset(mBurnInYOffset * 2, false /* xAxis */) - mBurnInYOffset; mLockIcon.setTranslationY(burnInYOffset); } } Loading @@ -854,7 +848,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL return; } mBurnInXOffset = burnInXOffset; mIndicationArea.setTranslationX(burnInXOffset); mLockIcon.setTranslationX(burnInXOffset); } private class DefaultLeftButton implements IntentButton { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +3 −25 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.phone; import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; import static com.android.systemui.statusbar.notification.NotificationUtils.interpolate; import android.content.res.Resources; Loading @@ -30,10 +31,6 @@ import com.android.systemui.R; */ public class KeyguardClockPositionAlgorithm { private static final long MILLIS_PER_MINUTES = 1000 * 60; private static final float BURN_IN_PREVENTION_PERIOD_Y = 521; private static final float BURN_IN_PREVENTION_PERIOD_X = 83; /** * How much the clock height influences the shade position. * 0 means nothing, 1 means move the shade up by the height of the clock Loading Loading @@ -228,34 +225,15 @@ public class KeyguardClockPositionAlgorithm { } private float burnInPreventionOffsetY() { return zigzag(System.currentTimeMillis() / MILLIS_PER_MINUTES, mBurnInPreventionOffsetY * 2, BURN_IN_PREVENTION_PERIOD_Y) return getBurnInOffset(mBurnInPreventionOffsetY * 2, false /* xAxis */) - mBurnInPreventionOffsetY; } private float burnInPreventionOffsetX() { return zigzag(System.currentTimeMillis() / MILLIS_PER_MINUTES, mBurnInPreventionOffsetX * 2, BURN_IN_PREVENTION_PERIOD_X) return getBurnInOffset(mBurnInPreventionOffsetX * 2, true /* xAxis */) - mBurnInPreventionOffsetX; } /** * Implements a continuous, piecewise linear, periodic zig-zag function * * Can be thought of as a linear approximation of abs(sin(x))) * * @param period period of the function, ie. zigzag(x + period) == zigzag(x) * @param amplitude maximum value of the function * @return a value between 0 and amplitude */ private float zigzag(float x, float amplitude, float period) { float xprime = (x % period) / (period / 2); float interpolationAmount = (xprime <= 1) ? xprime : (2 - xprime); return interpolate(0, amplitude, interpolationAmount); } public static class Result { /** Loading