-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 Updated for T Change-Id: I35b04d1edff86a556adb3ad349569e5d82653f16 Signed-off-by: Park Ju Hyung <[email protected]> Signed-off-by: Alex Naidis <[email protected]> Signed-off-by: Thecrazyskull <[email protected]> Signed-off-by: Joey Rizzoli <[email protected]>
- Loading branch information
Showing
5 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
packages/SystemUI/src/com/android/systemui/statusbar/policy/BurnInProtectionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.CentralSurfacesImpl; | ||
|
||
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 CentralSurfacesImpl mStatusBar; | ||
|
||
private Context mContext; | ||
|
||
public BurnInProtectionController(Context context, CentralSurfacesImpl 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"); | ||
} | ||
} |