Move and split removing window token

Bug: 205676419
Test: make
Change-Id: Ic3aa02925fe460d4530e9f0cede3aa3a98a109ec
This commit is contained in:
Nikolas Havrikov
2021-11-15 13:46:27 +01:00
parent 614cd72824
commit 5ae6910b7d
2 changed files with 25 additions and 19 deletions

View File

@@ -50,6 +50,7 @@ import com.android.internal.inputmethod.InputBindResult;
import com.android.internal.inputmethod.UnbindReason;
import com.android.internal.view.IInputMethod;
import com.android.server.inputmethod.InputMethodManagerService.ClientState;
import com.android.server.wm.WindowManagerInternal;
/**
* A controller managing the state of the input method binding.
@@ -64,6 +65,7 @@ final class InputMethodBindingController {
@NonNull private final InputMethodUtils.InputMethodSettings mSettings;
@NonNull private final PackageManagerInternal mPackageManagerInternal;
@NonNull private final IWindowManager mIWindowManager;
@NonNull private final WindowManagerInternal mWindowManagerInternal;
@NonNull private final Resources mRes;
private long mLastBindTime;
@@ -120,6 +122,7 @@ final class InputMethodBindingController {
mSettings = mService.mSettings;
mPackageManagerInternal = mService.mPackageManagerInternal;
mIWindowManager = mService.mIWindowManager;
mWindowManagerInternal = mService.mWindowManagerInternal;
mRes = mService.mRes;
// If configured, use low priority flags to make the IME killable by the lowmemorykiller
@@ -193,10 +196,6 @@ final class InputMethodBindingController {
return mCurToken;
}
void setCurToken(IBinder curToken) {
mCurToken = curToken;
}
/**
* The Intent used to connect to the current input method.
*/
@@ -368,13 +367,27 @@ final class InputMethodBindingController {
}
if (mCurToken != null) {
mService.removeCurrentTokenLocked();
removeCurrentTokenLocked();
mService.resetSystemUiLocked();
}
mCurId = null;
mService.clearCurMethodLocked();
}
@GuardedBy("mMethodMap")
private void removeCurrentTokenLocked() {
int curTokenDisplayId = mService.getCurTokenDisplayId();
if (DEBUG) {
Slog.v(TAG,
"Removing window token: " + mCurToken + " for display: " + curTokenDisplayId);
}
mWindowManagerInternal.removeWindowToken(mCurToken, false /* removeWindows */,
false /* animateExit */, curTokenDisplayId);
mCurToken = null;
}
@GuardedBy("mMethodMap")
@NonNull
InputBindResult bindCurrentMethodLocked(int displayIdToShowIme) {

View File

@@ -593,17 +593,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return mBindingController.getCurToken();
}
private void setCurToken(IBinder curToken) {
mBindingController.setCurToken(curToken);
/**
* The displayId of current active input method.
*/
int getCurTokenDisplayId() {
return mCurTokenDisplayId;
}
void setCurTokenDisplayId(int curTokenDisplayId) {
mCurTokenDisplayId = curTokenDisplayId;
}
/**
* The displayId of current active input method.
*/
int mCurTokenDisplayId = INVALID_DISPLAY;
/**
@@ -2536,18 +2536,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
@GuardedBy("mMethodMap")
void removeCurrentTokenLocked() {
IBinder token = getCurToken();
if (DEBUG) {
Slog.v(TAG, "Removing window token: " + token + " for display: " + mCurTokenDisplayId);
}
mWindowManagerInternal.removeWindowToken(token, false /* removeWindows */,
false /* animateExit */, mCurTokenDisplayId);
// Set IME window status as invisible when unbind current method.
void resetSystemUiLocked() {
// Set IME window status as invisible when unbinding current method.
mImeWindowVis = 0;
mBackDisposition = InputMethodService.BACK_DISPOSITION_DEFAULT;
updateSystemUiLocked(mImeWindowVis, mBackDisposition);
setCurToken(null);
mCurTokenDisplayId = INVALID_DISPLAY;
mCurHostInputToken = null;
}