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

Commit 111b03de authored by Michael Wachenschwanz's avatar Michael Wachenschwanz
Browse files

Lower IME background importance

The keyboard app is currently bound with the BIND_NOT_VISIBLE flag
by system. This keeps it in the oom score 200 slot, which competes
with higher priority processes like foreground services. Binding
with BIND_ALMOT_PERCEPTIBLE will lower its background importance to
201, keeping it warm in memory for snappier UX but allows it to
die in favor of process doing more important work.

Flag: android.view.inputmethod.lower_ime_oom_importance
Fixes: 372511805
Test: manual (`adb shell dumpsys activity lru`, background ime
process should have `prcp+1` oom score.)
Change-Id: Ie94ec1bcac212da3fad06186a73502bf01b68def

Change-Id: I41398340eea4d4694f69ccd9abc9e344eee444ef
parent 41f071c4
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -203,3 +203,14 @@ flag {
  description: "Adding animating insets types and report IME visibility at the beginning of hiding"
  bug: "393049691"
}

flag {
    name: "lower_ime_oom_importance"
    namespace: "input_method"
    description: "Lower keyboard app process oom importance to PERCEPTIBLE_APP_ADJ + 1."
    bug: "372511805"
    is_fixed_read_only: true
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+11 −2
Original line number Diff line number Diff line
@@ -120,12 +120,21 @@ final class InputMethodBindingController {
     * Binding flags for establishing connection to the {@link InputMethodService}.
     */
    @VisibleForTesting
    static final int IME_CONNECTION_BIND_FLAGS =
            Context.BIND_AUTO_CREATE
    static final int IME_CONNECTION_BIND_FLAGS;
    static {
        if (android.view.inputmethod.Flags.lowerImeOomImportance()) {
            IME_CONNECTION_BIND_FLAGS = Context.BIND_AUTO_CREATE
                    | Context.BIND_ALMOST_PERCEPTIBLE
                    | Context.BIND_IMPORTANT_BACKGROUND
                    | Context.BIND_SCHEDULE_LIKE_TOP_APP;
        } else {
            IME_CONNECTION_BIND_FLAGS = Context.BIND_AUTO_CREATE
                    | Context.BIND_NOT_VISIBLE
                    | Context.BIND_NOT_FOREGROUND
                    | Context.BIND_IMPORTANT_BACKGROUND
                    | Context.BIND_SCHEDULE_LIKE_TOP_APP;
        }
    }

    private final int mImeConnectionBindFlags;