Enable lowering IME binding priority
This CL introduces the config_killableInputMethods configuration option, which is disabled by default. When enabled, this option lowers the IME binding priority to below the perceptible level to allow the lowmemorykiller to reclaim the IME process. Test: set the config value to true in an overlay Test: manually on an Android TV device Test atest CtsInputMethodTestCases Bug: 199887357 Change-Id: Ib191d964de15bbb84daa8bbeca6f2dca6f96311c
This commit is contained in:
@@ -2781,6 +2781,9 @@
|
||||
<item>com.android.inputmethod.latin</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Make the IME killable by the lowmemorykiller by raising its oom_score_adj. -->
|
||||
<bool name="config_killableInputMethods">false</bool>
|
||||
|
||||
<!-- The list of classes that should be added to the notification ranking pipeline.
|
||||
See {@link com.android.server.notification.NotificationSignalExtractor}
|
||||
If you add a new extractor to this list make sure to update
|
||||
|
||||
@@ -2228,6 +2228,7 @@
|
||||
<java-symbol type="string" name="config_secondaryLocationTimeZoneProviderPackageName" />
|
||||
<java-symbol type="bool" name="config_autoResetAirplaneMode" />
|
||||
<java-symbol type="string" name="config_notificationAccessConfirmationActivity" />
|
||||
<java-symbol type="bool" name="config_killableInputMethods" />
|
||||
|
||||
<java-symbol type="layout" name="resolver_list" />
|
||||
<java-symbol type="id" name="resolver_list" />
|
||||
|
||||
@@ -269,6 +269,24 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
| Context.BIND_NOT_FOREGROUND
|
||||
| Context.BIND_IMPORTANT_BACKGROUND;
|
||||
|
||||
/**
|
||||
* Binding flags for establishing connection to the {@link InputMethodService} when
|
||||
* config_killableInputMethods is enabled.
|
||||
*/
|
||||
private static final int IME_CONNECTION_LOW_PRIORITY_BIND_FLAGS =
|
||||
Context.BIND_AUTO_CREATE
|
||||
| Context.BIND_REDUCTION_FLAGS;
|
||||
|
||||
/**
|
||||
* Binding flags for establishing connection to the {@link InputMethodService}.
|
||||
*
|
||||
* <p>
|
||||
* This defaults to {@link #IME_CONNECTION_BIND_FLAGS} unless config_killableInputMethods is
|
||||
* enabled, in which case this takes the value of
|
||||
* {@link #IME_CONNECTION_LOW_PRIORITY_BIND_FLAGS}.
|
||||
*/
|
||||
private final int mImeConnectionBindFlags;
|
||||
|
||||
/**
|
||||
* Binding flags used only while the {@link InputMethodService} is showing window.
|
||||
*/
|
||||
@@ -1651,6 +1669,16 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
mSwitchingController = InputMethodSubtypeSwitchingController.createInstanceLocked(
|
||||
mSettings, context);
|
||||
mMenuController = new InputMethodMenuController(this);
|
||||
|
||||
// If configured, use low priority flags to make the IME killable by the lowmemorykiller
|
||||
final boolean lowerIMEPriority = mRes.getBoolean(
|
||||
com.android.internal.R.bool.config_killableInputMethods);
|
||||
|
||||
if (lowerIMEPriority) {
|
||||
mImeConnectionBindFlags = IME_CONNECTION_LOW_PRIORITY_BIND_FLAGS;
|
||||
} else {
|
||||
mImeConnectionBindFlags = IME_CONNECTION_BIND_FLAGS;
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mMethodMap")
|
||||
@@ -2434,7 +2462,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
mContext, 0, new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS),
|
||||
PendingIntent.FLAG_IMMUTABLE));
|
||||
|
||||
if (bindCurrentInputMethodServiceLocked(mCurIntent, this, IME_CONNECTION_BIND_FLAGS)) {
|
||||
if (bindCurrentInputMethodServiceLocked(mCurIntent, this, mImeConnectionBindFlags)) {
|
||||
mLastBindTime = SystemClock.uptimeMillis();
|
||||
mHaveConnection = true;
|
||||
mCurId = info.getId();
|
||||
@@ -3155,7 +3183,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
SystemClock.uptimeMillis()-mLastBindTime,1);
|
||||
Slog.w(TAG, "Force disconnect/connect to the IME in showCurrentInputLocked()");
|
||||
mContext.unbindService(this);
|
||||
bindCurrentInputMethodServiceLocked(mCurIntent, this, IME_CONNECTION_BIND_FLAGS);
|
||||
bindCurrentInputMethodServiceLocked(mCurIntent, this, mImeConnectionBindFlags);
|
||||
} else {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Can't show input: connection = " + mHaveConnection + ", time = "
|
||||
|
||||
Reference in New Issue
Block a user