Loading core/java/com/android/internal/policy/ForceShowNavigationBarSettingsObserver.java 0 → 100644 +83 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.policy; import android.content.ContentResolver; import android.content.Context; import android.database.ContentObserver; import android.os.Handler; import android.os.UserHandle; import android.provider.Settings; /** * A ContentObserver for listening force show navigation bar relative setting keys: * - {@link Settings.Secure#NAVIGATION_MODE} * - {@link Settings.Secure#NAV_BAR_KIDS_MODE} * * @hide */ public class ForceShowNavigationBarSettingsObserver extends ContentObserver { private Context mContext; private Runnable mOnChangeRunnable; public ForceShowNavigationBarSettingsObserver(Handler handler, Context context) { super(handler); mContext = context; } public void setOnChangeRunnable(Runnable r) { mOnChangeRunnable = r; } /** * Registers the observer. */ public void register() { final ContentResolver r = mContext.getContentResolver(); r.registerContentObserver( Settings.Secure.getUriFor(Settings.Secure.NAVIGATION_MODE), false, this, UserHandle.USER_ALL); r.registerContentObserver( Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), false, this, UserHandle.USER_ALL); } /** * Unregisters the observer. */ public void unregister() { mContext.getContentResolver().unregisterContentObserver(this); } @Override public void onChange(boolean selfChange) { if (mOnChangeRunnable != null) { mOnChangeRunnable.run(); } } /** * Returns true only when it's in three button nav mode and the kid nav bar mode is enabled. * Otherwise, return false. */ public boolean isEnabled() { return Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.NAVIGATION_MODE, 0, UserHandle.USER_CURRENT) == 0 && Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.NAV_BAR_KIDS_MODE, 0, UserHandle.USER_CURRENT) == 1; } } services/core/java/com/android/server/wm/DisplayPolicy.java +23 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ import android.view.accessibility.AccessibilityManager; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.ForceShowNavigationBarSettingsObserver; import com.android.internal.policy.GestureNavigationSettingsObserver; import com.android.internal.policy.ScreenDecorationsUtils; import com.android.internal.policy.SystemBarUtils; Loading Loading @@ -381,6 +382,9 @@ public class DisplayPolicy { private final WindowManagerInternal.AppTransitionListener mAppTransitionListener; private final ForceShowNavigationBarSettingsObserver mForceShowNavigationBarSettingsObserver; private boolean mForceShowNavigationBarEnabled; private class PolicyHandler extends Handler { PolicyHandler(Looper looper) { Loading Loading @@ -652,6 +656,18 @@ public class DisplayPolicy { } }); mHandler.post(mGestureNavigationSettingsObserver::register); mForceShowNavigationBarSettingsObserver = new ForceShowNavigationBarSettingsObserver( mHandler, mContext); mForceShowNavigationBarSettingsObserver.setOnChangeRunnable(() -> { synchronized (mLock) { mForceShowNavigationBarEnabled = mForceShowNavigationBarSettingsObserver.isEnabled(); updateSystemBarAttributes(); } }); mForceShowNavigationBarEnabled = mForceShowNavigationBarSettingsObserver.isEnabled(); mHandler.post(mForceShowNavigationBarSettingsObserver::register); } /** Loading Loading @@ -791,6 +807,10 @@ public class DisplayPolicy { return mWindowManagerDrawComplete; } public boolean isForceShowNavigationBarEnabled() { return mForceShowNavigationBarEnabled; } public ScreenOnListener getScreenOnListener() { return mScreenOnListener; } Loading Loading @@ -2755,6 +2775,8 @@ public class DisplayPolicy { } pw.print(prefix); pw.print("mTopIsFullscreen="); pw.println(mTopIsFullscreen); pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); pw.print(prefix); pw.print("mForceShowNavigationBarEnabled="); pw.print(mForceShowNavigationBarEnabled); pw.print(" mAllowLockscreenWhenOn="); pw.println(mAllowLockscreenWhenOn); pw.print(prefix); pw.print("mRemoteInsetsControllerControlsSystemBars="); pw.println(mDisplayContent.getInsetsPolicy().getRemoteInsetsControllerControlsSystemBars()); Loading Loading @@ -2832,6 +2854,7 @@ public class DisplayPolicy { void release() { mDisplayContent.mTransitionController.unregisterLegacyListener(mAppTransitionListener); mHandler.post(mGestureNavigationSettingsObserver::unregister); mHandler.post(mForceShowNavigationBarSettingsObserver::unregister); mImmersiveModeConfirmation.release(); } Loading services/core/java/com/android/server/wm/InsetsPolicy.java +9 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.wm; import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN; import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.view.InsetsController.ANIMATION_TYPE_HIDE; import static android.view.InsetsController.ANIMATION_TYPE_SHOW; import static android.view.InsetsController.LAYOUT_INSETS_DURING_ANIMATION_HIDDEN; Loading Loading @@ -450,6 +451,14 @@ class InsetsPolicy { // Notification shade has control anyways, no reason to force anything. return focusedWin; } if (mPolicy.isForceShowNavigationBarEnabled() && focusedWin.getActivityType() == ACTIVITY_TYPE_STANDARD) { // When "force show navigation bar" is enabled, it means we are in kid navigation bar // and 3-button navigation bar mode. In this mode, the navigation bar is forcibly shown // when activity type is ACTIVITY_TYPE_STANDARD which means Launcher or Recent could // still control the navigation bar in this mode. return null; } if (remoteInsetsControllerControlsSystemBars(focusedWin)) { mDisplayContent.mRemoteInsetsControlTarget.topFocusedWindowChanged( focusedWin.mAttrs.packageName); Loading Loading
core/java/com/android/internal/policy/ForceShowNavigationBarSettingsObserver.java 0 → 100644 +83 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.policy; import android.content.ContentResolver; import android.content.Context; import android.database.ContentObserver; import android.os.Handler; import android.os.UserHandle; import android.provider.Settings; /** * A ContentObserver for listening force show navigation bar relative setting keys: * - {@link Settings.Secure#NAVIGATION_MODE} * - {@link Settings.Secure#NAV_BAR_KIDS_MODE} * * @hide */ public class ForceShowNavigationBarSettingsObserver extends ContentObserver { private Context mContext; private Runnable mOnChangeRunnable; public ForceShowNavigationBarSettingsObserver(Handler handler, Context context) { super(handler); mContext = context; } public void setOnChangeRunnable(Runnable r) { mOnChangeRunnable = r; } /** * Registers the observer. */ public void register() { final ContentResolver r = mContext.getContentResolver(); r.registerContentObserver( Settings.Secure.getUriFor(Settings.Secure.NAVIGATION_MODE), false, this, UserHandle.USER_ALL); r.registerContentObserver( Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), false, this, UserHandle.USER_ALL); } /** * Unregisters the observer. */ public void unregister() { mContext.getContentResolver().unregisterContentObserver(this); } @Override public void onChange(boolean selfChange) { if (mOnChangeRunnable != null) { mOnChangeRunnable.run(); } } /** * Returns true only when it's in three button nav mode and the kid nav bar mode is enabled. * Otherwise, return false. */ public boolean isEnabled() { return Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.NAVIGATION_MODE, 0, UserHandle.USER_CURRENT) == 0 && Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.NAV_BAR_KIDS_MODE, 0, UserHandle.USER_CURRENT) == 1; } }
services/core/java/com/android/server/wm/DisplayPolicy.java +23 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ import android.view.accessibility.AccessibilityManager; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.ForceShowNavigationBarSettingsObserver; import com.android.internal.policy.GestureNavigationSettingsObserver; import com.android.internal.policy.ScreenDecorationsUtils; import com.android.internal.policy.SystemBarUtils; Loading Loading @@ -381,6 +382,9 @@ public class DisplayPolicy { private final WindowManagerInternal.AppTransitionListener mAppTransitionListener; private final ForceShowNavigationBarSettingsObserver mForceShowNavigationBarSettingsObserver; private boolean mForceShowNavigationBarEnabled; private class PolicyHandler extends Handler { PolicyHandler(Looper looper) { Loading Loading @@ -652,6 +656,18 @@ public class DisplayPolicy { } }); mHandler.post(mGestureNavigationSettingsObserver::register); mForceShowNavigationBarSettingsObserver = new ForceShowNavigationBarSettingsObserver( mHandler, mContext); mForceShowNavigationBarSettingsObserver.setOnChangeRunnable(() -> { synchronized (mLock) { mForceShowNavigationBarEnabled = mForceShowNavigationBarSettingsObserver.isEnabled(); updateSystemBarAttributes(); } }); mForceShowNavigationBarEnabled = mForceShowNavigationBarSettingsObserver.isEnabled(); mHandler.post(mForceShowNavigationBarSettingsObserver::register); } /** Loading Loading @@ -791,6 +807,10 @@ public class DisplayPolicy { return mWindowManagerDrawComplete; } public boolean isForceShowNavigationBarEnabled() { return mForceShowNavigationBarEnabled; } public ScreenOnListener getScreenOnListener() { return mScreenOnListener; } Loading Loading @@ -2755,6 +2775,8 @@ public class DisplayPolicy { } pw.print(prefix); pw.print("mTopIsFullscreen="); pw.println(mTopIsFullscreen); pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); pw.print(prefix); pw.print("mForceShowNavigationBarEnabled="); pw.print(mForceShowNavigationBarEnabled); pw.print(" mAllowLockscreenWhenOn="); pw.println(mAllowLockscreenWhenOn); pw.print(prefix); pw.print("mRemoteInsetsControllerControlsSystemBars="); pw.println(mDisplayContent.getInsetsPolicy().getRemoteInsetsControllerControlsSystemBars()); Loading Loading @@ -2832,6 +2854,7 @@ public class DisplayPolicy { void release() { mDisplayContent.mTransitionController.unregisterLegacyListener(mAppTransitionListener); mHandler.post(mGestureNavigationSettingsObserver::unregister); mHandler.post(mForceShowNavigationBarSettingsObserver::unregister); mImmersiveModeConfirmation.release(); } Loading
services/core/java/com/android/server/wm/InsetsPolicy.java +9 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.wm; import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN; import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.view.InsetsController.ANIMATION_TYPE_HIDE; import static android.view.InsetsController.ANIMATION_TYPE_SHOW; import static android.view.InsetsController.LAYOUT_INSETS_DURING_ANIMATION_HIDDEN; Loading Loading @@ -450,6 +451,14 @@ class InsetsPolicy { // Notification shade has control anyways, no reason to force anything. return focusedWin; } if (mPolicy.isForceShowNavigationBarEnabled() && focusedWin.getActivityType() == ACTIVITY_TYPE_STANDARD) { // When "force show navigation bar" is enabled, it means we are in kid navigation bar // and 3-button navigation bar mode. In this mode, the navigation bar is forcibly shown // when activity type is ACTIVITY_TYPE_STANDARD which means Launcher or Recent could // still control the navigation bar in this mode. return null; } if (remoteInsetsControllerControlsSystemBars(focusedWin)) { mDisplayContent.mRemoteInsetsControlTarget.topFocusedWindowChanged( focusedWin.mAttrs.packageName); Loading