2022-10-15 07:53:14 -04:00
|
|
|
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
|
|
|
|
|
2022-12-23 09:47:13 -05:00
|
|
|
Linux4: Removed toggle from settings - the burnIn protection is always
|
2022-10-15 07:53:14 -04:00
|
|
|
enabled if the corresponding AOSP overlay is set to true
|
2022-12-23 09:47:13 -05:00
|
|
|
Updated for T
|
2022-10-15 07:53:14 -04:00
|
|
|
|
|
|
|
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 +++++
|
2022-12-23 09:47:13 -05:00
|
|
|
.../statusbar/phone/CentralSurfacesImpl.java | 14 +++
|
2022-10-15 07:53:14 -04:00
|
|
|
.../statusbar/phone/PhoneStatusBarView.java | 27 +++++
|
|
|
|
.../policy/BurnInProtectionController.java | 105 ++++++++++++++++++
|
2022-12-23 09:47:13 -05:00
|
|
|
5 files changed, 175 insertions(+)
|
2022-10-15 07:53:14 -04:00
|
|
|
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
|
2023-06-20 18:13:52 -04:00
|
|
|
index bca52070edc3..d3f614f32086 100644
|
2022-10-15 07:53:14 -04:00
|
|
|
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
|
|
|
|
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
|
2023-03-19 20:23:48 -04:00
|
|
|
@@ -163,6 +163,13 @@ public class NavigationBarView extends FrameLayout implements TunerService.Tunab
|
2022-10-15 07:53:14 -04:00
|
|
|
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
|
2023-06-20 18:13:52 -04:00
|
|
|
@@ -888,12 +895,31 @@ public class NavigationBarView extends FrameLayout implements TunerService.Tunab
|
2022-10-15 07:53:14 -04:00
|
|
|
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();
|
|
|
|
}
|
2022-12-23 09:47:13 -05:00
|
|
|
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
|
2023-07-03 12:00:12 -04:00
|
|
|
index 5d9d85ec0e79..d77bdcaa4f4b 100644
|
2022-12-23 09:47:13 -05:00
|
|
|
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
|
|
|
|
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
|
2023-06-20 18:13:52 -04:00
|
|
|
@@ -229,6 +229,7 @@ import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule;
|
2023-03-19 20:23:48 -04:00
|
|
|
import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController;
|
2022-12-23 09:47:13 -05:00
|
|
|
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;
|
2023-06-20 18:13:52 -04:00
|
|
|
@@ -440,6 +441,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces, Tune
|
2022-12-23 09:47:13 -05:00
|
|
|
@Nullable
|
|
|
|
protected LockscreenWallpaper mLockscreenWallpaper;
|
|
|
|
private final AutoHideController mAutoHideController;
|
|
|
|
+ private BurnInProtectionController mBurnInProtectionController;
|
|
|
|
|
|
|
|
private final Point mCurrentDisplaySize = new Point();
|
|
|
|
|
2023-06-20 18:13:52 -04:00
|
|
|
@@ -1250,6 +1252,12 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces, Tune
|
2022-12-23 09:47:13 -05:00
|
|
|
mNotificationPanelViewController.updatePanelExpansionAndVisibility();
|
|
|
|
setBouncerShowingForStatusBarComponents(mBouncerShowing);
|
|
|
|
checkBarModes();
|
|
|
|
+
|
|
|
|
+ if (mContext.getResources().getBoolean(
|
|
|
|
+ com.android.internal.R.bool.config_enableBurnInProtection)) {
|
|
|
|
+ mBurnInProtectionController = new BurnInProtectionController(mContext,
|
|
|
|
+ this, mStatusBarView);
|
|
|
|
+ }
|
|
|
|
});
|
|
|
|
initializer.initializeStatusBar(mCentralSurfacesComponent);
|
|
|
|
|
2023-06-20 18:13:52 -04:00
|
|
|
@@ -3507,6 +3515,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces, Tune
|
2022-12-23 09:47:13 -05:00
|
|
|
|
|
|
|
updateNotificationPanelTouchState();
|
|
|
|
mNotificationShadeWindowViewController.cancelCurrentTouch();
|
|
|
|
+ if (mBurnInProtectionController != null) {
|
|
|
|
+ mBurnInProtectionController.stopShiftTimer(true);
|
|
|
|
+ }
|
|
|
|
if (mLaunchCameraOnFinishedGoingToSleep) {
|
|
|
|
mLaunchCameraOnFinishedGoingToSleep = false;
|
|
|
|
|
2023-07-03 12:00:12 -04:00
|
|
|
@@ -3651,6 +3662,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces, Tune
|
2022-12-23 09:47:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
updateScrimController();
|
|
|
|
+ if (mBurnInProtectionController != null) {
|
|
|
|
+ mBurnInProtectionController.startShiftTimer(true);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-10-15 07:53:14 -04:00
|
|
|
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
|
2023-06-20 18:13:52 -04:00
|
|
|
index 753f75c1433b..77c23d189b28 100644
|
2022-10-15 07:53:14 -04:00
|
|
|
--- 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;
|
2023-06-20 18:13:52 -04:00
|
|
|
@@ -64,6 +65,13 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
|
2022-10-15 07:53:14 -04:00
|
|
|
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;
|
2023-06-20 18:13:52 -04:00
|
|
|
@@ -137,6 +145,18 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
|
2022-10-15 07:53:14 -04:00
|
|
|
mTouchEventHandler = handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public void shiftStatusBarItems(int horizontalShift, int verticalShift) {
|
|
|
|
+ if (mStatusBarContents == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mStatusBarContents.setPaddingRelative(mBasePaddingLeft + horizontalShift,
|
|
|
|
+ mBasePaddingTop + verticalShift,
|
|
|
|
+ mBasePaddingRight + horizontalShift,
|
|
|
|
+ mBasePaddingBottom - verticalShift);
|
|
|
|
+ invalidate();
|
|
|
|
+ }
|
|
|
|
+
|
2023-03-19 20:23:48 -04:00
|
|
|
void init(StatusBarUserChipViewModel viewModel) {
|
|
|
|
StatusBarUserSwitcherContainer container = findViewById(R.id.user_switcher_container);
|
|
|
|
StatusBarUserChipViewBinder.bind(container, viewModel);
|
2023-06-20 18:13:52 -04:00
|
|
|
@@ -149,6 +169,13 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
|
2022-10-15 07:53:14 -04:00
|
|
|
mClockController = new ClockController(getContext(), this);
|
|
|
|
mCutoutSpace = findViewById(R.id.cutout_space_view);
|
|
|
|
|
|
|
|
+ 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/policy/BurnInProtectionController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BurnInProtectionController.java
|
|
|
|
new file mode 100644
|
2022-12-23 09:47:13 -05:00
|
|
|
index 000000000000..864d86ffd6a3
|
2022-10-15 07:53:14 -04:00
|
|
|
--- /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;
|
2022-12-23 09:47:13 -05:00
|
|
|
+import com.android.systemui.statusbar.phone.CentralSurfacesImpl;
|
2022-10-15 07:53:14 -04:00
|
|
|
+
|
|
|
|
+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;
|
2022-12-23 09:47:13 -05:00
|
|
|
+ private CentralSurfacesImpl mStatusBar;
|
2022-10-15 07:53:14 -04:00
|
|
|
+
|
|
|
|
+ private Context mContext;
|
|
|
|
+
|
2022-12-23 09:47:13 -05:00
|
|
|
+ public BurnInProtectionController(Context context, CentralSurfacesImpl statusBar,
|
2022-10-15 07:53:14 -04:00
|
|
|
+ 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");
|
|
|
|
+ }
|
|
|
|
+}
|