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

/** {@inheritDoc} */@Overridepublic 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();            }        }         //省略一部分代码         //...}

更多相关文章

  1. 裁判文书android app逆向
  2. Android(安卓)make 中变量记录
  3. Android(安卓)CheckBox设置背景selector和文本text 设置selectCo
  4. Android(安卓)自定义控件属性
  5. eclipse的dx问题
  6. Android周报第二十四期
  7. 科普篇
  8. android开发 典型网站客户端
  9. popup menu案例,无说明只代码

随机推荐

  1. Android——消息机制
  2. Blog-05-《一周快速上手Kotlin For Andro
  3. Android内核开发:源码的版本与分支详解
  4. Android笔记Android基于事件监听器处理机
  5. .NET 开源了,Visual Studio 开始支持 Andr
  6. Android(安卓)gitHub 开源
  7. 开发前奏曲之添加Android(安卓)SDK平台工
  8. Android(安卓)amr语音编解码解惑
  9. Android中app的请求抓包工具 Fiddler 详
  10. Android(安卓)-- BroadcastReceiver的使