Add unconditional burnin protection on 18.1 and 19.1, credit @arter97

Also skip the power on animation on 19.1, credit @kdrag0n

Signed-off-by: Tad <tad@spotco.us>
This commit is contained in:
Tad 2022-06-04 10:53:47 -04:00
parent 5df4058a15
commit 3da5613dfc
6 changed files with 665 additions and 0 deletions

View File

@ -250,4 +250,7 @@
<item>com.android.printspooler</item>
</string-array>
<!-- If true, the display will be shifted around. -->
<bool name="config_enableBurnInProtection">true</bool>
</resources>

View File

@ -0,0 +1,315 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Park Ju Hyung <qkrwngud825@gmail.com>
Date: Sun, 15 Jan 2017 03:33:04 +0900
Subject: [PATCH] SystemUI: add burnIn protection
Devices with OLED display suffer from
status-bar's notification items and nagivation bar's software keys
causing permanent burn-ins when used long-term.
Moving all items in the area
both horizontally and vertically workarounds this problem.
jrizzoli: integrate with runtime cmsdk preference
Linux4: removed settings preference
Change-Id: I35b04d1edff86a556adb3ad349569e5d82653f16
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Alex Naidis <alex.naidis@linux.com>
Signed-off-by: Thecrazyskull <anaskarbila@gmail.com>
Signed-off-by: Joey Rizzoli <joey@lineageos.org>
Signed-off-by: Francescodario Cuzzocrea <bosconovic@gmail.com>
---
.../SystemUI/res/values/lineage_dimens.xml | 3 +
.../statusbar/phone/NavigationBarView.java | 26 +++++
.../statusbar/phone/PhoneStatusBarView.java | 27 +++++
.../systemui/statusbar/phone/StatusBar.java | 13 +++
.../policy/BurnInProtectionController.java | 105 ++++++++++++++++++
5 files changed, 174 insertions(+)
create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/policy/BurnInProtectionController.java
diff --git a/packages/SystemUI/res/values/lineage_dimens.xml b/packages/SystemUI/res/values/lineage_dimens.xml
index 8f42ea0b873d..b567e952ff71 100644
--- a/packages/SystemUI/res/values/lineage_dimens.xml
+++ b/packages/SystemUI/res/values/lineage_dimens.xml
@@ -21,4 +21,7 @@
<!-- Largest size an avatar might need to be drawn in the power menu user picker -->
<dimen name="global_actions_avatar_size">24dp</dimen>
+
+ <dimen name="burnin_protection_horizontal_shift">3dp</dimen>
+ <dimen name="burnin_protection_vertical_shift">1dp</dimen>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index e28abe4e7e00..bd5b5c9ebcf1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -160,6 +160,13 @@ public class NavigationBarView extends FrameLayout implements
private FloatingRotationButton mFloatingRotationButton;
private RotationButtonController mRotationButtonController;
+ private int mBasePaddingBottom;
+ private int mBasePaddingLeft;
+ private int mBasePaddingRight;
+ private int mBasePaddingTop;
+
+ private ViewGroup mNavigationBarContents;
+
/**
* Helper that is responsible for showing the right toast when a disallowed activity operation
* occurred. In pinned mode, we show instructions on how to break out of this mode, whilst in
@@ -938,6 +945,18 @@ public class NavigationBarView extends FrameLayout implements
mRecentsOnboarding.hide(true);
}
+ public void shiftNavigationBarItems(int horizontalShift, int verticalShift) {
+ if (mNavigationBarContents == null) {
+ return;
+ }
+
+ mNavigationBarContents.setPaddingRelative(mBasePaddingLeft + horizontalShift,
+ mBasePaddingTop + verticalShift,
+ mBasePaddingRight + horizontalShift,
+ mBasePaddingBottom - verticalShift);
+ invalidate();
+ }
+
@Override
public void onFinishInflate() {
super.onFinishInflate();
@@ -946,6 +965,13 @@ public class NavigationBarView extends FrameLayout implements
getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);
+ mNavigationBarContents = (ViewGroup) findViewById(R.id.nav_buttons);
+
+ mBasePaddingLeft = mNavigationBarContents.getPaddingStart();
+ mBasePaddingTop = mNavigationBarContents.getPaddingTop();
+ mBasePaddingRight = mNavigationBarContents.getPaddingEnd();
+ mBasePaddingBottom = mNavigationBarContents.getPaddingBottom();
+
Divider divider = Dependency.get(Divider.class);
divider.registerInSplitScreenListener(mDockedListener);
updateOrientationViews();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 8856d892fcfb..53b1860ce5df 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -22,6 +22,7 @@ import static java.lang.Float.isNaN;
import android.annotation.Nullable;
import android.content.Context;
+import android.content.res.Resources;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.RemoteException;
@@ -61,6 +62,13 @@ public class PhoneStatusBarView extends PanelBar implements Callbacks {
StatusBar mBar;
+ private int mBasePaddingBottom;
+ private int mBasePaddingLeft;
+ private int mBasePaddingRight;
+ private int mBasePaddingTop;
+
+ private ViewGroup mStatusBarContents;
+
boolean mIsFullyOpenedPanel = false;
private ScrimController mScrimController;
private float mMinFraction;
@@ -131,12 +139,31 @@ public class PhoneStatusBarView extends PanelBar implements Callbacks {
mScrimController = scrimController;
}
+ public void shiftStatusBarItems(int horizontalShift, int verticalShift) {
+ if (mStatusBarContents == null) {
+ return;
+ }
+
+ mStatusBarContents.setPaddingRelative(mBasePaddingLeft + horizontalShift,
+ mBasePaddingTop + verticalShift,
+ mBasePaddingRight + horizontalShift,
+ mBasePaddingBottom - verticalShift);
+ invalidate();
+ }
+
@Override
public void onFinishInflate() {
mBattery = findViewById(R.id.battery);
mCutoutSpace = findViewById(R.id.cutout_space_view);
mCenterIconSpace = findViewById(R.id.centered_icon_area);
+ mStatusBarContents = (ViewGroup) findViewById(R.id.status_bar_contents);
+
+ mBasePaddingLeft = mStatusBarContents.getPaddingStart();
+ mBasePaddingTop = mStatusBarContents.getPaddingTop();
+ mBasePaddingRight = mStatusBarContents.getPaddingEnd();
+ mBasePaddingBottom = mStatusBarContents.getPaddingBottom();
+
updateResources();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index ebbefbe45244..8e20400e14c5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -221,6 +221,7 @@ import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
+import com.android.systemui.statusbar.policy.BurnInProtectionController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
@@ -369,6 +370,7 @@ public class StatusBar extends SystemUI implements DemoMode,
private final AutoHideController mAutoHideController;
@Nullable
private final KeyguardLiftController mKeyguardLiftController;
+ private BurnInProtectionController mBurnInProtectionController;
private final Point mCurrentDisplaySize = new Point();
@@ -1189,6 +1191,11 @@ public class StatusBar extends SystemUI implements DemoMode,
mStatusBarView.findViewById(R.id.notification_lights_out));
mNotificationShadeWindowViewController.setStatusBarView(mStatusBarView);
checkBarModes();
+ if (mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_enableBurnInProtection)) {
+ mBurnInProtectionController = new BurnInProtectionController(mContext,
+ this, mStatusBarView);
+ }
}).getFragmentManager()
.beginTransaction()
.replace(R.id.status_bar_container, new CollapsedStatusBarFragment(),
@@ -4009,6 +4016,9 @@ public class StatusBar extends SystemUI implements DemoMode,
updateNotificationPanelTouchState();
mNotificationShadeWindowViewController.cancelCurrentTouch();
+ if (mBurnInProtectionController != null) {
+ mBurnInProtectionController.stopShiftTimer(true);
+ }
if (mLaunchCameraOnFinishedGoingToSleep) {
mLaunchCameraOnFinishedGoingToSleep = false;
@@ -4065,6 +4075,9 @@ public class StatusBar extends SystemUI implements DemoMode,
mLaunchCameraWhenFinishedWaking = false;
}
updateScrimController();
+ if (mBurnInProtectionController != null) {
+ mBurnInProtectionController.startShiftTimer(true);
+ }
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BurnInProtectionController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BurnInProtectionController.java
new file mode 100644
index 000000000000..1976402d9323
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BurnInProtectionController.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2017 Paranoid Android
+ * Copyright 2020 The LineageOS 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.statusbar.policy;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.os.Handler;
+import android.os.Looper;
+import android.util.Log;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.NavigationBarView;
+import com.android.systemui.statusbar.phone.PhoneStatusBarView;
+import com.android.systemui.statusbar.phone.StatusBar;
+
+public class BurnInProtectionController {
+ private static final String TAG = "BurnInProtectionController";
+ private static final boolean DEBUG = false;
+ private static final long INTERVAL = 60000; // Milliseconds
+
+ private int mHorizontalShift = 0;
+ private int mVerticalShift = 0;
+ private int mHorizontalDirection = 1;
+ private int mVerticalDirection = 1;
+ private int mNavigationBarHorizontalMaxShift;
+ private int mNavigationBarVerticalMaxShift;
+ private int mHorizontalMaxShift;
+ private int mVerticalMaxShift;
+ private long mShiftInterval;
+
+ private final Handler mHandler = new Handler();
+ private final Runnable mRunnable = () -> {
+ shiftItems();
+ mHandler.postDelayed(this.mRunnable, INTERVAL);
+ };
+
+ private PhoneStatusBarView mPhoneStatusBarView;
+ private StatusBar mStatusBar;
+
+ private Context mContext;
+
+ public BurnInProtectionController(Context context, StatusBar statusBar,
+ PhoneStatusBarView phoneStatusBarView) {
+ mContext = context;
+
+ mPhoneStatusBarView = phoneStatusBarView;
+ mStatusBar = statusBar;
+
+ mHorizontalMaxShift = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.burnin_protection_horizontal_shift);
+ // total of ((vertical_max_shift - 1) * 2) pixels can be moved
+ mVerticalMaxShift = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.burnin_protection_vertical_shift) - 1;
+ }
+
+ public void startShiftTimer(boolean enabled) {
+ if (!enabled) return;
+ mHandler.removeCallbacks(mRunnable);
+ mHandler.postDelayed(mRunnable, INTERVAL);
+ if (DEBUG) Log.d(TAG, "Started shift timer");
+ }
+
+ public void stopShiftTimer(boolean enabled) {
+ if (!enabled) return;
+ mHandler.removeCallbacks(mRunnable);
+ if (DEBUG) Log.d(TAG, "Canceled shift timer");
+ }
+
+ private void shiftItems() {
+ mHorizontalShift += mHorizontalDirection;
+ if ((mHorizontalShift >= mHorizontalMaxShift) ||
+ (mHorizontalShift <= -mHorizontalMaxShift)) {
+ mHorizontalDirection *= -1;
+ }
+
+ mVerticalShift += mVerticalDirection;
+ if ((mVerticalShift >= mVerticalMaxShift) ||
+ (mVerticalShift <= -mVerticalMaxShift)) {
+ mVerticalDirection *= -1;
+ }
+
+ mPhoneStatusBarView.shiftStatusBarItems(mHorizontalShift, mVerticalShift);
+ NavigationBarView navigationBarView = mStatusBar.getNavigationBarView();
+
+ if (navigationBarView != null) {
+ navigationBarView.shiftNavigationBarItems(mHorizontalShift, mVerticalShift);
+ }
+ if (DEBUG) Log.d(TAG, "Shifting items\u2026");
+ }
+}

View File

@ -0,0 +1,29 @@
From bd956da828fe5ffce6daf5b30fce7b942cfa6794 Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Tue, 15 Dec 2020 16:58:40 -0800
Subject: [PATCH] SystemUI: Skip screen-on animation in all scenarios
Unlike turning the screen off, turning it on is a time-critical
operation that should be done as fast as possible without a slow
animation. It's not only noticeable when using capacitive fingerprint
sensors.
Change-Id: I87276128456afd9f535742477d9f76d025a12539
---
.../src/com/android/systemui/statusbar/phone/StatusBar.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 07bc9fcfaac9..f344d36db344 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -3737,8 +3737,7 @@ public void updateScrimController() {
boolean launchingAffordanceWithPreview =
mNotificationPanelViewController.isLaunchingAffordanceWithPreview();
- mScrimController.setLaunchingAffordanceWithPreview(launchingAffordanceWithPreview
- || mBiometricUnlockController.isWakeAndUnlock());
+ mScrimController.setLaunchingAffordanceWithPreview(true);
if (mStatusBarKeyguardViewManager.isShowingAlternateAuth()) {
if (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED) {

View File

@ -0,0 +1,315 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Park Ju Hyung <qkrwngud825@gmail.com>
Date: Sun, 15 Jan 2017 03:33:04 +0900
Subject: [PATCH] SystemUI: add burnIn protection
Devices with AMOLED display suffer from
status-bar's notification items and nagivation bar's software keys
causing permanent burn-ins when used long-term.
Moving all items in the area
both horizontally and vertically workarounds this problem.
jrizzoli: integrate with runtime cmsdk preference
Linux4: removed toggle from settings - the burnIn protection is always
enabled if the corresponding AOSP overlay is set to true
Change-Id: I35b04d1edff86a556adb3ad349569e5d82653f16
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Alex Naidis <alex.naidis@linux.com>
Signed-off-by: Thecrazyskull <anaskarbila@gmail.com>
Signed-off-by: Joey Rizzoli <joey@lineageos.org>
---
.../SystemUI/res/values/lineage_dimens.xml | 3 +
.../navigationbar/NavigationBarView.java | 26 +++++
.../statusbar/phone/PhoneStatusBarView.java | 27 +++++
.../systemui/statusbar/phone/StatusBar.java | 13 +++
.../policy/BurnInProtectionController.java | 105 ++++++++++++++++++
5 files changed, 174 insertions(+)
create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/policy/BurnInProtectionController.java
diff --git a/packages/SystemUI/res/values/lineage_dimens.xml b/packages/SystemUI/res/values/lineage_dimens.xml
index e1998ce3d3ab..dc59ccd794f7 100644
--- a/packages/SystemUI/res/values/lineage_dimens.xml
+++ b/packages/SystemUI/res/values/lineage_dimens.xml
@@ -21,4 +21,7 @@
<!-- Largest size an avatar might need to be drawn in the power menu user picker -->
<dimen name="global_actions_avatar_size">24dp</dimen>
+
+ <dimen name="burnin_protection_horizontal_shift">3dp</dimen>
+ <dimen name="burnin_protection_vertical_shift">1dp</dimen>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
index 3d6a7b41069c..051ce042cd8a 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
@@ -176,6 +176,13 @@ public class NavigationBarView extends FrameLayout implements
private RotationButtonController mRotationButtonController;
private NavigationBarOverlayController mNavBarOverlayController;
+ private int mBasePaddingBottom;
+ private int mBasePaddingLeft;
+ private int mBasePaddingRight;
+ private int mBasePaddingTop;
+
+ private ViewGroup mNavigationBarContents;
+
/**
* Helper that is responsible for showing the right toast when a disallowed activity operation
* occurred. In pinned mode, we show instructions on how to break out of this mode, whilst in
@@ -1006,12 +1013,31 @@ public class NavigationBarView extends FrameLayout implements
mContextualButtonGroup.setButtonVisibility(R.id.accessibility_button, visible);
}
+ public void shiftNavigationBarItems(int horizontalShift, int verticalShift) {
+ if (mNavigationBarContents == null) {
+ return;
+ }
+
+ mNavigationBarContents.setPaddingRelative(mBasePaddingLeft + horizontalShift,
+ mBasePaddingTop + verticalShift,
+ mBasePaddingRight + horizontalShift,
+ mBasePaddingBottom - verticalShift);
+ invalidate();
+ }
+
@Override
public void onFinishInflate() {
super.onFinishInflate();
mNavigationInflaterView = findViewById(R.id.navigation_inflater);
mNavigationInflaterView.setButtonDispatchers(mButtonDispatchers);
+
+ mNavigationBarContents = (ViewGroup) findViewById(R.id.nav_buttons);
+
+ mBasePaddingLeft = mNavigationBarContents.getPaddingStart();
+ mBasePaddingTop = mNavigationBarContents.getPaddingTop();
+ mBasePaddingRight = mNavigationBarContents.getPaddingEnd();
+ mBasePaddingBottom = mNavigationBarContents.getPaddingBottom();
updateOrientationViews();
reloadNavIcons();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index d7b6fe9c708f..ae6c080a2f60 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone;
import android.annotation.Nullable;
import android.content.Context;
+import android.content.res.Resources;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.inputmethodservice.InputMethodService;
@@ -60,6 +61,13 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
private final CommandQueue mCommandQueue;
private final StatusBarContentInsetsProvider mContentInsetsProvider;
+ private int mBasePaddingBottom;
+ private int mBasePaddingLeft;
+ private int mBasePaddingRight;
+ private int mBasePaddingTop;
+
+ private ViewGroup mStatusBarContents;
+
private DarkReceiver mBattery;
private ClockController mClockController;
private int mRotationOrientation = -1;
@@ -132,6 +140,18 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
mTouchEventHandler = handler;
}
+ public void shiftStatusBarItems(int horizontalShift, int verticalShift) {
+ if (mStatusBarContents == null) {
+ return;
+ }
+
+ mStatusBarContents.setPaddingRelative(mBasePaddingLeft + horizontalShift,
+ mBasePaddingTop + verticalShift,
+ mBasePaddingRight + horizontalShift,
+ mBasePaddingBottom - verticalShift);
+ invalidate();
+ }
+
@Override
public void onFinishInflate() {
mBattery = findViewById(R.id.battery);
@@ -139,6 +159,13 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
mCutoutSpace = findViewById(R.id.cutout_space_view);
mCenterIconSpace = findViewById(R.id.centered_icon_area);
+ mStatusBarContents = (ViewGroup) findViewById(R.id.status_bar_contents);
+
+ mBasePaddingLeft = mStatusBarContents.getPaddingStart();
+ mBasePaddingTop = mStatusBarContents.getPaddingTop();
+ mBasePaddingRight = mStatusBarContents.getPaddingEnd();
+ mBasePaddingBottom = mStatusBarContents.getPaddingBottom();
+
updateResources();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 00169546a799..da19bdc0de94 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -230,6 +230,7 @@ import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
+import com.android.systemui.statusbar.policy.BurnInProtectionController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
@@ -476,6 +477,7 @@ public class StatusBar extends SystemUI implements
protected LockscreenWallpaper mLockscreenWallpaper;
private final AutoHideController mAutoHideController;
private final CollapsedStatusBarFragmentLogger mCollapsedStatusBarFragmentLogger;
+ private BurnInProtectionController mBurnInProtectionController;
private final Point mCurrentDisplaySize = new Point();
@@ -1224,6 +1226,11 @@ public class StatusBar extends SystemUI implements
mStatusBarView.findViewById(R.id.notification_lights_out));
mNotificationShadeWindowViewController.setStatusBarView(mStatusBarView);
checkBarModes();
+ if (mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_enableBurnInProtection)) {
+ mBurnInProtectionController = new BurnInProtectionController(mContext,
+ this, mStatusBarView);
+ }
}).getFragmentManager()
.beginTransaction()
.replace(R.id.status_bar_container,
@@ -3697,6 +3704,9 @@ public class StatusBar extends SystemUI implements
updateNotificationPanelTouchState();
mNotificationShadeWindowViewController.cancelCurrentTouch();
+ if (mBurnInProtectionController != null) {
+ mBurnInProtectionController.stopShiftTimer(true);
+ }
if (mLaunchCameraOnFinishedGoingToSleep) {
mLaunchCameraOnFinishedGoingToSleep = false;
@@ -3783,6 +3793,9 @@ public class StatusBar extends SystemUI implements
}
}
updateScrimController();
+ if (mBurnInProtectionController != null) {
+ mBurnInProtectionController.startShiftTimer(true);
+ }
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BurnInProtectionController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BurnInProtectionController.java
new file mode 100644
index 000000000000..a7b7bd9e53dc
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BurnInProtectionController.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2017 Paranoid Android
+ * Copyright 2020 The LineageOS 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.statusbar.policy;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.os.Handler;
+import android.os.Looper;
+import android.util.Log;
+
+import com.android.systemui.R;
+import com.android.systemui.navigationbar.NavigationBarView;
+import com.android.systemui.statusbar.phone.PhoneStatusBarView;
+import com.android.systemui.statusbar.phone.StatusBar;
+
+public class BurnInProtectionController {
+ private static final String TAG = "BurnInProtectionController";
+ private static final boolean DEBUG = false;
+ private static final long INTERVAL = 60000; // Milliseconds
+
+ private int mHorizontalShift = 0;
+ private int mVerticalShift = 0;
+ private int mHorizontalDirection = 1;
+ private int mVerticalDirection = 1;
+ private int mNavigationBarHorizontalMaxShift;
+ private int mNavigationBarVerticalMaxShift;
+ private int mHorizontalMaxShift;
+ private int mVerticalMaxShift;
+ private long mShiftInterval;
+
+ private final Handler mHandler = new Handler();
+ private final Runnable mRunnable = () -> {
+ shiftItems();
+ mHandler.postDelayed(this.mRunnable, INTERVAL);
+ };
+
+ private PhoneStatusBarView mPhoneStatusBarView;
+ private StatusBar mStatusBar;
+
+ private Context mContext;
+
+ public BurnInProtectionController(Context context, StatusBar statusBar,
+ PhoneStatusBarView phoneStatusBarView) {
+ mContext = context;
+
+ mPhoneStatusBarView = phoneStatusBarView;
+ mStatusBar = statusBar;
+
+ mHorizontalMaxShift = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.burnin_protection_horizontal_shift);
+ // total of ((vertical_max_shift - 1) * 2) pixels can be moved
+ mVerticalMaxShift = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.burnin_protection_vertical_shift) - 1;
+ }
+
+ public void startShiftTimer(boolean enabled) {
+ if (!enabled) return;
+ mHandler.removeCallbacks(mRunnable);
+ mHandler.postDelayed(mRunnable, INTERVAL);
+ if (DEBUG) Log.d(TAG, "Started shift timer");
+ }
+
+ public void stopShiftTimer(boolean enabled) {
+ if (!enabled) return;
+ mHandler.removeCallbacks(mRunnable);
+ if (DEBUG) Log.d(TAG, "Canceled shift timer");
+ }
+
+ private void shiftItems() {
+ mHorizontalShift += mHorizontalDirection;
+ if ((mHorizontalShift >= mHorizontalMaxShift) ||
+ (mHorizontalShift <= -mHorizontalMaxShift)) {
+ mHorizontalDirection *= -1;
+ }
+
+ mVerticalShift += mVerticalDirection;
+ if ((mVerticalShift >= mVerticalMaxShift) ||
+ (mVerticalShift <= -mVerticalMaxShift)) {
+ mVerticalDirection *= -1;
+ }
+
+ mPhoneStatusBarView.shiftStatusBarItems(mHorizontalShift, mVerticalShift);
+ NavigationBarView navigationBarView = mStatusBar.getNavigationBarView();
+
+ if (navigationBarView != null) {
+ navigationBarView.shiftNavigationBarItems(mHorizontalShift, mVerticalShift);
+ }
+ if (DEBUG) Log.d(TAG, "Shifting items\u2026");
+ }
+}

View File

@ -160,6 +160,7 @@ applyPatch "$DOS_PATCHES/android_frameworks_base/0018-Exec_Based_Spawning-12.pat
sed -i 's/sys.spawn.exec/persist.security.exec_spawn_new/' core/java/com/android/internal/os/ZygoteConnection.java;
fi;
applyPatch "$DOS_PATCHES/android_frameworks_base/0019-Random_MAC.patch"; #Add option of always randomizing MAC addresses (GrapheneOS)
applyPatch "$DOS_PATCHES/android_frameworks_base/0020-Burnin_Protection.patch"; #SystemUI: add burnIn protection (arter97)
applyPatch "$DOS_PATCHES_COMMON/android_frameworks_base/0006-Do-not-throw-in-setAppOnInterfaceLocked.patch"; #Fix random reboots on broken kernels when an app has data restricted XXX: ugly (DivestOS)
applyPatch "$DOS_PATCHES_COMMON/android_frameworks_base/0007-ABI_Warning.patch"; #Warn when running activity from 32 bit app on ARM64 devices. (AOSP)
hardenLocationConf services/core/java/com/android/server/location/gps_debug.conf; #Harden the default GPS config

View File

@ -161,6 +161,8 @@ fi;
applyPatch "$DOS_PATCHES/android_frameworks_base/0020-Location_Indicators.patch"; #SystemUI: Use new privacy indicators for location (GrapheneOS)
applyPatch "$DOS_PATCHES/android_frameworks_base/0021-Boot_Animation.patch"; #Use basic boot animation (DivestOS)
applyPatch "$DOS_PATCHES/android_frameworks_base/0022-Ignore_StatementService_ANR.patch"; #Don't report statementservice crashes (GrapheneOS)
applyPatch "$DOS_PATCHES/android_frameworks_base/0023-Skip_Screen_Animation.patch"; #SystemUI: Skip screen-on animation in all scenarios (kdrag0n)
applyPatch "$DOS_PATCHES/android_frameworks_base/0024-Burnin_Protection.patch"; #SystemUI: add burnIn protection (arter97)
applyPatch "$DOS_PATCHES_COMMON/android_frameworks_base/0007-ABI_Warning.patch"; #Warn when running activity from 32 bit app on ARM64 devices. (AOSP)
applyPatch "$DOS_PATCHES/android_frameworks_base/326692.patch"; #Skip screen on animation when wake and unlock via biometrics (jesec)
hardenLocationConf services/core/java/com/android/server/location/gnss/gps_debug.conf; #Harden the default GPS config