zoukankan      html  css  js  c++  java
  • android4.4上全屏界面实现禁止状态栏下拉

    附上我改动的方法:PhoneWindowManager.java里面的改动
    --- a/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
    +++ b/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
    @@ -2863,7 +2863,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
         @Override
         public int adjustSystemUiVisibilityLw(int visibility) {
    -        mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility);
    +       if(Settings.System.getInt(mContext.getContentResolver(),"factorytest.touch.mode",0) == 0){
    +                mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility);
    +       }
             mNavigationBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility);
             // Reset any bits in mForceClearingStatusBarVisibility that
    Acitvity里面使用例如以下方式:
    --- a/huaqin/source/packages/FactoryKitTest/src/com/android/huaqin/factory/TestTouchPanelLine2.java
    +++ b/huaqin/source/packages/FactoryKitTest/src/com/android/huaqin/factory/TestTouchPanelLine2.java
    @@ -32,6 +32,8 @@ import android.view.WindowManager;
     import java.util.ArrayList;
     import java.util.List;
    +import android.provider.Settings;
    +import android.app.StatusBarManager;
     public class TestTouchPanelLine2 extends Activity {
            private static final String TAG = "TestTouchPanelLine";
    @@ -54,6 +56,7 @@ public class TestTouchPanelLine2 extends Activity {
            private static final int MSG_TEST_PANEL_NEXT_ITEM = 100;
            private static final int MSG_TEST_PANEL_START = 101;
            private static final int MSG_TEST_PANEL_STOP = 102;
    +       private StatusBarManager mStatusBarManager;
            private Handler mInHandler = new Handler() {
                    @Override
    @@ -94,6 +97,12 @@ public class TestTouchPanelLine2 extends Activity {
            @Override
            public void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
    @@ -141,8 +150,22 @@ public class TestTouchPanelLine2 extends Activity {
                                    .obtainMessage(FactoryTestMessage.MSG_OPEN_UI_OK);
                    msg.arg1 = (int) ID;
                    mOutHandler.sendMessage(msg);
    +               mStatusBarManager = (StatusBarManager) this.getSystemService(Context.STATUS_BAR_SERVICE);
    +               int state= StatusBarManager.DISABLE_EXPAND;
    +                   state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS;
    +                   state |=  StatusBarManager.DISABLE_SYSTEM_INFO;
    +               mStatusBarManager.disable(state);
            }
    +           @Override
    +           protected void onPause() {
    +               int state =  StatusBarManager.DISABLE_NONE;
    +               mStatusBarManager.disable(state);
    +               super.onPause();
    +           }
            @Override
            public boolean onKeyDown(int keyCode, KeyEvent event) {
                    // 是否触发按键为back键
     
    下面是从MTK Online 上面找到的解决方式。保留备用。
    Google从KK開始添加了状态栏透明以及全屏界面有通知能够下拉状态栏的设计,而这个设计出现的隐患是设置了FULL_SCREEN的界面是无法禁止状态栏下拉的。这样对一些project測试app可能会造成一定的影响。可是以google默认的设计,应用端无法改动此设计来满足自己的需求。
    MTK 内部已经开发提供新的接口来实现全屏界面禁止下拉状态栏,假设贵司的代码还没有这部分逻辑,请參考例如以下:
    1. frameworksasecorejavaandroidviewView.java
     
      public static final int SYSTEM_UI_FLAG_IMMERSIVE_STICKY = 0x00001000;
    +    /**
    +     * @hide
    +     *
    +     * NOTE: Flag for {@link #setSystemUiVisibility(int)}: It help user to disable transient
    +     * status bar triggered by gesture
    +     */
    +    public static final int SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED = 0x00002000;



    2. frameworksasepolicysrccomandroidinternalpolicyimplPhoneWindowManager.java
     // monitor for system gestures
            mSystemGestures = new SystemGesturesPointerEventListener(context,
                    new SystemGesturesPointerEventListener.Callbacks() {
                        @Override
                        public void onSwipeFromTop() {
    +                        if (isGestureIsolated())
    +                            return;
                            if (mStatusBar != null) {
                                requestTransientBars(mStatusBar);
                            }
                        }
                        @Override
                        public void onSwipeFromBottom() {
    +                        if (isGestureIsolated())
    +                            return;
                            if (mNavigationBar != null && mNavigationBarOnBottom) {
                                requestTransientBars(mNavigationBar);
                            }
                        }
                        @Override
                        public void onSwipeFromRight() {
    +                        if (isGestureIsolated())
    +                            return;                   
                            if (mNavigationBar != null && !mNavigationBarOnBottom) {
                                requestTransientBars(mNavigationBar);
                            }
                        }
                        @Override
                        public void onDebug() {
                            // no-op
                        }
    +                    private boolean isGestureIsolated() {
    +                        WindowState win = mFocusedWindow != null ? mFocusedWindow : mTopFullscreenOpaqueWindowState;
    +                        if (win != null && (win.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED) != 0)
    +                            return true;
    +                        else
    +                            return false;
    +                    }
                    });



    3. 請在改动完framework后,將测試app用setSystemUiVisibility的API加上SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED的flag
  • 相关阅读:
    MyBatis 笔记
    Python os模块、os.path模块常用方法
    vue-lazyload 的使用(vue图片懒加载)
    使用 vant 的 v-lazy 实现图片 vue 在移动端的懒加载
    代码注释规范-IDEA 配置 Java 类方法注释模板
    Java Web 笔记(杂)
    tortoisegit使用
    git结合github远程仓库使用
    .doc 2 .docx可用代码
    惊奇,MySQL还能正则匹配,简易例子
  • 原文地址:https://www.cnblogs.com/wzzkaifa/p/6755640.html
Copyright © 2011-2022 走看看