0


SystemUI默认去掉底部导航栏

一、背景

  1. Android系统中,SystemUI负责管理系统的状态栏、导航栏等用户界面元素。若要在SystemUI中默认去掉底部导航栏,

可以通过以下几种方法实现:

1. 修改布局文件

在Android的SystemUI源代码中,底部导航栏的布局文件通常位于

  1. com.android.systemui.statusbar.phone

包中,文件名可能为

  1. NavigationBarView.xml

或其他与导航栏相关的布局文件。通过修改这些布局文件,可以隐藏底部导航栏。具体步骤包括:

  • 使用Android Studio或其他IDE打开SystemUI项目。
  • 导入Android的SystemUI源代码。
  • 导航到与导航栏布局相关的文件。
  • 修改布局文件中的代码以隐藏底部导航栏,例如通过设置visibility属性为GONEINVISIBLE
  1. frameworks\base\core\res\res\values\demins.xml

2. 编程方式隐藏

在SystemUI的Java代码中,可以通过编程方式控制底部导航栏的显示与隐藏。这通常涉及到对

  1. NavigationBarController

或类似控制器的操作。例如,可以通过调用

  1. setSystemUiVisibility

方法并传入适当的标志来隐藏导航栏,如

  1. View.SYSTEM_UI_FLAG_HIDE_NAVIGATION

。但请注意,这种方法可能需要在应用层面而非系统层面实现,因为直接修改SystemUI的代码通常需要对Android系统进行深度定制。

  1. frameworks\base\services\core\java\com\android\server\wm\DisplayPolicy.java

3. 使用手势导航

  1. 主要核心代码:
  2. framework/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java

二、改变状态栏或者其他系统UI的可见性

  1. setSystemUiVisibility(int visibility):通过setSystemUiVisibility(int visibility)方法,可以改变状态栏或者其他系统UI的可见性。getWindow().getDecorView().setSystemUiVisibility(int visibility);

可供选择的参数:

View.SYSTEM_UI_FLAG_VISIBLE(默认模式,显示状态栏和导航栏)
View.SYSTEM_UI_FLAG_LOW_PROFILE(低调模式,隐藏不重要的状态栏图标,导航栏中相应的图标都变成了一个小点。点击状态栏或导航栏还原成正常的状态)
SYSTEM_UI_FLAG_HIDE_NAVIGATION(隐藏导航栏,点击屏幕任意区域,导航栏将重新出现,并且不会自动消失
SYSTEM_UI_FLAG_FULLSCREEN(隐藏状态栏,点击屏幕区域不会出现,需要从状态栏位置下拉才会出现)
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

三、三种方法去去掉底部导航栏

1、StatusBar中实现默认去掉底部导航栏

  1. @Override
  2. public void start() {
  3. mGroupManager = Dependency.get(NotificationGroupManager.class);
  4. mGroupAlertTransferHelper = Dependency.get(NotificationGroupAlertTransferHelper.class);
  5. mVisualStabilityManager = Dependency.get(VisualStabilityManager.class);
  6. mNotificationLogger = Dependency.get(NotificationLogger.class);
  7. mRemoteInputManager = Dependency.get(NotificationRemoteInputManager.class);
  8. mNotificationListener = Dependency.get(NotificationListener.class);
  9. mNotificationListener.registerAsSystemService();
  10. mNetworkController = Dependency.get(NetworkController.class);
  11. mUserSwitcherController = Dependency.get(UserSwitcherController.class);
  12. mScreenLifecycle = Dependency.get(ScreenLifecycle.class);
  13. mScreenLifecycle.addObserver(mScreenObserver);
  14. mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
  15. mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
  16. mBatteryController = Dependency.get(BatteryController.class);
  17. mDataSaverController = Dependency.get(DataSaverController.class);
  18. mAssistManager = Dependency.get(AssistManager.class);
  19. mUiModeManager = mContext.getSystemService(UiModeManager.class);
  20. mLockscreenUserManager = Dependency.get(NotificationLockscreenUserManager.class);
  21. mGutsManager = Dependency.get(NotificationGutsManager.class);
  22. mMediaManager = Dependency.get(NotificationMediaManager.class);
  23. mEntryManager = Dependency.get(NotificationEntryManager.class);
  24. mNotificationInterruptionStateProvider =
  25. Dependency.get(NotificationInterruptionStateProvider.class);
  26. mViewHierarchyManager = Dependency.get(NotificationViewHierarchyManager.class);
  27. mForegroundServiceController = Dependency.get(ForegroundServiceController.class);
  28. mAppOpsController = Dependency.get(AppOpsController.class);
  29. mZenController = Dependency.get(ZenModeController.class);
  30. mKeyguardViewMediator = getComponent(KeyguardViewMediator.class);
  31. mColorExtractor = Dependency.get(SysuiColorExtractor.class);
  32. mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
  33. mNavigationBarController = Dependency.get(NavigationBarController.class);
  34. mBubbleController = Dependency.get(BubbleController.class);
  35. mBubbleController.setExpandListener(mBubbleExpandListener);
  36. mActivityIntentHelper = new ActivityIntentHelper(mContext);
  37. KeyguardSliceProvider sliceProvider = KeyguardSliceProvider.getAttachedInstance();
  38. if (sliceProvider != null) {
  39. sliceProvider.initDependencies(mMediaManager, mStatusBarStateController);
  40. } else {
  41. Log.w(TAG, "Cannot init KeyguardSliceProvider dependencies");
  42. }
  43. mColorExtractor.addOnColorsChangedListener(this);
  44. mStatusBarStateController.addCallback(this,
  45. SysuiStatusBarStateController.RANK_STATUS_BAR);
  46. mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
  47. mDreamManager = IDreamManager.Stub.asInterface(
  48. ServiceManager.checkService(DreamService.DREAM_SERVICE));
  49. /* UNISOC: Bug 1074234, 885650, Super power feature @{ */
  50. if(SprdPowerManagerUtil.SUPPORT_SUPER_POWER_SAVE){
  51. int mode = SprdPowerManagerUtil.getPowerSaveModeInternal();
  52. mPowerSaveMode = mode;
  53. curMode = mode;
  54. }
  55. /* @} */
  56. mDisplay = mWindowManager.getDefaultDisplay();
  57. mDisplayId = mDisplay.getDisplayId();
  58. updateDisplaySize();
  59. mVibrateOnOpening = mContext.getResources().getBoolean(
  60. R.bool.config_vibrateOnIconAnimation);
  61. mVibratorHelper = Dependency.get(VibratorHelper.class);
  62. DateTimeView.setReceiverHandler(Dependency.get(Dependency.TIME_TICK_HANDLER));
  63. putComponent(StatusBar.class, this);
  64. // start old BaseStatusBar.start().
  65. mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
  66. mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService(
  67. Context.DEVICE_POLICY_SERVICE);
  68. mAccessibilityManager = (AccessibilityManager)
  69. mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
  70. mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
  71. mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
  72. mBarService = IStatusBarService.Stub.asInterface(
  73. ServiceManager.getService(Context.STATUS_BAR_SERVICE));
  74. mRecents = getComponent(Recents.class);
  75. mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
  76. // Connect in to the status bar manager service
  77. mCommandQueue = getComponent(CommandQueue.class);
  78. mCommandQueue.addCallback(this);
  79. RegisterStatusBarResult result = null;
  80. try {
  81. result = mBarService.registerStatusBar(mCommandQueue);
  82. } catch (RemoteException ex) {
  83. ex.rethrowFromSystemServer();
  84. }
  85. createAndAddWindows(result);
  86. // Make sure we always have the most current wallpaper info.
  87. IntentFilter wallpaperChangedFilter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED);
  88. mContext.registerReceiverAsUser(mWallpaperChangedReceiver, UserHandle.ALL,
  89. wallpaperChangedFilter, null /* broadcastPermission */, null /* scheduler */);
  90. mWallpaperChangedReceiver.onReceive(mContext, null);
  91. // Set up the initial notification state. This needs to happen before CommandQueue.disable()
  92. setUpPresenter();
  93. setSystemUiVisibility(mDisplayId, result.mSystemUiVisibility,
  94. result.mFullscreenStackSysUiVisibility, result.mDockedStackSysUiVisibility,
  95. 0xffffffff, result.mFullscreenStackBounds, result.mDockedStackBounds,
  96. result.mNavbarColorManagedByIme);
  97. // StatusBarManagerService has a back up of IME token and it's restored here.
  98. setImeWindowStatus(mDisplayId, result.mImeToken, result.mImeWindowVis,
  99. result.mImeBackDisposition, result.mShowImeSwitcher);
  100. // Set up the initial icon state
  101. int numIcons = result.mIcons.size();
  102. for (int i = 0; i < numIcons; i++) {
  103. mCommandQueue.setIcon(result.mIcons.keyAt(i), result.mIcons.valueAt(i));
  104. }
  105. if (DEBUG) {
  106. Log.d(TAG, String.format(
  107. "init: icons=%d disabled=0x%08x lights=0x%08x imeButton=0x%08x",
  108. numIcons,
  109. result.mDisabledFlags1,
  110. result.mSystemUiVisibility,
  111. result.mImeWindowVis));
  112. }
  113. IntentFilter internalFilter = new IntentFilter();
  114. internalFilter.addAction(BANNER_ACTION_CANCEL);
  115. internalFilter.addAction(BANNER_ACTION_SETUP);
  116. mContext.registerReceiver(mBannerActionBroadcastReceiver, internalFilter, PERMISSION_SELF,
  117. null);
  118. IWallpaperManager wallpaperManager = IWallpaperManager.Stub.asInterface(
  119. ServiceManager.getService(Context.WALLPAPER_SERVICE));
  120. try {
  121. wallpaperManager.setInAmbientMode(false /* ambientMode */, 0L /* duration */);
  122. } catch (RemoteException e) {
  123. // Just pass, nothing critical.
  124. }
  125. // end old BaseStatusBar.start().
  126. // Lastly, call to the icon policy to install/update all the icons.
  127. mIconPolicy = new PhoneStatusBarPolicy(mContext, mIconController);
  128. mSignalPolicy = new StatusBarSignalPolicy(mContext, mIconController);
  129. mUnlockMethodCache = UnlockMethodCache.getInstance(mContext);
  130. mUnlockMethodCache.addListener(this);
  131. startKeyguard();
  132. mKeyguardUpdateMonitor.registerCallback(mUpdateCallback);
  133. putComponent(DozeHost.class, mDozeServiceHost);
  134. mScreenPinningRequest = new ScreenPinningRequest(mContext);
  135. mFalsingManager = FalsingManagerFactory.getInstance(mContext);
  136. Dependency.get(ActivityStarterDelegate.class).setActivityStarterImpl(this);
  137. Dependency.get(ConfigurationController.class).addCallback(this);
  138. // set the initial view visibility
  139. Dependency.get(InitController.class).addPostInitTask(this::updateAreThereNotifications);
  140. int disabledFlags1 = result.mDisabledFlags1;
  141. int disabledFlags2 = result.mDisabledFlags2;
  142. Dependency.get(InitController.class).addPostInitTask(
  143. () -> setUpDisableFlags(disabledFlags1, disabledFlags2));
  144. // UNISOC: BUG 1156257 add screen resolution observer to control NavigationBarView
  145. mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(ACTION_SR_CHANGING),
  146. false, mScreenResolutionObserver);
  147. CommonUtils.setRegionOrLongshotMode(mContext.getContentResolver(), 0);
  148. }
  149. // ================================================================================
  150. // Constructing the view
  151. // ================================================================================
  152. protected void makeStatusBarView(@Nullable RegisterStatusBarResult result) {
  153. final Context context = mContext;
  154. updateDisplaySize(); // populates mDisplayMetrics
  155. updateResources();
  156. updateTheme();
  157. inflateStatusBarWindow(context);
  158. mStatusBarWindow.setService(this);
  159. mStatusBarWindow.setOnTouchListener(getStatusBarWindowTouchListener());
  160. // TODO: Deal with the ugliness that comes from having some of the statusbar broken out
  161. // into fragments, but the rest here, it leaves some awkward lifecycle and whatnot.
  162. mNotificationPanel = mStatusBarWindow.findViewById(R.id.notification_panel);
  163. mStackScroller = mStatusBarWindow.findViewById(R.id.notification_stack_scroller);
  164. mZenController.addCallback(this);
  165. NotificationListContainer notifListContainer = (NotificationListContainer) mStackScroller;
  166. mNotificationLogger.setUpWithContainer(notifListContainer);
  167. mNotificationIconAreaController = SystemUIFactory.getInstance()
  168. .createNotificationIconAreaController(context, this, mStatusBarStateController);
  169. inflateShelf();
  170. mNotificationIconAreaController.setupShelf(mNotificationShelf);
  171. Dependency.get(DarkIconDispatcher.class).addDarkReceiver(mNotificationIconAreaController);
  172. // Allow plugins to reference DarkIconDispatcher and StatusBarStateController
  173. Dependency.get(PluginDependencyProvider.class)
  174. .allowPluginDependency(DarkIconDispatcher.class);
  175. Dependency.get(PluginDependencyProvider.class)
  176. .allowPluginDependency(StatusBarStateController.class);
  177. FragmentHostManager.get(mStatusBarWindow)
  178. .addTagListener(CollapsedStatusBarFragment.TAG, (tag, fragment) -> {
  179. CollapsedStatusBarFragment statusBarFragment =
  180. (CollapsedStatusBarFragment) fragment;
  181. statusBarFragment.initNotificationIconArea(mNotificationIconAreaController);
  182. PhoneStatusBarView oldStatusBarView = mStatusBarView;
  183. mStatusBarView = (PhoneStatusBarView) fragment.getView();
  184. mStatusBarView.setBar(this);
  185. mStatusBarView.setPanel(mNotificationPanel);
  186. mStatusBarView.setScrimController(mScrimController);
  187. // CollapsedStatusBarFragment re-inflated PhoneStatusBarView and both of
  188. // mStatusBarView.mExpanded and mStatusBarView.mBouncerShowing are false.
  189. // PhoneStatusBarView's new instance will set to be gone in
  190. // PanelBar.updateVisibility after calling mStatusBarView.setBouncerShowing
  191. // that will trigger PanelBar.updateVisibility. If there is a heads up showing,
  192. // it needs to notify PhoneStatusBarView's new instance to update the correct
  193. // status by calling mNotificationPanel.notifyBarPanelExpansionChanged().
  194. if (mHeadsUpManager.hasPinnedHeadsUp()) {
  195. mNotificationPanel.notifyBarPanelExpansionChanged();
  196. }
  197. mStatusBarView.setBouncerShowing(mBouncerShowing);
  198. if (oldStatusBarView != null) {
  199. float fraction = oldStatusBarView.getExpansionFraction();
  200. boolean expanded = oldStatusBarView.isExpanded();
  201. mStatusBarView.panelExpansionChanged(fraction, expanded);
  202. }
  203. HeadsUpAppearanceController oldController = mHeadsUpAppearanceController;
  204. if (mHeadsUpAppearanceController != null) {
  205. // This view is being recreated, let's destroy the old one
  206. mHeadsUpAppearanceController.destroy();
  207. }
  208. mHeadsUpAppearanceController = new HeadsUpAppearanceController(
  209. mNotificationIconAreaController, mHeadsUpManager, mStatusBarWindow);
  210. mHeadsUpAppearanceController.readFrom(oldController);
  211. mStatusBarWindow.setStatusBarView(mStatusBarView);
  212. updateAreThereNotifications();
  213. checkBarModes();
  214. }).getFragmentManager()
  215. .beginTransaction()
  216. .replace(R.id.status_bar_container, new CollapsedStatusBarFragment(),
  217. CollapsedStatusBarFragment.TAG)
  218. .commit();
  219. mIconController = Dependency.get(StatusBarIconController.class);
  220. mHeadsUpManager = new HeadsUpManagerPhone(context, mStatusBarWindow, mGroupManager, this,
  221. mVisualStabilityManager);
  222. Dependency.get(ConfigurationController.class).addCallback(mHeadsUpManager);
  223. mHeadsUpManager.addListener(this);
  224. mHeadsUpManager.addListener(mNotificationPanel);
  225. mHeadsUpManager.addListener(mGroupManager);
  226. mHeadsUpManager.addListener(mGroupAlertTransferHelper);
  227. mHeadsUpManager.addListener(mVisualStabilityManager);
  228. mAmbientPulseManager.addListener(this);
  229. mAmbientPulseManager.addListener(mGroupManager);
  230. mAmbientPulseManager.addListener(mGroupAlertTransferHelper);
  231. mNotificationPanel.setHeadsUpManager(mHeadsUpManager);
  232. mGroupManager.setHeadsUpManager(mHeadsUpManager);
  233. mGroupAlertTransferHelper.setHeadsUpManager(mHeadsUpManager);
  234. mNotificationLogger.setHeadsUpManager(mHeadsUpManager);
  235. putComponent(HeadsUpManager.class, mHeadsUpManager);
  236. createNavigationBar(result);
  237. if (ENABLE_LOCKSCREEN_WALLPAPER) {
  238. mLockscreenWallpaper = new LockscreenWallpaper(mContext, this, mHandler);
  239. }
  240. mKeyguardIndicationController =
  241. SystemUIFactory.getInstance().createKeyguardIndicationController(mContext,
  242. mStatusBarWindow.findViewById(R.id.keyguard_indication_area),
  243. mStatusBarWindow.findViewById(R.id.lock_icon));
  244. mNotificationPanel.setKeyguardIndicationController(mKeyguardIndicationController);
  245. mAmbientIndicationContainer = mStatusBarWindow.findViewById(
  246. R.id.ambient_indication_container);
  247. // TODO: Find better place for this callback.
  248. mBatteryController.addCallback(new BatteryStateChangeCallback() {
  249. @Override
  250. public void onPowerSaveChanged(boolean isPowerSave) {
  251. mHandler.post(mCheckBarModes);
  252. if (mDozeServiceHost != null) {
  253. mDozeServiceHost.firePowerSaveChanged(isPowerSave);
  254. }
  255. }
  256. @Override
  257. public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
  258. // noop
  259. }
  260. });
  261. mAutoHideController = Dependency.get(AutoHideController.class);
  262. mAutoHideController.setStatusBar(this);
  263. mLightBarController = Dependency.get(LightBarController.class);
  264. ScrimView scrimBehind = mStatusBarWindow.findViewById(R.id.scrim_behind);
  265. ScrimView scrimInFront = mStatusBarWindow.findViewById(R.id.scrim_in_front);
  266. mScrimController = SystemUIFactory.getInstance().createScrimController(
  267. scrimBehind, scrimInFront, mLockscreenWallpaper,
  268. (state, alpha, color) -> mLightBarController.setScrimState(state, alpha, color),
  269. scrimsVisible -> {
  270. if (mStatusBarWindowController != null) {
  271. mStatusBarWindowController.setScrimsVisibility(scrimsVisible);
  272. }
  273. if (mStatusBarWindow != null) {
  274. mStatusBarWindow.onScrimVisibilityChanged(scrimsVisible);
  275. }
  276. }, DozeParameters.getInstance(mContext),
  277. mContext.getSystemService(AlarmManager.class));
  278. mNotificationPanel.initDependencies(this, mGroupManager, mNotificationShelf,
  279. mHeadsUpManager, mNotificationIconAreaController, mScrimController);
  280. mDozeScrimController = new DozeScrimController(DozeParameters.getInstance(context));
  281. BackDropView backdrop = mStatusBarWindow.findViewById(R.id.backdrop);
  282. mMediaManager.setup(backdrop, backdrop.findViewById(R.id.backdrop_front),
  283. backdrop.findViewById(R.id.backdrop_back), mScrimController, mLockscreenWallpaper);
  284. // Other icons
  285. mVolumeComponent = getComponent(VolumeComponent.class);
  286. mNotificationPanel.setUserSetupComplete(mUserSetup);
  287. if (UserManager.get(mContext).isUserSwitcherEnabled()) {
  288. createUserSwitcher();
  289. }
  290. mNotificationPanel.setLaunchAffordanceListener(
  291. mStatusBarWindow::onShowingLaunchAffordanceChanged);
  292. // Set up the quick settings tile panel
  293. View container = mStatusBarWindow.findViewById(R.id.qs_frame);
  294. if (container != null) {
  295. FragmentHostManager fragmentHostManager = FragmentHostManager.get(container);
  296. ExtensionFragmentListener.attachExtensonToFragment(container, QS.TAG, R.id.qs_frame,
  297. Dependency.get(ExtensionController.class)
  298. .newExtension(QS.class)
  299. .withPlugin(QS.class)
  300. .withDefault(this::createDefaultQSFragment)
  301. .build());
  302. mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow,
  303. (visible) -> {
  304. mBrightnessMirrorVisible = visible;
  305. updateScrimController();
  306. });
  307. fragmentHostManager.addTagListener(QS.TAG, (tag, f) -> {
  308. QS qs = (QS) f;
  309. if (qs instanceof QSFragment) {
  310. mQSPanel = ((QSFragment) qs).getQsPanel();
  311. mQSPanel.setBrightnessMirror(mBrightnessMirrorController);
  312. mFooter = ((QSFragment) qs).getFooter();
  313. }
  314. });
  315. }
  316. mReportRejectedTouch = mStatusBarWindow.findViewById(R.id.report_rejected_touch);
  317. if (mReportRejectedTouch != null) {
  318. updateReportRejectedTouchVisibility();
  319. mReportRejectedTouch.setOnClickListener(v -> {
  320. Uri session = mFalsingManager.reportRejectedTouch();
  321. if (session == null) { return; }
  322. StringWriter message = new StringWriter();
  323. message.write("Build info: ");
  324. message.write(SystemProperties.get("ro.build.description"));
  325. message.write("\nSerial number: ");
  326. message.write(SystemProperties.get("ro.serialno"));
  327. message.write("\n");
  328. PrintWriter falsingPw = new PrintWriter(message);
  329. FalsingLog.dump(falsingPw);
  330. falsingPw.flush();
  331. startActivityDismissingKeyguard(Intent.createChooser(new Intent(Intent.ACTION_SEND)
  332. .setType("*/*")
  333. .putExtra(Intent.EXTRA_SUBJECT, "Rejected touch report")
  334. .putExtra(Intent.EXTRA_STREAM, session)
  335. .putExtra(Intent.EXTRA_TEXT, message.toString()),
  336. "Share rejected touch report")
  337. .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
  338. true /* onlyProvisioned */, true /* dismissShade */);
  339. });
  340. }
  341. PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
  342. if (!pm.isScreenOn()) {
  343. mBroadcastReceiver.onReceive(mContext, new Intent(Intent.ACTION_SCREEN_OFF));
  344. }
  345. mGestureWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
  346. "GestureWakeLock");
  347. mVibrator = mContext.getSystemService(Vibrator.class);
  348. int[] pattern = mContext.getResources().getIntArray(
  349. R.array.config_cameraLaunchGestureVibePattern);
  350. mCameraLaunchGestureVibePattern = new long[pattern.length];
  351. for (int i = 0; i < pattern.length; i++) {
  352. mCameraLaunchGestureVibePattern[i] = pattern[i];
  353. }
  354. // receive broadcasts
  355. IntentFilter filter = new IntentFilter();
  356. filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  357. filter.addAction(Intent.ACTION_SCREEN_OFF);
  358. filter.addAction(DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG);
  359. /* UNISOC: Bug 1074234, 885650, Super power feature @{ */
  360. if(SprdPowerManagerUtil.SUPPORT_SUPER_POWER_SAVE){
  361. filter.addAction(SprdPowerManagerUtil.ACTION_POWEREX_SAVE_MODE_CHANGED);
  362. }
  363. /* @} */
  364. context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
  365. IntentFilter demoFilter = new IntentFilter();
  366. if (DEBUG_MEDIA_FAKE_ARTWORK) {
  367. demoFilter.addAction(ACTION_FAKE_ARTWORK);
  368. }
  369. demoFilter.addAction(ACTION_DEMO);
  370. context.registerReceiverAsUser(mDemoReceiver, UserHandle.ALL, demoFilter,
  371. android.Manifest.permission.DUMP, null);
  372. // listen for USER_SETUP_COMPLETE setting (per-user)
  373. mDeviceProvisionedController.addCallback(mUserSetupObserver);
  374. mUserSetupObserver.onUserSetupChanged();
  375. // disable profiling bars, since they overlap and clutter the output on app windows
  376. ThreadedRenderer.overrideProperty("disableProfileBars", "true");
  377. // Private API call to make the shadows look better for Recents
  378. ThreadedRenderer.overrideProperty("ambientRatio", String.valueOf(1.5f));
  379. /* UNISOC: Bug 1074234, 885650, Super power feature @{ */
  380. if(SprdPowerManagerUtil.SUPPORT_SUPER_POWER_SAVE && mNotificationPanel != null){
  381. int mode = SprdPowerManagerUtil.getPowerSaveModeInternal();
  382. if(mFooter != null){
  383. mFooter.setPowerSaveMode(mode);
  384. }
  385. if(mQSPanel != null){
  386. mQSPanel.setPowerSaveMode(mode);
  387. }
  388. if (mNotificationPanel != null){
  389. mNotificationPanel.setPowerSaveMode(mode);
  390. }
  391. /* UNISOC: Modify for bug974161 {@ */
  392. mNavigationBarController.setPowerSaveMode(mode);
  393. /* @} */
  394. }
  395. /* @} */
  396. /* UNISOC: Bug 1104465 add for screen pinning @{ */
  397. mScreenPinningNotify = new ScreenPinningNotify(mContext);
  398. /* @} */
  399. }
  400. makeStatusBarView(@Nullable RegisterStatusBarResult result)中的 createNavigationBar(result); 就是加载导航栏 直接注释掉就可以了

2、在DisplayPolicy.java中去掉底部导航栏

  1. public boolean hasNavigationBar() {
  2. return mHasNavigationBar;
  3. }
  4. /**
  5. * Return the display height available after excluding any screen
  6. * decorations that could never be removed in Honeycomb. That is, system bar or
  7. * button bar.
  8. */
  9. public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode,
  10. DisplayCutout displayCutout) {
  11. int height = fullHeight;
  12. if (hasNavigationBar()) {
  13. final int navBarPosition = navigationBarPosition(fullWidth, fullHeight, rotation);
  14. if (navBarPosition == NAV_BAR_BOTTOM) {
  15. height -= getNavigationBarHeight(rotation, uiMode);
  16. }
  17. }
  18. if (displayCutout != null) {
  19. height -= displayCutout.getSafeInsetTop() + displayCutout.getSafeInsetBottom();
  20. }
  21. return height;
  22. }
  23. /**
  24. * Return the display width available after excluding any screen
  25. * decorations that could never be removed in Honeycomb. That is, system bar or
  26. * button bar.
  27. */
  28. public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode,
  29. DisplayCutout displayCutout) {
  30. int width = fullWidth;
  31. if (hasNavigationBar()) {
  32. final int navBarPosition = navigationBarPosition(fullWidth, fullHeight, rotation);
  33. if (navBarPosition == NAV_BAR_LEFT || navBarPosition == NAV_BAR_RIGHT) {
  34. width -= getNavigationBarWidth(rotation, uiMode);
  35. }
  36. }
  37. if (displayCutout != null) {
  38. width -= displayCutout.getSafeInsetLeft() + displayCutout.getSafeInsetRight();
  39. }
  40. return width;
  41. }
  42. 根据hasNavigationBar()判断是否有导航栏来就是显示屏幕宽度和高度
  43. 所以修改为:
  44. public boolean hasNavigationBar() {
  45. - return mHasNavigationBar;
  46. + return false;
  47. }

3、默认隐藏导航栏

  1. 设置导航栏高度为0
  2. 路径:frameworks\base\core\res\res\values\demins.xml
  3. <dimen name="navigation_bar_height">48dp</dimen>
  4. navigation_bar_height 导航栏高度设置为0

4、修改完成记得执行快速编译命令

  1. make snod

然后重启编译备,模拟器或者设备即可看到效果。

参考

标签: android

本文转载自: https://blog.csdn.net/shi450561200/article/details/140588928
版权归原作者 人民的石头 所有, 如有侵权,请联系我们删除。

“SystemUI默认去掉底部导航栏”的评论:

还没有评论