android8.1系统刘海屏适配修改记录
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index c670351..01dadb2 100644 (file)
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -22866,7 +22866,20 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* and {@link #SYSTEM_UI_FLAG_IMMERSIVE_STICKY}.
*/
public void setSystemUiVisibility(int visibility) {
- if (visibility != mSystemUiVisibility) {
+ /**6210-add-notch adaptation-#8954-zhoujy-190329-start*/
+ if(getDisplay() != null && (getDisplay().getRotation() == Surface.ROTATION_270 || getDisplay().getRotation() == Surface.ROTATION_90)) {
+ visibility &= ~SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+ visibility &= ~SYSTEM_UI_FLAG_LAYOUT_STABLE;
+ visibility &= ~SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ visibility &= ~SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+ visibility &= ~SYSTEM_UI_FLAG_FULLSCREEN;
+ // visibility &= ~SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
+ visibility &= ~SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+ // visibility &= ~SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
+
+ }
+ /**6210-add-notch adaptation-#8954-zhoujy-190329-end*/
+ if (visibility != mSystemUiVisibility) {
mSystemUiVisibility = visibility;
if (mParent != null && mAttachInfo != null && !mAttachInfo.mRecomputeGlobalAttributes) {
mParent.recomputeViewAttributes(this);
-------刘海屏全屏显示就不能再刘海屏位置显示黑框,主要是去除全屏显示
1552 /* package */ WindowInsets getWindowInsets(boolean forceConstruct) {
1553 if (mLastWindowInsets == null || forceConstruct) {
1554 mDispatchContentInsets.set(mAttachInfo.mContentInsets);
1555 mDispatchStableInsets.set(mAttachInfo.mStableInsets);
1556 Rect contentInsets = mDispatchContentInsets;
1557 Rect stableInsets = mDispatchStableInsets;
1558 // For dispatch we preserve old logic, but for direct requests from Views we allow to
1559 // immediately use pending insets.
1560 if (!forceConstruct
1561 && (!mPendingContentInsets.equals(contentInsets) ||
1562 !mPendingStableInsets.equals(stableInsets))) {
1563 contentInsets = mPendingContentInsets;
1564 stableInsets = mPendingStableInsets;
1565 }
1566 Rect outsets = mAttachInfo.mOutsets;
1567 if (outsets.left > 0 || outsets.top > 0 || outsets.right > 0 || outsets.bottom > 0) {
1568 contentInsets = new Rect(contentInsets.left + outsets.left,
1569 contentInsets.top + outsets.top, contentInsets.right + outsets.right,
1570 contentInsets.bottom + outsets.bottom);
1571 }
1572 mLastWindowInsets = new WindowInsets(contentInsets,
1573 null /* windowDecorInsets */, stableInsets,
1574 mContext.getResources().getConfiguration().isScreenRound(),
1575 mAttachInfo.mAlwaysConsumeNavBar);
1576 }
1577 /**6210-add -notch adaptation-#8954-zhoujy-190329-start*/
1578 if(mDisplay != null && mDisplay.getRotation() == Surface.ROTATION_0) {
1579 // mLastWindowInsets = mLastWindowInsets.replaceSystemWindowInsets(mLastWindowInsets.getSystemWindowInsetLeft(), 110,
1580 // mLastWindowInsets.getSystemWindowInsetRight(), mLastWindowInsets.getSystemWindowInsetBottom());
1581 // mLastWindowInsets = mLastWindowInsets.replaceWindowDecorInsets(mLastWindowInsets.getWindowDecorInsetLeft(), 110,
1582 // mLastWindowInsets.getWindowDecorInsetRight(),mLastWindowInsets.getWindowDecorInsetBottom());
1583 // mLastWindowInsets = mLastWindowInsets.replaceStableInsets(mLastWindowInsets.getStableInsetLeft(), 110,
1584 // mLastWindowInsets.getStableInsetRight(), mLastWindowInsets.getStableInsetBottom());
1585
1586 } else if(mDisplay.getRotation() ==Surface.ROTATION_90) {
1587 mLastWindowInsets = mLastWindowInsets.replaceSystemWindowInsets(110, 0,
1588 mLastWindowInsets.getSystemWindowInsetRight(), mLastWindowInsets.getSystemWindowInsetBottom());
1589 mLastWindowInsets = mLastWindowInsets.replaceWindowDecorInsets(110, 0,
1590 mLastWindowInsets.getWindowDecorInsetRight(),mLastWindowInsets.getWindowDecorInsetBottom());
1591 mLastWindowInsets = mLastWindowInsets.replaceStableInsets(110, 0,
1592 mLastWindowInsets.getStableInsetRight(),mLastWindowInsets.getStableInsetBottom());
1593 } else if(mDisplay.getRotation() == Surface.ROTATION_270) {
1594 mLastWindowInsets = mLastWindowInsets.replaceSystemWindowInsets(mLastWindowInsets.getSystemWindowInsetLeft(), 0,
1595 110, mLastWindowInsets.getSystemWindowInsetBottom());
1596 mLastWindowInsets = mLastWindowInsets.replaceWindowDecorInsets(mLastWindowInsets.getWindowDecorInsetLeft(), 0,
1597 110,mLastWindowInsets.getWindowDecorInsetBottom());
1598 mLastWindowInsets = mLastWindowInsets.replaceStableInsets(mLastWindowInsets.getStableInsetLeft(), 0,
1599 110,mLastWindowInsets.getStableInsetBottom());
1600 }
1601 /**6210-add -notch adaptation-#8954-zhoujy-190329-start*/
1602 return mLastWindowInsets;
1603 }
-------------------》修改navigationbar和刘海屏位置的矩阵
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index 80c7d2e..87f33a5 100644 (file)
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -1063,13 +1063,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
WindowInsets updateColorViews(WindowInsets insets, boolean animate) {
WindowManager.LayoutParams attrs = mWindow.getAttributes();
int sysUiVisibility = attrs.systemUiVisibility | getWindowSystemUiVisibility();
-
- if (!mWindow.mIsFloating) {
+ if (!mWindow.mIsFloating) {
boolean disallowAnimate = !isLaidOut();
disallowAnimate |= ((mLastWindowFlags ^ attrs.flags)
& FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0;
mLastWindowFlags = attrs.flags;
-
if (insets != null) {
mLastTopInset = getColorViewTopInset(insets.getStableInsetTop(),
insets.getSystemWindowInsetTop());
@@ -1105,11 +1103,17 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
boolean navBarToRightEdge = isNavBarToRightEdge(mLastBottomInset, mLastRightInset);
boolean navBarToLeftEdge = isNavBarToLeftEdge(mLastBottomInset, mLastLeftInset);
int navBarSize = getNavBarSize(mLastBottomInset, mLastRightInset, mLastLeftInset);
+ /**6210-add-notch adaptation-#8954-zhoujy-190329-start*/
+ int naviColor = mWindow.mNavigationBarColor;
+ if(navBarToLeftEdge) {
+ naviColor = 0; //解决有时候刘海屏位置颜色为白色问题
+
+ }
updateColorViewInt(mNavigationColorViewState, sysUiVisibility,
- mWindow.mNavigationBarColor, mWindow.mNavigationBarDividerColor, navBarSize,
+ naviColor, mWindow.mNavigationBarDividerColor, navBarSize,
navBarToRightEdge || navBarToLeftEdge, navBarToLeftEdge,
0 /* sideInset */, animate && !disallowAnimate, false /* force */);
-
+ /**6210-add-notch adaptation-#8954-zhoujy-190329-end*/
boolean statusBarNeedsRightInset = navBarToRightEdge
&& mNavigationColorViewState.present;
boolean statusBarNeedsLeftInset = navBarToLeftEdge
该刘海屏修改,目前还存在一些问题,个别视频和游戏适配有一些Bug,能满足刘海屏适配基本要求,后续继续修改。