码迷,mamicode.com
首页 > 移动开发 > 详细

android4.4上全屏界面实现禁止状态栏下拉

时间:2017-04-24 12:26:59      阅读:1745      评论:0      收藏:0      [点我收藏+]

标签:mod   frame   void   monit   get   context   callbacks   arraylist   ansi   

附上我改动的方法: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. frameworks\base\core\java\android\view\View.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. frameworks\base\policy\src\com\android\internal\policy\impl\PhoneWindowManager.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

android4.4上全屏界面实现禁止状态栏下拉

标签:mod   frame   void   monit   get   context   callbacks   arraylist   ansi   

原文地址:http://www.cnblogs.com/wzzkaifa/p/6755640.html

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!