Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a4e080f authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Make IMMS#shouldPreventImeStartupLocked() more readable

This is a mechanical refactoring with no behavior change for

  InputMethodManagerService#shouldPreventImeStartupLocked(),

which was added recently [1].

Most likely return-early pattern would be more readable and
maintainable for this kind of method.

There must be no observable behavior change in this CL.

 [1]: Id0aaa496ee46532d0e97c236df7e073947ababcd
      76a3c8c9

Bug: 234882948
Test: presubmit
Change-Id: Ic2d5164697523ec410b635b451fff1e4feb40830
parent b1793891
Loading
Loading
Loading
Loading
+12 −15
Original line number Diff line number Diff line
@@ -2603,24 +2603,21 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
        if (!mPreventImeStartupUnlessTextEditor) {
            return false;
        }

        final boolean imeVisibleAllowed =
                isSoftInputModeStateVisibleAllowed(unverifiedTargetSdkVersion, startInputFlags);

        return !(imeVisibleAllowed
                || mShowRequested
                || isNonPreemptibleImeLocked(selectedMethodId));
        if (mShowRequested) {
            return false;
        }
        if (isSoftInputModeStateVisibleAllowed(unverifiedTargetSdkVersion, startInputFlags)) {
            return false;
        }

    /** Return {@code true} if the given IME is non-preemptible like the tv remote service. */
    @GuardedBy("ImfLock.class")
    private boolean isNonPreemptibleImeLocked(@NonNull  String selectedMethodId) {
        final InputMethodInfo imi = mMethodMap.get(selectedMethodId);
        if (imi != null) {
            return ArrayUtils.contains(mNonPreemptibleInputMethods, imi.getPackageName());
        if (imi == null) {
            return false;
        }
        if (ArrayUtils.contains(mNonPreemptibleInputMethods, imi.getPackageName())) {
            return false;
        }
        return true;
    }

    @GuardedBy("ImfLock.class")
    private boolean isSelectedMethodBoundLocked() {