Android P系统修改状态栏记录

1、强制永久显示状态栏(不被app隐藏)
代码路径:\frameworks\base\services\core\java\com\android\server\policy\PhoneWindowManager.java

/** {@inheritDoc} */
@Override
public void applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams attrs,WindowState attached, WindowState imeTarget) {
        final boolean affectsSystemUi = win.canAffectSystemUiFlags();
        if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": affectsSystemUi=" + affectsSystemUi);
        applyKeyguardPolicyLw(win, imeTarget);
		//modify start 220190808
        //final int fl = PolicyControl.getWindowFlags(win, attrs);
		int fl = PolicyControl.getWindowFlags(win, attrs);
		fl |= FLAG_FORCE_NOT_FULLSCREEN;				//增加FLAG_FORCE_NOT_FULLSCREEN编辑,强制不全屏
		//modify  end 220190808

		 //省略一部分代码
         //...
        if (mTopFullscreenOpaqueWindowState == null && affectsSystemUi) {
          if ((fl & FLAG_FORCE_NOT_FULLSCREEN) != 0) {
              mForceStatusBar = true;									//mForceStatusBar = true,强制显示状态栏
          }
          if (attrs.type == TYPE_DREAM) {
              // If the lockscreen was showing when the dream started then wait
              // for the dream to draw before hiding the lockscreen.
              if (!mDreamingLockscreen
                      || (win.isVisibleLw() && win.hasDrawnLw())) {
                  mShowingDream = true;
                  appWindow = true;
              }
          }

          // For app windows that are not attached, we decide if all windows in the app they
          // represent should be hidden or if we should hide the lockscreen. For attached app
          // windows we defer the decision to the window it is attached to.
          if (appWindow && attached == null) {
              if (attrs.isFullscreen() && inFullScreenOrSplitScreenSecondaryWindowingMode) {
                  if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win);
                  mTopFullscreenOpaqueWindowState = win;
                  if (mTopFullscreenOpaqueOrDimmingWindowState == null) {
                      mTopFullscreenOpaqueOrDimmingWindowState = win;
                  }
                  if ((fl & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) {
                      mAllowLockscreenWhenOn = true;
                  }
              }
          }
      }
         //省略一部分代码
         //...
}

2、固定状态栏无背景View,背景色无变化
代码路径:\frameworks\base\core\java\com\android\internal\policy\DecorView.java

private void updateColorViewInt(final ColorViewState state, int sysUiVis, int color,
            int dividerColor, int size, boolean verticalBar, boolean seascape, int sideMargin,
            boolean animate, boolean force) {
         //省略一部分代码
         //...
		//add by sunxiaolin
		//增加view= null,showView=true逻辑,使其进入以下代码分支
		view = null;
		showView = true;
        if (view == null) {
            if (showView) {
                state.view = view = new View(mContext);
                setColor(view, color, dividerColor, verticalBar, seascape);
                view.setTransitionName(state.attributes.transitionName);
                view.setId(state.attributes.id);
                visibilityChanged = true;
                view.setVisibility(INVISIBLE);
                state.targetVisibility = VISIBLE;
			//modify by sunxiaolin
			//做测试,增加的状态栏View的颜色为红色,方便测试查看,状态栏底层View为空色
			color = Color.RED;
			visibilityChanged = false;
			setColor(view, color, dividerColor, verticalBar, seascape);
			view.setVisibility(VISIBLE);
			Log.d(TAG, "sunxiaolin,updateColorViewInt mWindow.getAttributes().flags(0x" + Integer.toHexString(mWindow.getAttributes().flags) + ")");
			Log.d(TAG, "sunxiaolin,updateColorViewInt state.present=" + state.present);
                LayoutParams lp = new LayoutParams(resolvedWidth, resolvedHeight,
                        resolvedGravity);
                if (seascape) {
                    lp.leftMargin = sideMargin;
                } else {
                    lp.rightMargin = sideMargin;
                }
				Log.d(TAG, "sunxiaolin,updateColorViewInt do nothing");
				Log.d(TAG, "sunxiaolin,updateColorViewInt do nothing");
				//去掉添加View,即没有状态栏View背景。这样状态栏背景固定为无背景
                //addView(view, lp);
                //updateColorViewTranslations();
            }
        }
         //省略一部分代码
         //...
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sunxiaolin2016

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值