Move adding fresh window token to controller
This is a step in a larger refactoring. Bug: 205676419 Test: make Change-Id: I3f5a4c59f8de0b2285defe2c7f0d60f755b0df95
This commit is contained in:
@@ -30,14 +30,18 @@ import android.content.ServiceConnection;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
import android.content.res.Resources;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Slog;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethod;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
|
||||
@@ -59,6 +63,7 @@ final class InputMethodBindingController {
|
||||
@NonNull private final ArrayMap<String, InputMethodInfo> mMethodMap;
|
||||
@NonNull private final InputMethodUtils.InputMethodSettings mSettings;
|
||||
@NonNull private final PackageManagerInternal mPackageManagerInternal;
|
||||
@NonNull private final IWindowManager mIWindowManager;
|
||||
@NonNull private final Resources mRes;
|
||||
|
||||
private long mLastBindTime;
|
||||
@@ -114,6 +119,7 @@ final class InputMethodBindingController {
|
||||
mMethodMap = mService.mMethodMap;
|
||||
mSettings = mService.mSettings;
|
||||
mPackageManagerInternal = mService.mPackageManagerInternal;
|
||||
mIWindowManager = mService.mIWindowManager;
|
||||
mRes = mService.mRes;
|
||||
|
||||
// If configured, use low priority flags to make the IME killable by the lowmemorykiller
|
||||
@@ -136,10 +142,6 @@ final class InputMethodBindingController {
|
||||
return mLastBindTime;
|
||||
}
|
||||
|
||||
void setLastBindTime(long lastBindTime) {
|
||||
mLastBindTime = lastBindTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true if our ServiceConnection is currently actively bound to
|
||||
* a service (whether or not we have gotten its IBinder back yet).
|
||||
@@ -161,10 +163,6 @@ final class InputMethodBindingController {
|
||||
return mCurId;
|
||||
}
|
||||
|
||||
void setCurId(@Nullable String curId) {
|
||||
mCurId = curId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Id obtained with {@link InputMethodInfo#getId()} for the currently selected input method.
|
||||
* This is to be synchronized with the secure settings keyed with
|
||||
@@ -388,7 +386,7 @@ final class InputMethodBindingController {
|
||||
mCurIntent = createImeBindingIntent(info.getComponent());
|
||||
|
||||
if (bindCurrentInputMethodServiceMainConnectionLocked()) {
|
||||
mService.addFreshWindowTokenLocked(displayIdToShowIme, info.getId());
|
||||
addFreshWindowTokenLocked(displayIdToShowIme, info.getId());
|
||||
return new InputBindResult(
|
||||
InputBindResult.ResultCode.SUCCESS_WAITING_IME_BINDING,
|
||||
null, null, mCurId, mCurSeq, false);
|
||||
@@ -412,6 +410,28 @@ final class InputMethodBindingController {
|
||||
return intent;
|
||||
}
|
||||
|
||||
@GuardedBy("mMethodMap")
|
||||
private void addFreshWindowTokenLocked(int displayIdToShowIme, String methodId) {
|
||||
Binder token = new Binder();
|
||||
mCurToken = token;
|
||||
mLastBindTime = SystemClock.uptimeMillis();
|
||||
mCurId = methodId;
|
||||
|
||||
mService.setCurTokenDisplayId(displayIdToShowIme);
|
||||
|
||||
try {
|
||||
if (DEBUG) {
|
||||
Slog.v(TAG, "Adding window token: " + token + " for display: "
|
||||
+ displayIdToShowIme);
|
||||
}
|
||||
mIWindowManager.addWindowToken(token, WindowManager.LayoutParams.TYPE_INPUT_METHOD,
|
||||
displayIdToShowIme, null /* options */);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Could not add window token " + token + " for display "
|
||||
+ displayIdToShowIme, e);
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mMethodMap")
|
||||
void unbindMainConnectionLocked() {
|
||||
mContext.unbindService(mMainConnection);
|
||||
|
||||
@@ -518,10 +518,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
return mBindingController.getCurId();
|
||||
}
|
||||
|
||||
private void setCurId(@Nullable String curId) {
|
||||
mBindingController.setCurId(curId);
|
||||
}
|
||||
|
||||
/**
|
||||
* The current subtype of the current input method.
|
||||
*/
|
||||
@@ -601,6 +597,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
mBindingController.setCurToken(curToken);
|
||||
}
|
||||
|
||||
void setCurTokenDisplayId(int curTokenDisplayId) {
|
||||
mCurTokenDisplayId = curTokenDisplayId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The displayId of current active input method.
|
||||
*/
|
||||
@@ -653,10 +653,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
return mBindingController.getLastBindTime();
|
||||
}
|
||||
|
||||
private void setLastBindTime(long lastBindTime) {
|
||||
mBindingController.setLastBindTime(lastBindTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Have we called mCurMethod.bindInput()?
|
||||
*/
|
||||
@@ -2472,26 +2468,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@GuardedBy("mMethodMap")
|
||||
void addFreshWindowTokenLocked(int displayIdToShowIme, String methodId) {
|
||||
Binder token = new Binder();
|
||||
setCurToken(token);
|
||||
setLastBindTime(SystemClock.uptimeMillis());
|
||||
setCurId(methodId);
|
||||
mCurTokenDisplayId = displayIdToShowIme;
|
||||
try {
|
||||
if (DEBUG) {
|
||||
Slog.v(TAG, "Adding window token: " + token + " for display: "
|
||||
+ displayIdToShowIme);
|
||||
}
|
||||
mIWindowManager.addWindowToken(token, LayoutParams.TYPE_INPUT_METHOD,
|
||||
displayIdToShowIme, null /* options */);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Could not add window token " + token + " for display "
|
||||
+ displayIdToShowIme, e);
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface ImeDisplayValidator {
|
||||
@DisplayImePolicy int getDisplayImePolicy(int displayId);
|
||||
|
||||
Reference in New Issue
Block a user