您现在的位置是:首页 >学无止境 >android11中添加导航栏控制功能网站首页学无止境

android11中添加导航栏控制功能

路奇的电脑 2025-03-21 12:01:03
简介android11中添加导航栏控制功能

在android11中有的客户需要导航栏来控制是隐藏导航栏还是显示导航栏或者是一段时间之后自动隐藏导航栏,下面就是具体实现功能的代码

第一步

frameworks/base

diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
         }
         return packages[0];
     }
+    /**
+     * @hide
+     */
+     public static final class SystemUI {
+        /**
+        * @hide
+       */
+        public static final int DISABLE = 0;
+        /**
+        * @hide
+        */
+        public static final int ENABLE = 1;
+       /**
+        * @hide
+        */
+        public static final String HIDE_NAVBAR = "hide_navbar";
+       /**
+        * @hide
+        */
+       public static final String BOTTOM_SWIPE_SHOW = "bottom_swipe_show";
+        /**
+        * @hide
+        */
+        public static final String AUTO_HIDE_NAVBAR = "auto_hide_navbar";
+        /**
+        * @hide
+        */
+        public static final String HIDE_STATUSBAR = "hide_statusbar";
+        /**
+        * @hide
+       */
+        public static final String HIDE_PANELS = "hide_panels";
+       /**
+        * @hide
+        */
+        public static final String HIDE_NOTIFICATION = "hide_notification";
+        /**
+        * @hide
+        */
+        public static final String ACTION_HIDE_NAVBAR = "com.android.HIDE_NAVBAR";
+        /**
+        * @hide
+        */
+        public static final String ACTION_SHOW_NAVBAR = "com.android.SHOW_NAVBAR";
+        /**
+        * @hide
+        */
+        public static final String ACTION_AUTO_HIDE_NAVBAR = "com.android.AUTO_HIDE_NAVBAR";
+        /**
+        * @hide
+        */
+       public static final String ACTION_CANCEL_HIDE_NAVBAR = "com.android.CANCEL_HIDE_NAVBAR";
+        /**
+        * @hide
+       */
+        public static final String ACTION_HIDE_STATUSBAR = "com.android.HIDE_STATUSBAR";
+       /**
+        * @hide
+        */
+        public static final String ACTION_SHOW_STATUSBAR= "com.android.SHOW_STATUSBAR";
+        /**
+        * @hide
+        */
+        public static final String ACTION_HIDE_PANELS = "com.android.HIDE_PANELS";
+        /**
+        * @hide
+        */
+        public static final String ACTION_SHOW_PANELS = "com.android.SHOW_PANELS";
+        /**
+        * @hide
+        */
+        public static final String ACTION_HIDE_NOTIFICATION = "com.android.HIDE_NOTIFICATION";
+        /**
+        * @hide
+        */
+        public static final String ACTION_SHOW_NOTIFICATION = "com.android.SHOW_NOTIFICATION";
+        /**
+        * @hide
+        */
+        public static final String DISPLAY_STATUS_BAR = "display_status_bar";
+        /**
+        * @hide
+        */
+        public static final String ACTION_DISPLAY_STATUS_BAR = "com.android.display_status_bar";
+    }
 }
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
     <!-- should show the screenshot button default -->
     <integer name="def_screenshot_button_show">0</integer>
 
+    <!-- frameworks/base/core/java/android/provider/Settings.java SystemUI.ENABLE -->
+    <integer name="def_hide_navbar">0</integer>
+    <integer name="def_auto_hide_navbar">0</integer>
+    <integer name="def_display_status_bar">1</integer>
+    <integer name="def_hide_panels">1</integer>
+    <integer name="def_hide_notification">0</integer>
+    <integer name="def_bottom_swipe_show">0</integer>
+
     <integer name="def_ble_scan_always_enabled">1</integer>
     <integer name="def_wifi_scan_always_enabled">1</integer>
 
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index bdd180c68dd8..79494cde58b8 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2604,6 +2604,25 @@ class DatabaseHelper extends SQLiteOpenHelper {
             }
             loadSetting(stmt, Settings.Global.LID_BEHAVIOR, defaultLidBehavior);
 
+
+            loadIntegerSetting(stmt, Settings.SystemUI.HIDE_NAVBAR,
+                    R.integer.def_hide_navbar);
+
+            loadIntegerSetting(stmt, Settings.SystemUI.AUTO_HIDE_NAVBAR,
+                    R.integer.def_auto_hide_navbar);
+
+            loadIntegerSetting(stmt, Settings.SystemUI.DISPLAY_STATUS_BAR,
+                   R.integer.def_display_status_bar);
+
+            loadIntegerSetting(stmt, Settings.SystemUI.HIDE_PANELS,
+                    R.integer.def_hide_panels);
+
+            loadIntegerSetting(stmt, Settings.SystemUI.HIDE_NOTIFICATION,
+                    R.integer.def_hide_notification);
+
+            loadIntegerSetting(stmt, Settings.SystemUI.HIDE_NOTIFICATION,
+                    R.integer.def_bottom_swipe_show);
+
             /*
              * IMPORTANT: Do not add any more upgrade steps here as the global,
              * secure, and system settings are no longer stored in a database
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index 96d6ecbcc07f..feb4b90456ed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -54,6 +54,10 @@ import com.android.internal.view.AppearanceRegion;
 import com.android.systemui.statusbar.CommandQueue.Callbacks;
 import com.android.systemui.statusbar.policy.CallbackController;
 import com.android.systemui.tracing.ProtoTracer;
+import android.provider.Settings;
+import android.util.Log;
+import com.android.systemui.SystemUIApplication;
+import com.android.systemui.statusbar.phone.StatusBar;
 
 import java.util.ArrayList;
 
@@ -373,9 +377,18 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
     public boolean panelsEnabled() {
         final int disabled1 = getDisabled1(DEFAULT_DISPLAY);
         final int disabled2 = getDisabled2(DEFAULT_DISPLAY);
-        return (disabled1 & StatusBarManager.DISABLE_EXPAND) == 0
-                && (disabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) == 0
-                && !ONLY_CORE_APPS;
+    boolean  isstatus=false;
+    int intstatus=StatusBar.StatusBarintstatus;
+    if(intstatus==1){
+          isstatus=false;
+      }
+    if(intstatus==0){
+    isstatus=(disabled1 & StatusBarManager.DISABLE_EXPAND) == 0
+                 && (disabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) == 0
+                 && !ONLY_CORE_APPS;
+      } 
+       return isstatus;
     }
 
     public void addCallback(Callbacks callbacks) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java b/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
index 8c24c540e743..4f37f5226f7f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
@@ -178,6 +178,13 @@ public class NavigationBarController implements Callbacks {
         }
     }
 
+    public void hideNavigationBar() { 
+        Display[] displays = mDisplayManager.getDisplays();
+        for (Display display : displays) {
+            removeNavigationBar(display.getDisplayId());
+        }
+    }
+
     /** @see NavigationBarFragment#checkNavBarModes() */
     public void checkNavBarModes(int displayId) {
         NavigationBarFragment navBar = mNavigationBars.get(displayId);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -65,6 +65,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import com.android.systemui.statusbar.phone.StatusBar;
 
 import dagger.Lazy;
 
@@ -691,8 +692,15 @@ public class NotificationEntryManager implements
      * Update the notifications
      * @param reason why the notifications are updating
      */
-    public void updateNotifications(String reason) {
-        reapplyFilterAndSort(reason);
+    public  void updateNotifications(String reason) {
+            int intstatus=StatusBar.StatusBarintnotification;
+            if(intstatus==1){
+             reapplyFilterAndSort(reason);
+            }
+            if(intstatus==0){
+            mSortedAndFiltered.clear();
+            }
         if (mPresenter != null && !mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
             mPresenter.updateNotificationViews(reason);
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index f125b7d10035..a0c62e2ea91d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -237,6 +237,8 @@ import java.util.concurrent.Executor;
 
 import javax.inject.Named;
 import javax.inject.Provider;
+import android.database.ContentObserver;
+import com.android.systemui.statusbar.notification.NotificationEntryManager;
 
 import dagger.Lazy;
 
@@ -247,6 +249,8 @@ public class StatusBar extends SystemUI implements DemoMode,
         StatusBarStateController.StateListener, ActivityLaunchAnimator.Callback,
         LifecycleOwner, BatteryController.BatteryStateChangeCallback {
     public static final boolean MULTIUSER_DEBUG = false;
+    private boolean mHideNavStatus = true;
+    private  int intstatus=1;
 
     protected static final int MSG_HIDE_RECENT_APPS = 1020;
     protected static final int MSG_PRELOAD_RECENT_APPS = 1022;
@@ -270,6 +274,8 @@ public class StatusBar extends SystemUI implements DemoMode,
     public static final boolean DEBUG_GESTURES = false;
     public static final boolean DEBUG_MEDIA_FAKE_ARTWORK = false;
     public static final boolean DEBUG_CAMERA_LIFT = false;
+    public static int  StatusBarintstatus=1;
+    public static int  StatusBarintnotification=0;
 
     public static final boolean DEBUG_WINDOW_STATE = false;
 
@@ -512,6 +518,135 @@ public class StatusBar extends SystemUI implements DemoMode,
 
     protected final H mHandler = createHandler();
 
+        private Runnable autoHideRunnable = ()->{
+            //  Settings.Global.putInt(mContext.getContentResolver(), "hide_navbar", 0);
+            hideNavigation();
+    };
+
+
+     private void setNavigationStatus() {
+       boolean hideNavStatus = Settings.Global.getInt(mContext.getContentResolver(), "hide_navbar", 0) == 1;
+        if(hideNavStatus){
+              showNavigation();
+        }
+        else{
+            hideNavigation();
+            int value= Settings.Global.getInt(mContext.getContentResolver(), "auto_hide_navbar", 1);
+            enableAutoHideNavBar(value);
+        }
+        
+    }
+
+        private void enableAutoHideNavBar(int value){
+        if(value == 0){
+            if (mHandler.hasCallbacks(autoHideRunnable)) {
+               mHandler.removeCallbacks(autoHideRunnable);
+            }
+        }else{
+            if (mHandler.hasCallbacks(autoHideRunnable)) {
+                mHandler.removeCallbacks(autoHideRunnable);
+            }
+            mHandler.postDelayed(autoHideRunnable,5000);
+        }
+    }
+
+        final private ContentObserver navbarShowObserver = new ContentObserver(mHandler) {
+        @Override
+        public void onChange(boolean selfChange) {
+            boolean isShow = Settings.Global.getInt(mContext.getContentResolver(), "hide_navbar", 1) == 1;
+            int value= Settings.Global.getInt(mContext.getContentResolver(), "auto_hide_navbar", 1);
+            //boolean isShow = value == 1;
+            if(isShow){
+             showNavigation();
+             enableAutoHideNavBar(value);
+            }else{
+            hideNavigation();
+         }
+        }
+    };
+
+    private void showNavigation() {
+        if (!mHideNavStatus){
+            Log.d(TAG,"====== show Navigation ======");
+            NavigationBarView mNavigationBarView = mNavigationBarController.getDefaultNavigationBarView();
+
+            // if (mNavigationBarView == null){
+            mNavigationBarController.createNavigationBars(true,null);
+            mHideNavStatus = true;
+            // }
+   
+        }
+    }
+
+    private void hideNavigation() {
+        if (mHideNavStatus){
+            Log.d(TAG,"====== hide Navigation ======");
+            NavigationBarView mNavigationBarView = mNavigationBarController.getDefaultNavigationBarView();
+
+            // if (mNavigationBarView != null){
+             mNavigationBarController.hideNavigationBar();
+                mHideNavStatus = false;
+            // }
+    
+       }
+    }
+
+         final private ContentObserver notificationpulldownShowObserver = new ContentObserver(mHandler) {
+        @Override
+        public void onChange(boolean selfChange) {
+            boolean isShow = Settings.Global.getInt(mContext.getContentResolver(), "hide_panels", 1) == 1;
+            if(isShow){
+             StatusBarintstatus=1;
+            }else{
+            StatusBarintstatus=0;
+
+         }
+        }
+    };
+
+     final private ContentObserver notificationbarShowObserver = new ContentObserver(mHandler) {
+        @Override
+        public void onChange(boolean selfChange) {
+            boolean isShow = Settings.Global.getInt(mContext.getContentResolver(), "hide_notification", 1) == 1;
+            if(isShow){
+            StatusBarintnotification=1;
+            }else{
+            StatusBarintnotification=0;
+         }
+        }
+    };
+
+
+        final private ContentObserver statusbarShowObserver = new ContentObserver(mHandler) {
+        @Override
+        public void onChange(boolean selfChange) {
+            boolean isShow = Settings.Global.getInt(mContext.getContentResolver(), "display_status_bar", 1) == 1;
+            if(isShow){
+                mPhoneStatusBarWindow.setVisibility(View.VISIBLE);
+            }else{
+                mPhoneStatusBarWindow.setVisibility(View.GONE);
+         }
+        }
+    };
+
+
+        final private ContentObserver antonavbarShowObserver = new ContentObserver(mHandler) {
+        @Override
+        public void onChange(boolean selfChange) {
+            int value= Settings.Global.getInt(mContext.getContentResolver(), "auto_hide_navbar", 1);
+            boolean isShow = Settings.Global.getInt(mContext.getContentResolver(), "auto_hide_navbar", 1) == 1;
+            enableAutoHideNavBar(value);  
+        }
+    };
+
     private int mInteractingWindows;
     private @TransitionMode int mStatusBarMode;
 
@@ -998,6 +1133,11 @@ public class StatusBar extends SystemUI implements DemoMode,
                         }
                     }
                 }, OverlayPlugin.class, true /* Allow multiple plugins */);
+                    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor("hide_navbar"), true, navbarShowObserver);
+                    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor("auto_hide_navbar"), true, antonavbarShowObserver);
+                    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor("display_status_bar"), true, statusbarShowObserver);
+                    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor("hide_panels"), true, notificationpulldownShowObserver);
+                    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor("hide_notification"), true, notificationbarShowObserver);
     }
 
     // ================================================================================
@@ -1099,7 +1239,30 @@ public class StatusBar extends SystemUI implements DemoMode,
         mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager);
         mNotificationLogger.setHeadsUpManager(mHeadsUpManager);
 
-        createNavigationBar(result);
+        //createNavigationBar(result);
+        try {
+           boolean hideNavStatus = Settings.Global.getInt(mContext.getContentResolver(), "hide_navbar", 0) == 1;
+            //Log.d(TAG, "====== Navigation ====== " + hideNavStatus);
+            boolean isShowpanels = Settings.Global.getInt(mContext.getContentResolver(), "hide_panels", 1) == 1;
+            boolean isShownotification = Settings.Global.getInt(mContext.getContentResolver(), "hide_notification", 1) == 1;
+            if(isShowpanels){
+            StatusBarintstatus=1;
+            }else{
+            StatusBarintstatus=0;
+            }
+            if (hideNavStatus) {
+                 createNavigationBar(result);
+            }
+            if(isShownotification){
+            StatusBarintnotification=1;
+            }else{
+            StatusBarintnotification=0;
+            }
+        } catch (Exception e) {
+            Log.d(TAG, "====== Navigation ====== " + e);
+        }
+
+        setNavigationStatus();
 
         if (ENABLE_LOCKSCREEN_WALLPAPER && mWallpaperSupported) {
             mLockscreenWallpaper = mLockscreenWallpaperLazy.get();
@@ -1289,6 +1452,16 @@ public class StatusBar extends SystemUI implements DemoMode,
         filter.addAction(Intent.ACTION_SCREEN_OFF);
         filter.addAction(DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG);
         mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter, null, UserHandle.ALL);
+        filter = new IntentFilter("com.android.SHOW_NAVBAR");
+        mContext.registerReceiver(navigationshowReceiver, filter);
+        filter = new IntentFilter("com.android.SHOW");
+        mContext.registerReceiver(showReceiver, filter);
+        filter = new IntentFilter("com.android.HIDE_NAVBAR");
+        mContext.registerReceiver(navigationhideReceiver, filter);
+        filter = new IntentFilter("com.android.SHOW_STATUSBAR");
+        mContext.registerReceiver(statusshowReceiver, filter);
+        filter = new IntentFilter("com.android.HIDE_STATUSBAR");
+        mContext.registerReceiver(statushideReceiver, filter);
     }
 
     protected QS createDefaultQSFragment() {
@@ -1452,6 +1625,17 @@ public class StatusBar extends SystemUI implements DemoMode,
         mNotificationShadeWindowViewController.setupExpandedStatusBar();
         mStatusBarWindowController = statusBarComponent.getStatusBarWindowController();
         mPhoneStatusBarWindow = mSuperStatusBarViewFactory.getStatusBarWindowView();
+        try {
+            boolean isShow = Settings.Global.getInt(mContext.getContentResolver(), "display_status_bar", 1) == 1;
+            if(isShow){
+                mPhoneStatusBarWindow.setVisibility(View.VISIBLE);
+            }else{
+                mPhoneStatusBarWindow.setVisibility(View.GONE);
+         }
+        } catch (Exception e) {
+            Log.d(TAG, "====== status_bar ====== " + e);
+        }
         mNotificationPanelViewController = statusBarComponent.getNotificationPanelViewController();
     }
 
@@ -2808,6 +2992,68 @@ public class StatusBar extends SystemUI implements DemoMode,
         }
     };
 
+        BroadcastReceiver navigationshowReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+             if ((intent.getAction()).equals("com.android.SHOW_NAVBAR")) {
+            // 接收到广播传来的数据
+            Settings.Global.putInt(mContext.getContentResolver(), "hide_navbar", 1);
+            Settings.Global.putInt(mContext.getContentResolver(), "bottom_swipe_show", 0);
+        //    showNavigation();
+        //      int value= Settings.Global.getInt(mContext.getContentResolver(), "auto_hide_navbar", 1);
+        //     enableAutoHideNavBar(value);
+
+         }
+        }
+    };
+
+
+        BroadcastReceiver showReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+             if ((intent.getAction()).equals("com.android.SHOW")) {
+            // 接收到广播传来的数据
+            // Settings.System.putInt(mContext.getContentResolver(), "navbar_show", 1);
+            showNavigation();
+             int value= Settings.Global.getInt(mContext.getContentResolver(), "auto_hide_navbar", 1);
+            enableAutoHideNavBar(value);
+
+         }
+        }
+    };
+
+        BroadcastReceiver navigationhideReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+             if ((intent.getAction()).equals("com.android.HIDE_NAVBAR")) {
+            // 接收到广播传来的数据
+            Settings.Global.putInt(mContext.getContentResolver(), "hide_navbar", 0);
+            //  hideNavigation();
+         }
+        }
+    };
+
+        BroadcastReceiver statusshowReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+             if ((intent.getAction()).equals("com.android.SHOW_STATUSBAR")) {
+            // 接收到广播传来的数据
+            Settings.Global.putInt(mContext.getContentResolver(), "display_status_bar", 1);
+         }
+        }
+    };
+
+        BroadcastReceiver statushideReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+             if ((intent.getAction()).equals("com.android.HIDE_STATUSBAR")) {
+            // 接收到广播传来的数据
+            Settings.Global.putInt(mContext.getContentResolver(), "display_status_bar", 0);
+         }
+        }
+    };
+
+
     private final BroadcastReceiver mDemoReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
 import com.android.server.statusbar.StatusBarManagerInternal;
 import com.android.server.wallpaper.WallpaperManagerInternal;
 import com.android.server.wm.utils.InsetUtils;
+import android.provider.Settings;
+import android.util.Log;
 
 import java.io.PrintWriter;
 import java.util.function.Consumer;
@@ -539,6 +541,14 @@ public class DisplayPolicy {
                                     && mNavigationBarPosition == NAV_BAR_BOTTOM) {
                                 requestTransientBars(mNavigationBar);
                             }
+                        if (mNavigationBar == null && Settings.Global.getInt(mContext.getContentResolver(), "bottom_swipe_show", 0) == 1){
+                        // Settings.Global.putInt(mContext.getContentResolver(), "hide_navbar", 1);
+                        Intent customIntent = new Intent();
+                        customIntent.setAction("com.android.SHOW");
+                        customIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+                        mContext.sendBroadcast(customIntent);
+                        }
                             checkAltBarSwipeForTransientBars(ALT_BAR_BOTTOM);
                         }
                     }

第二步:packages/apps/Settings

diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-	<string name="display_usb_mode">USB模式</string>
+    <string name="navbar_manager">导航栏开关</string>
+    <string name="auto_hide_navbar">自动隐藏导航栏</string>
+    <string name="Display_Status_bar">显示状态栏</string>
+    <string name="no_pulldown_notification_bar">禁止下拉通知栏</string>
+     <string name="network_adb">网络adb</string>
+    <string name="Notification_bar">通知栏提示框</string>
+  <string name="display_usb_mode">USB模式</string>
 	<string name="display_usb_mode_host">主模式</string>
 	<string name="display_usb_mode_peripheral">从模式</string>
     <string name="yes" msgid="1999566976857398962">"是"</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e4fd58acbc..1006884f9e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -14,6 +14,12 @@
      limitations under the License.
 -->
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="navbar_manager">Navigation bar switch</string>
+    <string name="auto_hide_navbar">Auto hide the navigation bar</string>
+    <string name="Display_Status_bar">Display Status bar</string>
+    <string name="no_pulldown_notification_bar">Do not pull down the notification bar</string>
+    <string name="Notification_bar">Notification bar Prompt box</string>
+    <string name="network_adb">network adb</string>
     <!-- Strings for Dialog yes button -->
     <string name="yes">"Yes"</string>
     <!-- Strings for Dialog no button -->
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
         android:title="@string/hdmi_settings"
         settings:keywords="@string/hdmi_settings"
         android:fragment="com.android.settings.display.HdmiSettings" />
+
+    <SwitchPreference
+        android:key="navbar_manager"
+        android:title="@string/navbar_manager" />
+
+    <SwitchPreference
+        android:key="auto_hide_navbar"
+        android:title="@string/auto_hide_navbar"/>
+
+    <SwitchPreference
+        android:key="Display_Status_bar"
+        android:title="@string/Display_Status_bar"/>
+
+       <SwitchPreference
+        android:key="no_pulldown_notification_bar"
+        android:title="@string/no_pulldown_notification_bar"/>
+
+         <SwitchPreference
+        android:key="Notification_bar"
+        android:title="@string/Notification_bar"/>
 </PreferenceScreen>
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 3492cf1d08..500be72945 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -37,6 +37,12 @@ import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.search.SearchIndexable;
+import com.android.settings.display.ShowNavBarPreferenceController;
+import com.android.settings.display.AutoshowNavBarPreferenceController;
+import com.android.settings.display.NotificationbarPreferenceController;
+import com.android.settings.display.StatusbarPreferenceController;
+import com.android.settings.display.pulldownnotificationbarPreferenceController;
+
 
 import java.util.ArrayList;
 import java.util.List;
@@ -93,6 +99,11 @@ public class DisplaySettings extends DashboardFragment {
         controllers.add(new ThemePreferenceController(context));
         controllers.add(new BrightnessLevelPreferenceController(context, lifecycle));
         controllers.add(new HdmiSettingsPreferenceController(context, KET_HDMI_SETTINGS));
+        controllers.add(new ShowNavBarPreferenceController(context));
+        controllers.add(new AutoshowNavBarPreferenceController(context));
+        controllers.add(new NotificationbarPreferenceController(context));
+        controllers.add(new StatusbarPreferenceController(context));
+        controllers.add(new pulldownnotificationbarPreferenceController(context));
         return controllers;
     }
 
diff --git a/src/com/android/settings/display/AutoshowNavBarPreferenceController.java b/src/com/android/settings/display/AutoshowNavBarPreferenceController.java
new file mode 100644
--- /dev/null
+++ b/src/com/android/settings/display/AutoshowNavBarPreferenceController.java
@@ -0,0 +1,90 @@
+package com.android.settings.display;
+
+import android.content.Context;
+import android.provider.Settings;
+import androidx.preference.SwitchPreference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.Preference;
+
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.AbstractPreferenceController;
+import android.content.Intent;
+
+import com.android.internal.statusbar.IStatusBarService;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.util.Log;
+
+public class AutoshowNavBarPreferenceController extends AbstractPreferenceController
+        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+    private static final String KEY_NAME = "auto_hide_navbar";
+
+    private static final int KEY_ENABLE = 1;
+    private static final int KEY_DISABLE = 0;
+    private static final String KEY_AUTO_NAVBAR_SHOW = "auto_hide_navbar";
+    private Preference mPreference;
+
+
+   public AutoshowNavBarPreferenceController(Context context) {
+        super(context);
+        context.getContentResolver().registerContentObserver(Settings.Global.getUriFor("hide_navbar"), true, statusbarShowObserver);
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY_NAME;
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = screen.findPreference(KEY_NAME);
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        boolean value = (Boolean) newValue;
+        if(value){
+            Settings.Global.putInt(mContext.getContentResolver(), KEY_AUTO_NAVBAR_SHOW, KEY_ENABLE);
+        }else {
+           Settings.Global.putInt(mContext.getContentResolver(), KEY_AUTO_NAVBAR_SHOW, KEY_DISABLE);
+        }
+        return true;
+   }
+
+        final private ContentObserver statusbarShowObserver = new ContentObserver(new Handler()) {
+        @Override
+        public void onChange(boolean selfChange) {
+            boolean isShow = Settings.Global.getInt(mContext.getContentResolver(), "hide_navbar", 0) == 0;
+            if(isShow){
+               mPreference.setEnabled(false);
+            }else{
+               mPreference.setEnabled(true);
+         }
+        }
+    };
+
+    @Override
+   public void updateState(Preference preference) {
+        int value = Settings.Global.getInt(mContext.getContentResolver(),
+                KEY_AUTO_NAVBAR_SHOW, KEY_ENABLE);
+        ((SwitchPreference) preference).setChecked(value != KEY_DISABLE);
+         boolean isShow = Settings.Global.getInt(mContext.getContentResolver(), "hide_navbar", 1) == 0;
+         if(isShow){
+              ((SwitchPreference) preference).setEnabled(false);
+         }else{
+               ((SwitchPreference) preference).setEnabled(true);
+         }
+    }
+}
 No newline at end of file
diff --git a/src/com/android/settings/display/NotificationbarPreferenceController.java b/src/com/android/settings/display/NotificationbarPreferenceController.java
new file mode 100644
--- /dev/null
+++ b/src/com/android/settings/display/NotificationbarPreferenceController.java
+package com.android.settings.display;
+
+import android.content.Context;
+import android.provider.Settings;
+import androidx.preference.SwitchPreference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.Preference;
+
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.AbstractPreferenceController;
+import android.content.Intent;
+
+import com.android.internal.statusbar.IStatusBarService;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.util.Log;
+
+public class NotificationbarPreferenceController extends AbstractPreferenceController
+        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+    private static final String KEY_NAME = "Notification_bar";
+
+    private static final int KEY_ENABLE = 1; 
+    private static final int KEY_DISABLE = 0;
+    private static final String KEY_NOTIFICATION_SHOW = "hide_notification";
+    private Preference mPreference;
+
+
+   public NotificationbarPreferenceController(Context context) {
+        super(context);
+        context.getContentResolver().registerContentObserver(Settings.Global.getUriFor("display_status_bar"), true, statusbarShowObserver);
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY_NAME;
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = screen.findPreference(KEY_NAME);
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        boolean value = (Boolean) newValue;
+        if(value){
+            Settings.Global.putInt(mContext.getContentResolver(), KEY_NOTIFICATION_SHOW, KEY_ENABLE);
+        }else {
+           Settings.Global.putInt(mContext.getContentResolver(), KEY_NOTIFICATION_SHOW, KEY_DISABLE);
+        }
+        return true;
+   }
+
+
+    final private ContentObserver statusbarShowObserver = new ContentObserver(new Handler()) {
+        @Override
+        public void onChange(boolean selfChange) {
+            boolean isShow = Settings.Global.getInt(mContext.getContentResolver(), "display_status_bar", 1) == 0;
+            if(isShow){
+            mPreference.setEnabled(false);
+            }else{
+           mPreference.setEnabled(true);
+         }
+        }
+    };
+
+    @Override
+   public void updateState(Preference preference) {
+        int value = Settings.Global.getInt(mContext.getContentResolver(),
+                KEY_NOTIFICATION_SHOW, KEY_ENABLE);
+        ((SwitchPreference) preference).setChecked(value != KEY_DISABLE);
+    }
+}
 No newline at end of file
diff --git a/src/com/android/settings/display/ShowNavBarPreferenceController.java b/src/com/android/settings/display/ShowNavBarPreferenceController.java
--- /dev/null
+++ b/src/com/android/settings/display/ShowNavBarPreferenceController.java
@@ -0,0 +1,63 @@
+package com.android.settings.display;
+
+import android.content.Context;
+import android.provider.Settings;
+import androidx.preference.SwitchPreference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.Preference;
+
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.AbstractPreferenceController;
+import android.content.Intent;
+
+import com.android.internal.statusbar.IStatusBarService;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
+
+
+public class ShowNavBarPreferenceController extends AbstractPreferenceController
+        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+    private static final String KEY_NAME = "navbar_manager";
+ 
+    private static final int KEY_ENABLE = 1;
+    private static final int KEY_DISABLE = 0;
+    private static final String KEY_NAVBAR_SHOW = "hide_navbar";
+
+   public ShowNavBarPreferenceController(Context context) {
+        super(context);
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY_NAME;
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        boolean value = (Boolean) newValue;
+        if(value){
+            Settings.Global.putInt(mContext.getContentResolver(), KEY_NAVBAR_SHOW, KEY_ENABLE);
+            Settings.Global.putInt(mContext.getContentResolver(), "bottom_swipe_show", KEY_ENABLE);
+        }else {
+           Settings.Global.putInt(mContext.getContentResolver(), KEY_NAVBAR_SHOW, KEY_DISABLE);
+           Settings.Global.putInt(mContext.getContentResolver(), "bottom_swipe_show", KEY_DISABLE);
+        } 
+        return true;
+   }
+
+    @Override
+   public void updateState(Preference preference) {
+        int value = Settings.Global.getInt(mContext.getContentResolver(),
+                KEY_NAVBAR_SHOW, KEY_ENABLE);
+        ((SwitchPreference) preference).setChecked(value != KEY_DISABLE);
+    }
+}
 No newline at end of file
diff --git a/src/com/android/settings/display/StatusbarPreferenceController.java b/src/com/android/settings/display/StatusbarPreferenceController.java
--- /dev/null
+++ b/src/com/android/settings/display/StatusbarPreferenceController.java
@@ -0,0 +1,62 @@
+package com.android.settings.display;
+
+import android.content.Context;
+import android.provider.Settings;
+import androidx.preference.SwitchPreference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.Preference;
+
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.AbstractPreferenceController;
+import android.content.Intent;
+
+import com.android.internal.statusbar.IStatusBarService;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+
+public class StatusbarPreferenceController extends AbstractPreferenceController
+        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+    private static final String KEY_NAME = "Display_Status_bar";
+    private SwitchPreference mHideStatusbar;
+    private static final int KEY_ENABLE = 1;
+    private static final int KEY_DISABLE = 0;
+    private static final String KEY_STATUS_SHOW = "display_status_bar";
+
+   public StatusbarPreferenceController(Context context) {
+        super(context);
+    //     mHideStatusbar = (SwitchPreference) findPreference(KEY_HIDE_STATUSBAR);
+    //     mHideStatusbar.setOnPreferenceChangeListener(this);
+    //     mHideStatusbar.setEnabled(false);
+
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY_NAME;
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        boolean value = (Boolean) newValue;
+        if(value){
+            Settings.Global.putInt(mContext.getContentResolver(), KEY_STATUS_SHOW, KEY_ENABLE);
+        }else {
+           Settings.Global.putInt(mContext.getContentResolver(), KEY_STATUS_SHOW, KEY_DISABLE);
+        }
+        return true;
+   }
+
+    @Override
+   public void updateState(Preference preference) {
+        int value = Settings.Global.getInt(mContext.getContentResolver(),
+                KEY_STATUS_SHOW, KEY_ENABLE);
+        ((SwitchPreference) preference).setChecked(value != KEY_DISABLE);
+    }
+}
 No newline at end of file
diff --git a/src/com/android/settings/display/pulldownnotificationbarPreferenceController.java b/src/com/android/settings/display/pulldownnotificationbarPreferenceController.java
--- /dev/null
+++ b/src/com/android/settings/display/pulldownnotificationbarPreferenceController.java
@@ -0,0 +1,83 @@
+package com.android.settings.display;
+
+import android.content.Context;
+import android.provider.Settings;
+import androidx.preference.SwitchPreference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.Preference;
+
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.AbstractPreferenceController;
+import android.content.Intent;
+
+import com.android.internal.statusbar.IStatusBarService;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.util.Log;
+
+
+public class pulldownnotificationbarPreferenceController extends AbstractPreferenceController
+        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+    private static final String KEY_NAME = "no_pulldown_notification_bar";
+    private static final int KEY_ENABLE = 1;
+    private static final int KEY_DISABLE = 0;
+    private static final String KEY_No_NOTIFICATION_SHOW = "hide_panels";
+    private Preference mPreference;
+
+   public pulldownnotificationbarPreferenceController(Context context) {
+        super(context);
+        context.getContentResolver().registerContentObserver(Settings.Global.getUriFor("display_status_bar"), true, statusbarShowObserver);
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY_NAME;
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = screen.findPreference(KEY_NAME);
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        boolean value = (Boolean) newValue;
+        if(value){
+            Settings.Global.putInt(mContext.getContentResolver(), KEY_No_NOTIFICATION_SHOW, KEY_ENABLE);
+        }else {
+           Settings.Global.putInt(mContext.getContentResolver(), KEY_No_NOTIFICATION_SHOW, KEY_DISABLE);
+        }
+        return true;
+   }
+
+        final private ContentObserver statusbarShowObserver = new ContentObserver(new Handler()) {
+        @Override
+        public void onChange(boolean selfChange) {
+            boolean isShow = Settings.Global.getInt(mContext.getContentResolver(), "display_status_bar", 1) == 0;
+            if(isShow){
+                 mPreference.setEnabled(false);
+            }else{
+           mPreference.setEnabled(true);
+         }
+        }
+    };
+
+    @Override
+   public void updateState(Preference preference) {
+        int value = Settings.Global.getInt(mContext.getContentResolver(),
+                KEY_No_NOTIFICATION_SHOW, KEY_ENABLE);
+        ((SwitchPreference) preference).setChecked(value != KEY_DISABLE);
+    }
+}
 No newline at end of file

小伙伴可以快去试试

风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。