From bb35a0df61af67a874ab531ff6a849214b415fc7 Mon Sep 17 00:00:00 2001 From: Gaurav Bhola Date: Fri, 1 Apr 2022 11:23:45 -0700 Subject: [PATCH] Move the logic of deciding what all insets are controllable to InsetsPolicy. - It makes more sense to have it in InsetsPolicy because this is something that OEMs can change. Fix: b/226613098 Test: atest WindowContainerInsetsSourceProviderTest Change-Id: Ie54f9457b4063b07a37198e04c05d30f083bd5c9 --- .../com/android/server/wm/InsetsPolicy.java | 17 +++++++++++++++++ .../android/server/wm/InsetsSourceProvider.java | 17 +---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java index 398816b331cb0..1842048d78da1 100644 --- a/services/core/java/com/android/server/wm/InsetsPolicy.java +++ b/services/core/java/com/android/server/wm/InsetsPolicy.java @@ -289,6 +289,23 @@ class InsetsPolicy { return adjustVisibilityForTransientTypes(originalState); } + /** + * @param type the internal type of the insets. + * @return {@code true} if the given type is controllable, {@code false} otherwise. + */ + static boolean isInsetsTypeControllable(@InternalInsetsType int type) { + switch (type) { + case ITYPE_STATUS_BAR: + case ITYPE_NAVIGATION_BAR: + case ITYPE_IME: + case ITYPE_CLIMATE_BAR: + case ITYPE_EXTRA_NAVIGATION_BAR: + return true; + default: + return false; + } + } + private static @InternalInsetsType int getInsetsTypeForLayoutParams( WindowManager.LayoutParams attrs) { @WindowManager.LayoutParams.WindowType int type = attrs.type; diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index 047bf2f53b687..ea783c0b1ab03 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -16,11 +16,7 @@ package com.android.server.wm; -import static android.view.InsetsState.ITYPE_CLIMATE_BAR; -import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_IME; -import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; -import static android.view.InsetsState.ITYPE_STATUS_BAR; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_WINDOW_INSETS; import static com.android.server.wm.InsetsSourceProviderProto.CAPTURED_LEASH; @@ -127,18 +123,7 @@ abstract class InsetsSourceProvider { mStateController = stateController; mFakeControl = new InsetsSourceControl( source.getType(), null /* leash */, new Point(), Insets.NONE); - - switch (source.getType()) { - case ITYPE_STATUS_BAR: - case ITYPE_NAVIGATION_BAR: - case ITYPE_IME: - case ITYPE_CLIMATE_BAR: - case ITYPE_EXTRA_NAVIGATION_BAR: - mControllable = true; - break; - default: - mControllable = false; - } + mControllable = InsetsPolicy.isInsetsTypeControllable(source.getType()); } InsetsSource getSource() {