diff options
| author | Yohei Yukawa <yukawa@google.com> | 2022-03-07 11:13:58 -0800 |
|---|---|---|
| committer | Yohei Yukawa <yukawa@google.com> | 2022-03-07 11:13:58 -0800 |
| commit | f93769b1ae390d4dc38bccb01627f5f7189cd075 (patch) | |
| tree | 9792941fdea7bbb533b74172e39d84748eea85f2 /core/java/android/inputmethodservice/NavigationBarController.java | |
| parent | 5f9f1ca560d8b9e0dd8811f80f991f126ea80518 (diff) | |
Use parentUserId when reading config_imeDrawsImeNavBar
This CL rewrites my previous CLs [1][2], which were written with an
incorrect assumption that config_imeDrawsImeNavBar was overlaid for
the entire profile group.
While SysUI's navigation mode is dynamically configurable with Runtime
Resource Overlay (RRO), it turns out that we currently configure RRO
only for the profile parent user. This means that processes run under
other profile users continue seeing the base resource value regardless
of how RRO is configured for the profile parent user. This is the
root cause of Bug 219604375.
To work around this limitation, this CL uses InputMethodManagerService
to monitor the value of config_imeDrawsImeNavBar for the profile
parent user then to propagate it to the IME process. Luckily we have
already been doing a similar thing for the IME switcher visibility.
What this CL does is 1) adding a new flag to InputMethodNavButtonFlags
then 2) just using the flag sent from IMMS instead of directly reading
config_imeDrawsImeNavBar
NavigationBarController.
Alternative solutions considered:
* Set RRO for profile users
One of straightforward ways to address this problem is letting the
Setting app apply the same RRO for other profile users. However,
this could be tricky when 1) the user changes navigation mode then
2) sets up a new profile, because the Settings app is not an
always-running process. While we might be able to rely on
com.android.settings.SettingsInitialize#onReceive()
to do so, the profile user's state could be left in a broken state
if that method was somehow interrupted. To minimize the risk, we
decided to not take this approach for T.
* Make OverlayManager be aware of profile groups
Given how RRO is used in SysUI, it's make more sense if
OverlayManager natively supports resource overlay for the entire
profile group. However, introducing such a new concept is too late
for Android T. We have filed Bug 221443458 to see if we can do this
in a future version of Android.
[1]: I3e7e1f83554444131e2765dc159617bb9e2337c7
ff7b453ca8e23b4ef75ba2c3f5becaf511cb07d3
[2]: Id0cfa44cce5de515dc5d28254e1d41bdfc01e201
177e4aafdb33ec0e4b9172a16a07a34dc6420e36
Fix: 219820813
Test: Manually verified as follows
1. Build aosp_coral-userdebug then flash it.
2. adb root
3. adb shell setprop persist.sys.ime.can_render_gestural_nav_buttons true
4. adb reboot
5. adb install -r TestDPC-normalv8001.apk
6. adb shell am start -n com.afwsamples.testdpc/.SetupManagementLaunchActivity
7. Set up work-profile
8. make -j EditTextVariations
9. adb install -r \
$ANDROID_TARGET_OUT_TESTCASES/EditTextVariations/arm64/EditTextVariations.apk
10. adb shell am start --user 0 -n \
com.android.inputmethod.tools.edittextvariations/.EditTextVariations
11. adb shell dumpsys input_method | grep mNavigation
-> "mNavigationBarController={mImeDrawsImeNavBar=false, ..."
12. Enable gesture navigation
13. adb shell dumpsys input_method | grep mNavigation
-> "mNavigationBarController={mImeDrawsImeNavBar=true, ..."
14. adb shell am start --user 10 -n \
com.android.inputmethod.tools.edittextvariations/.EditTextVariations
15. adb shell dumpsys input_method | grep mNavigation
-> "mNavigationBarController={mImeDrawsImeNavBar=true, ..."
Change-Id: Id3d6a71d8ba1bfa49131350b68aa8d3424eca381
Diffstat (limited to 'core/java/android/inputmethodservice/NavigationBarController.java')
| -rw-r--r-- | core/java/android/inputmethodservice/NavigationBarController.java | 83 |
1 files changed, 26 insertions, 57 deletions
diff --git a/core/java/android/inputmethodservice/NavigationBarController.java b/core/java/android/inputmethodservice/NavigationBarController.java index a247db2f3310..0f9075b498ae 100644 --- a/core/java/android/inputmethodservice/NavigationBarController.java +++ b/core/java/android/inputmethodservice/NavigationBarController.java @@ -16,7 +16,6 @@ package android.inputmethodservice; -import static android.content.Intent.ACTION_OVERLAY_CHANGED; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; import android.animation.ValueAnimator; @@ -24,18 +23,12 @@ import android.annotation.FloatRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.StatusBarManager; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.res.Resources; import android.graphics.Color; import android.graphics.Insets; import android.graphics.Rect; import android.graphics.Region; import android.inputmethodservice.navigationbar.NavigationBarFrame; import android.inputmethodservice.navigationbar.NavigationBarView; -import android.os.PatternMatcher; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -145,9 +138,6 @@ final class NavigationBarController { @Nullable Insets mLastInsets; - @Nullable - private BroadcastReceiver mSystemOverlayChangedReceiver; - private boolean mShouldShowImeSwitcherWhenImeIsShown; @Appearance @@ -360,14 +350,6 @@ final class NavigationBarController { }); } - private boolean imeDrawsImeNavBar() { - final Resources resources = mService.getResources(); - if (resources == null) { - return false; - } - return resources.getBoolean(com.android.internal.R.bool.config_imeDrawsImeNavBar); - } - @Override public void onSoftInputWindowCreated(@NonNull SoftInputWindow softInputWindow) { final Window window = softInputWindow.getWindow(); @@ -380,27 +362,6 @@ final class NavigationBarController { if (mDestroyed) { return; } - mImeDrawsImeNavBar = imeDrawsImeNavBar(); - if (mSystemOverlayChangedReceiver == null) { - final IntentFilter intentFilter = new IntentFilter(ACTION_OVERLAY_CHANGED); - intentFilter.addDataScheme(IntentFilter.SCHEME_PACKAGE); - intentFilter.addDataSchemeSpecificPart("android", PatternMatcher.PATTERN_LITERAL); - mSystemOverlayChangedReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (mDestroyed) { - return; - } - mImeDrawsImeNavBar = imeDrawsImeNavBar(); - if (mImeDrawsImeNavBar) { - installNavigationBarFrameIfNecessary(); - } else { - uninstallNavigationBarFrameIfNecessary(); - } - } - }; - mService.registerReceiver(mSystemOverlayChangedReceiver, intentFilter); - } installNavigationBarFrameIfNecessary(); } @@ -413,10 +374,6 @@ final class NavigationBarController { mTintAnimator.cancel(); mTintAnimator = null; } - if (mSystemOverlayChangedReceiver != null) { - mService.unregisterReceiver(mSystemOverlayChangedReceiver); - mSystemOverlayChangedReceiver = null; - } mDestroyed = true; } @@ -454,26 +411,38 @@ final class NavigationBarController { return; } + final boolean imeDrawsImeNavBar = + (navButtonFlags & InputMethodNavButtonFlags.IME_DRAWS_IME_NAV_BAR) != 0; final boolean shouldShowImeSwitcherWhenImeIsShown = (navButtonFlags & InputMethodNavButtonFlags.SHOW_IME_SWITCHER_WHEN_IME_IS_SHOWN) != 0; - if (mShouldShowImeSwitcherWhenImeIsShown == shouldShowImeSwitcherWhenImeIsShown) { - return; - } + + mImeDrawsImeNavBar = imeDrawsImeNavBar; + final boolean prevShouldShowImeSwitcherWhenImeIsShown = + mShouldShowImeSwitcherWhenImeIsShown; mShouldShowImeSwitcherWhenImeIsShown = shouldShowImeSwitcherWhenImeIsShown; - if (mNavigationBarFrame == null) { - return; - } - final NavigationBarView navigationBarView = - mNavigationBarFrame.findViewByPredicate(NavigationBarView.class::isInstance); - if (navigationBarView == null) { - return; + if (imeDrawsImeNavBar) { + installNavigationBarFrameIfNecessary(); + if (mNavigationBarFrame == null) { + return; + } + if (mShouldShowImeSwitcherWhenImeIsShown + == prevShouldShowImeSwitcherWhenImeIsShown) { + return; + } + final NavigationBarView navigationBarView = mNavigationBarFrame.findViewByPredicate( + NavigationBarView.class::isInstance); + if (navigationBarView == null) { + return; + } + final int hints = StatusBarManager.NAVIGATION_HINT_BACK_ALT + | (shouldShowImeSwitcherWhenImeIsShown + ? StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_SHOWN : 0); + navigationBarView.setNavigationIconHints(hints); + } else { + uninstallNavigationBarFrameIfNecessary(); } - final int hints = StatusBarManager.NAVIGATION_HINT_BACK_ALT - | (shouldShowImeSwitcherWhenImeIsShown - ? StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_SHOWN : 0); - navigationBarView.setNavigationIconHints(hints); } @Override |
