android 用沉浸式隐藏status bar

沉浸式, 隐藏status bar:

adb shell settings put global policy_control immersive.status=*

隐藏navigation bar:

adb shell settings put global policy_control immersive.navigation=*

 

禁止statusbar 下拉:

disable statusbar expand


StatusBarManager.java (core\java\android\app):
    public void disable(int what) {
        try {
            final IStatusBarService svc = getService();
            if (svc != null) {
                //<20180728-bacalli,disable statusbar expand
                //svc.disable(what, mToken, mContext.getPackageName());
                mService.disable(DISABLE_EXPAND, mToken, mContext.getPackageName());
                //>20180728-bacalli, end
            }
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

禁止点击在最上面时显示statusbar:

//PhoneWindowManager.java
       // monitor for system gestures
        mSystemGestures = new SystemGesturesPointerEventListener(context,
                new SystemGesturesPointerEventListener.Callbacks() {
                    @Override
                    public void onSwipeFromTop() {
                        //lightin.kunlin, no need to show statusbar for AR project, start
                        /*
                        if (mStatusBar != null) {
                            requestTransientBars(mStatusBar);
                        }
                        */
                        //lightin.kunlin, end 
                    }

                    @Override
                    public void onMouseHoverAtTop() {
                        //lightin.kunlin, no need to show status bar for AR project. start
                        /*
                        mHandler.removeMessages(MSG_REQUEST_TRANSIENT_BARS);
                        Message msg = mHandler.obtainMessage(MSG_REQUEST_TRANSIENT_BARS);
                        msg.arg1 = MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS;
                        mHandler.sendMessageDelayed(msg, 500);
                        */
                        //lightin.kunlin. end
                    }

禁止显示navigation bar: 

可以用config_showNavigationBar 控制navigationbar的显示

/frameworks/base/core/res/res/values/config.xml

    
     true


/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java


        mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);

        // Allow a system property to override this. Used by the emulator.
        // See also hasNavigationBar().
        String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
        if ("1".equals(navBarOverride)) {
            mHasNavigationBar = false;
        } else if ("0".equals(navBarOverride)) {
            mHasNavigationBar = true;
        }

    private boolean canHideNavigationBar() {
        return mHasNavigationBar;
    }

 

你可能感兴趣的:(android)