Remove IMM#reportVirtualDisplayGeometry() again
This CL effectively reverts our previous CL [1], which re-introduced
InputMethodManager#reportVirtualDisplayGeometry()
for certain form-factors.
Now that we no longer need this @hide API, let's remove this for
simplicity.
[1]: I35b491da5a340844e17542d7a6198f8152bbeda3
708c957fa3
Bug: 224424149
Bug: 256926300
Test: presubmit
Test: atest FrameworksInputMethodSystemServerTests:InputMethodManagerServiceWindowGainedFocusTest
Change-Id: Ic956c84e39ab24ef6cf946a32f1acb954d6eec38
This commit is contained in:
@@ -452,20 +452,6 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
}
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
static void reportVirtualDisplayGeometryAsync(@NonNull IInputMethodClient client,
|
||||
int childDisplayId, @Nullable float[] matrixValues) {
|
||||
final IInputMethodManager service = getService();
|
||||
if (service == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
service.reportVirtualDisplayGeometryAsync(client, childDisplayId, matrixValues);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
static void reportPerceptibleAsync(@NonNull IBinder windowToken, boolean perceptible) {
|
||||
final IInputMethodManager service = getService();
|
||||
|
||||
@@ -60,7 +60,6 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
@@ -572,18 +571,6 @@ public final class InputMethodManager {
|
||||
@GuardedBy("mH")
|
||||
private CursorAnchorInfo mCursorAnchorInfo = null;
|
||||
|
||||
/**
|
||||
* A special {@link Matrix} that can be provided by the system when this instance is running
|
||||
* inside a virtual display.
|
||||
*
|
||||
* <p>If this is non-{@code null}, {@link #updateCursorAnchorInfo(View, CursorAnchorInfo)}
|
||||
* should be adjusted with this {@link Matrix}.</p>
|
||||
*
|
||||
* <p>{@code null} when not used.</p>
|
||||
*/
|
||||
@GuardedBy("mH")
|
||||
private Matrix mVirtualDisplayToScreenMatrix = null;
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -670,7 +657,6 @@ public final class InputMethodManager {
|
||||
private static final int MSG_BIND_ACCESSIBILITY_SERVICE = 11;
|
||||
private static final int MSG_UNBIND_ACCESSIBILITY_SERVICE = 12;
|
||||
private static final int MSG_SET_INTERACTIVE = 13;
|
||||
private static final int MSG_UPDATE_VIRTUAL_DISPLAY_TO_SCREEN_MATRIX = 30;
|
||||
private static final int MSG_ON_SHOW_REQUESTED = 31;
|
||||
|
||||
/**
|
||||
@@ -1037,7 +1023,6 @@ public final class InputMethodManager {
|
||||
mCurMethod = res.method; // for @UnsupportedAppUsage
|
||||
mCurBindState = new BindState(res);
|
||||
mCurId = res.id; // for @UnsupportedAppUsage
|
||||
mVirtualDisplayToScreenMatrix = res.getVirtualDisplayToScreenMatrix();
|
||||
}
|
||||
startInputInner(StartInputReason.BOUND_TO_IMMS, null, 0, 0, 0);
|
||||
return;
|
||||
@@ -1245,43 +1230,6 @@ public final class InputMethodManager {
|
||||
}
|
||||
return;
|
||||
}
|
||||
case MSG_UPDATE_VIRTUAL_DISPLAY_TO_SCREEN_MATRIX: {
|
||||
final float[] matrixValues = (float[]) msg.obj;
|
||||
final int bindSequence = msg.arg1;
|
||||
synchronized (mH) {
|
||||
if (getBindSequenceLocked() != bindSequence) {
|
||||
return;
|
||||
}
|
||||
if (matrixValues == null || mVirtualDisplayToScreenMatrix == null) {
|
||||
// Either InputBoundResult#mVirtualDisplayToScreenMatrixValues is null
|
||||
// OR this app is unbound from the parent VirtualDisplay. In this case,
|
||||
// calling updateCursorAnchorInfo() isn't safe. Only clear the matrix.
|
||||
mVirtualDisplayToScreenMatrix = null;
|
||||
return;
|
||||
}
|
||||
|
||||
final float[] currentValues = new float[9];
|
||||
mVirtualDisplayToScreenMatrix.getValues(currentValues);
|
||||
if (Arrays.equals(currentValues, matrixValues)) {
|
||||
return;
|
||||
}
|
||||
mVirtualDisplayToScreenMatrix.setValues(matrixValues);
|
||||
|
||||
if (mCursorAnchorInfo == null || !isImeSessionAvailableLocked()
|
||||
|| mServedInputConnection == null) {
|
||||
return;
|
||||
}
|
||||
if (!mServedInputConnection.isCursorAnchorInfoMonitoring()) {
|
||||
return;
|
||||
}
|
||||
// Since the host VirtualDisplay is moved, we need to issue
|
||||
// IMS#updateCursorAnchorInfo() again.
|
||||
mCurBindState.mImeSession.updateCursorAnchorInfo(
|
||||
CursorAnchorInfo.createForAdditionalParentMatrix(
|
||||
mCursorAnchorInfo, mVirtualDisplayToScreenMatrix));
|
||||
}
|
||||
return;
|
||||
}
|
||||
case MSG_ON_SHOW_REQUESTED: {
|
||||
synchronized (mH) {
|
||||
if (mImeInsetsConsumer != null) {
|
||||
@@ -1359,12 +1307,6 @@ public final class InputMethodManager {
|
||||
.sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateVirtualDisplayToScreenMatrix(int bindSequence, float[] matrixValues) {
|
||||
mH.obtainMessage(MSG_UPDATE_VIRTUAL_DISPLAY_TO_SCREEN_MATRIX, bindSequence, 0,
|
||||
matrixValues).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImeTraceEnabled(boolean enabled) {
|
||||
ImeTracing.getInstance().setEnabled(enabled);
|
||||
@@ -1958,7 +1900,6 @@ public final class InputMethodManager {
|
||||
@UnsupportedAppUsage
|
||||
@GuardedBy("mH")
|
||||
void finishInputLocked() {
|
||||
mVirtualDisplayToScreenMatrix = null;
|
||||
View clearedView = null;
|
||||
mNextServedView = null;
|
||||
if (mServedView != null) {
|
||||
@@ -2839,7 +2780,6 @@ public final class InputMethodManager {
|
||||
+ InputMethodDebug.startInputFlagsToString(startInputFlags));
|
||||
return false;
|
||||
}
|
||||
mVirtualDisplayToScreenMatrix = res.getVirtualDisplayToScreenMatrix();
|
||||
if (res.id != null) {
|
||||
updateInputChannelLocked(res.channel);
|
||||
mCurMethod = res.method; // for @UnsupportedAppUsage
|
||||
@@ -3400,13 +3340,7 @@ public final class InputMethodManager {
|
||||
return;
|
||||
}
|
||||
if (DEBUG) Log.v(TAG, "updateCursorAnchorInfo: " + cursorAnchorInfo);
|
||||
if (mVirtualDisplayToScreenMatrix != null) {
|
||||
mCurBindState.mImeSession.updateCursorAnchorInfo(
|
||||
CursorAnchorInfo.createForAdditionalParentMatrix(
|
||||
cursorAnchorInfo, mVirtualDisplayToScreenMatrix));
|
||||
} else {
|
||||
mCurBindState.mImeSession.updateCursorAnchorInfo(cursorAnchorInfo);
|
||||
}
|
||||
mCurBindState.mImeSession.updateCursorAnchorInfo(cursorAnchorInfo);
|
||||
mCursorAnchorInfo = cursorAnchorInfo;
|
||||
}
|
||||
}
|
||||
@@ -4019,40 +3953,6 @@ public final class InputMethodManager {
|
||||
mRequestCursorUpdateDisplayIdCheck.set(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* An internal API for {@link android.hardware.display.VirtualDisplay} to report where its
|
||||
* embedded virtual display is placed.
|
||||
*
|
||||
* @param childDisplayId Display ID of the embedded virtual display.
|
||||
* @param matrix {@link Matrix} to convert virtual display screen coordinates to
|
||||
* the host screen coordinates. {@code null} to clear the relationship.
|
||||
* @hide
|
||||
*/
|
||||
public void reportVirtualDisplayGeometry(int childDisplayId, @Nullable Matrix matrix) {
|
||||
final float[] matrixValues;
|
||||
if (matrix == null) {
|
||||
matrixValues = null;
|
||||
} else {
|
||||
matrixValues = new float[9];
|
||||
matrix.getValues(matrixValues);
|
||||
}
|
||||
IInputMethodManagerGlobalInvoker.reportVirtualDisplayGeometryAsync(mClient, childDisplayId,
|
||||
matrixValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* An internal API that returns if the current display has a transformation matrix to apply.
|
||||
*
|
||||
* @return {@code true} if {@link Matrix} to convert virtual display screen coordinates to
|
||||
* the host screen coordinates is set.
|
||||
* @hide
|
||||
*/
|
||||
public boolean hasVirtualDisplayToScreenMatrix() {
|
||||
synchronized (mH) {
|
||||
return mVirtualDisplayToScreenMatrix != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force switch to the last used input method and subtype. If the last input method didn't have
|
||||
* any subtypes, the framework will simply switch to the last input method with no subtype
|
||||
|
||||
@@ -1107,8 +1107,7 @@ final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub {
|
||||
return false;
|
||||
}
|
||||
if (mParentInputMethodManager.mRequestCursorUpdateDisplayIdCheck.get()
|
||||
&& mParentInputMethodManager.getDisplayId() != imeDisplayId
|
||||
&& !mParentInputMethodManager.hasVirtualDisplayToScreenMatrix()) {
|
||||
&& mParentInputMethodManager.getDisplayId() != imeDisplayId) {
|
||||
// requestCursorUpdates() is not currently supported across displays.
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ oneway interface IInputMethodClient {
|
||||
void setInteractive(boolean active, boolean fullscreen);
|
||||
void scheduleStartInputIfNecessary(boolean fullscreen);
|
||||
void reportFullscreenMode(boolean fullscreen);
|
||||
void updateVirtualDisplayToScreenMatrix(int bindSequence, in float[] matrixValues);
|
||||
void setImeTraceEnabled(boolean enabled);
|
||||
void throwExceptionFromSystem(String message);
|
||||
}
|
||||
|
||||
@@ -19,11 +19,9 @@ package com.android.internal.inputmethod;
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.graphics.Matrix;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -205,28 +203,11 @@ public final class InputBindResult implements Parcelable {
|
||||
*/
|
||||
public final int sequence;
|
||||
|
||||
@Nullable
|
||||
private final float[] mVirtualDisplayToScreenMatrixValues;
|
||||
|
||||
/**
|
||||
* {@code true} if the IME explicitly specifies {@code suppressesSpellChecker="true"}.
|
||||
*/
|
||||
public final boolean isInputMethodSuppressingSpellChecker;
|
||||
|
||||
/**
|
||||
* @return {@link Matrix} that corresponds to {@link #mVirtualDisplayToScreenMatrixValues}.
|
||||
* {@code null} if {@link #mVirtualDisplayToScreenMatrixValues} is {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
public Matrix getVirtualDisplayToScreenMatrix() {
|
||||
if (mVirtualDisplayToScreenMatrixValues == null) {
|
||||
return null;
|
||||
}
|
||||
final Matrix matrix = new Matrix();
|
||||
matrix.setValues(mVirtualDisplayToScreenMatrixValues);
|
||||
return matrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@link InputBindResult}.
|
||||
*
|
||||
@@ -246,7 +227,6 @@ public final class InputBindResult implements Parcelable {
|
||||
IInputMethodSession method,
|
||||
SparseArray<IAccessibilityInputMethodSession> accessibilitySessions,
|
||||
InputChannel channel, String id, int sequence,
|
||||
@Nullable Matrix virtualDisplayToScreenMatrix,
|
||||
boolean isInputMethodSuppressingSpellChecker) {
|
||||
this.result = result;
|
||||
this.method = method;
|
||||
@@ -254,12 +234,6 @@ public final class InputBindResult implements Parcelable {
|
||||
this.channel = channel;
|
||||
this.id = id;
|
||||
this.sequence = sequence;
|
||||
if (virtualDisplayToScreenMatrix == null) {
|
||||
mVirtualDisplayToScreenMatrixValues = null;
|
||||
} else {
|
||||
mVirtualDisplayToScreenMatrixValues = new float[9];
|
||||
virtualDisplayToScreenMatrix.getValues(mVirtualDisplayToScreenMatrixValues);
|
||||
}
|
||||
this.isInputMethodSuppressingSpellChecker = isInputMethodSuppressingSpellChecker;
|
||||
}
|
||||
|
||||
@@ -287,7 +261,6 @@ public final class InputBindResult implements Parcelable {
|
||||
}
|
||||
id = source.readString();
|
||||
sequence = source.readInt();
|
||||
mVirtualDisplayToScreenMatrixValues = source.createFloatArray();
|
||||
isInputMethodSuppressingSpellChecker = source.readBoolean();
|
||||
}
|
||||
|
||||
@@ -298,7 +271,6 @@ public final class InputBindResult implements Parcelable {
|
||||
public String toString() {
|
||||
return "InputBindResult{result=" + getResultString() + " method=" + method + " id=" + id
|
||||
+ " sequence=" + sequence
|
||||
+ " virtualDisplayToScreenMatrix=" + getVirtualDisplayToScreenMatrix()
|
||||
+ " isInputMethodSuppressingSpellChecker=" + isInputMethodSuppressingSpellChecker
|
||||
+ "}";
|
||||
}
|
||||
@@ -330,7 +302,6 @@ public final class InputBindResult implements Parcelable {
|
||||
}
|
||||
dest.writeString(id);
|
||||
dest.writeInt(sequence);
|
||||
dest.writeFloatArray(mVirtualDisplayToScreenMatrixValues);
|
||||
dest.writeBoolean(isInputMethodSuppressingSpellChecker);
|
||||
}
|
||||
|
||||
@@ -400,7 +371,7 @@ public final class InputBindResult implements Parcelable {
|
||||
}
|
||||
|
||||
private static InputBindResult error(@ResultCode int result) {
|
||||
return new InputBindResult(result, null, null, null, null, -1, null, false);
|
||||
return new InputBindResult(result, null, null, null, null, -1, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -114,9 +114,6 @@ interface IInputMethodManager {
|
||||
// TODO(Bug 113914148): Consider removing this.
|
||||
int getInputMethodWindowVisibleHeight(in IInputMethodClient client);
|
||||
|
||||
oneway void reportVirtualDisplayGeometryAsync(in IInputMethodClient parentClient,
|
||||
int childDisplayId, in @nullable float[] matrixValues);
|
||||
|
||||
oneway void reportPerceptibleAsync(in IBinder windowToken, boolean perceptible);
|
||||
|
||||
@EnforcePermission("INTERNAL_SYSTEM_WINDOW")
|
||||
|
||||
@@ -248,26 +248,6 @@ final class IInputMethodClientInvoker {
|
||||
}
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
void updateVirtualDisplayToScreenMatrix(int bindSequence, float[] matrixValues) {
|
||||
if (mIsProxy) {
|
||||
updateVirtualDisplayToScreenMatrixInternal(bindSequence, matrixValues);
|
||||
} else {
|
||||
mHandler.post(() ->
|
||||
updateVirtualDisplayToScreenMatrixInternal(bindSequence, matrixValues));
|
||||
}
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
private void updateVirtualDisplayToScreenMatrixInternal(int bindSequence,
|
||||
float[] matrixValues) {
|
||||
try {
|
||||
mTarget.updateVirtualDisplayToScreenMatrix(bindSequence, matrixValues);
|
||||
} catch (RemoteException e) {
|
||||
logRemoteException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
void setImeTraceEnabled(boolean enabled) {
|
||||
if (mIsProxy) {
|
||||
|
||||
@@ -418,7 +418,7 @@ final class InputMethodBindingController {
|
||||
addFreshWindowToken();
|
||||
return new InputBindResult(
|
||||
InputBindResult.ResultCode.SUCCESS_WAITING_IME_BINDING,
|
||||
null, null, null, mCurId, mCurSeq, null, false);
|
||||
null, null, null, mCurId, mCurSeq, false);
|
||||
}
|
||||
|
||||
Slog.w(InputMethodManagerService.TAG,
|
||||
|
||||
@@ -81,8 +81,6 @@ import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.database.ContentObserver;
|
||||
import android.graphics.Matrix;
|
||||
import android.hardware.display.DisplayManagerInternal;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.media.AudioManagerInternal;
|
||||
@@ -118,7 +116,6 @@ import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
import android.view.DisplayInfo;
|
||||
import android.view.InputChannel;
|
||||
import android.view.InputDevice;
|
||||
import android.view.MotionEvent;
|
||||
@@ -288,7 +285,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
final InputManagerInternal mInputManagerInternal;
|
||||
final ImePlatformCompatUtils mImePlatformCompatUtils;
|
||||
final InputMethodDeviceConfigs mInputMethodDeviceConfigs;
|
||||
private final DisplayManagerInternal mDisplayManagerInternal;
|
||||
private final ArrayMap<String, List<InputMethodSubtype>> mAdditionalSubtypeMap =
|
||||
new ArrayMap<>();
|
||||
private final UserManagerInternal mUserManagerInternal;
|
||||
@@ -458,35 +454,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
@GuardedBy("ImfLock.class")
|
||||
final ArrayMap<IBinder, ClientState> mClients = new ArrayMap<>();
|
||||
|
||||
private static final class VirtualDisplayInfo {
|
||||
/**
|
||||
* {@link ClientState} where {@link android.hardware.display.VirtualDisplay} is running.
|
||||
*/
|
||||
private final ClientState mParentClient;
|
||||
/**
|
||||
* {@link Matrix} to convert screen coordinates in the embedded virtual display to
|
||||
* screen coordinates where {@link #mParentClient} exists.
|
||||
*/
|
||||
private final Matrix mMatrix;
|
||||
|
||||
VirtualDisplayInfo(ClientState parentClient, Matrix matrix) {
|
||||
mParentClient = parentClient;
|
||||
mMatrix = matrix;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A mapping table from virtual display IDs created for
|
||||
* {@link android.hardware.display.VirtualDisplay} to its parent IME client where the embedded
|
||||
* virtual display is running.
|
||||
*
|
||||
* <p>Note: this can be used only for virtual display IDs created by
|
||||
* {@link android.hardware.display.VirtualDisplay}.</p>
|
||||
*/
|
||||
@GuardedBy("ImfLock.class")
|
||||
private final SparseArray<VirtualDisplayInfo> mVirtualDisplayIdToParentMap =
|
||||
new SparseArray<>();
|
||||
|
||||
/**
|
||||
* Set once the system is ready to run third party code.
|
||||
*/
|
||||
@@ -604,16 +571,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
@Nullable
|
||||
EditorInfo mCurEditorInfo;
|
||||
|
||||
/**
|
||||
* A special {@link Matrix} to convert virtual screen coordinates to the IME target display
|
||||
* coordinates.
|
||||
*
|
||||
* <p>Used only while the IME client is running in a virtual display. {@code null}
|
||||
* otherwise.</p>
|
||||
*/
|
||||
@Nullable
|
||||
private Matrix mCurVirtualDisplayToScreenMatrix = null;
|
||||
|
||||
/**
|
||||
* Id obtained with {@link InputMethodInfo#getId()} for the input method that we are currently
|
||||
* connected to or in the process of connecting to.
|
||||
@@ -1728,7 +1685,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
mInputManagerInternal = LocalServices.getService(InputManagerInternal.class);
|
||||
mImePlatformCompatUtils = new ImePlatformCompatUtils();
|
||||
mInputMethodDeviceConfigs = new InputMethodDeviceConfigs();
|
||||
mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
|
||||
mUserManagerInternal = LocalServices.getService(UserManagerInternal.class);
|
||||
|
||||
mSlotIme = mContext.getString(com.android.internal.R.string.status_bar_ime);
|
||||
@@ -2309,14 +2265,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
clearClientSessionLocked(cs);
|
||||
clearClientSessionForAccessibilityLocked(cs);
|
||||
|
||||
final int numItems = mVirtualDisplayIdToParentMap.size();
|
||||
for (int i = numItems - 1; i >= 0; --i) {
|
||||
final VirtualDisplayInfo info = mVirtualDisplayIdToParentMap.valueAt(i);
|
||||
if (info.mParentClient == cs) {
|
||||
mVirtualDisplayIdToParentMap.removeAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (mCurClient == cs) {
|
||||
hideCurrentInputLocked(mCurFocusedWindow, null /* statsToken */, 0 /* flags */,
|
||||
null /* resultReceiver */, SoftInputShowHideReason.HIDE_REMOVE_CLIENT);
|
||||
@@ -2332,7 +2280,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
}
|
||||
mBoundToAccessibility = false;
|
||||
mCurClient = null;
|
||||
mCurVirtualDisplayToScreenMatrix = null;
|
||||
}
|
||||
if (mCurFocusedWindowClient == cs) {
|
||||
mCurFocusedWindowClient = null;
|
||||
@@ -2366,10 +2313,10 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
mCurClient.mSessionRequested = false;
|
||||
mCurClient.mSessionRequestedForAccessibility = false;
|
||||
mCurClient = null;
|
||||
mCurVirtualDisplayToScreenMatrix = null;
|
||||
ImeTracker.forLogging().onFailed(mCurStatsToken, ImeTracker.PHASE_SERVER_WAIT_IME);
|
||||
mCurStatsToken = null;
|
||||
InputMethodManager.invalidateLocalStylusHandwritingAvailabilityCaches();
|
||||
|
||||
mMenuController.hideInputMethodMenuLocked();
|
||||
}
|
||||
}
|
||||
@@ -2484,33 +2431,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
return new InputBindResult(InputBindResult.ResultCode.SUCCESS_WITH_IME_SESSION,
|
||||
session.mSession, accessibilityInputMethodSessions,
|
||||
(session.mChannel != null ? session.mChannel.dup() : null),
|
||||
curId, getSequenceNumberLocked(), mCurVirtualDisplayToScreenMatrix,
|
||||
suppressesSpellChecker);
|
||||
}
|
||||
|
||||
@GuardedBy("ImfLock.class")
|
||||
@Nullable
|
||||
private Matrix getVirtualDisplayToScreenMatrixLocked(int clientDisplayId, int imeDisplayId) {
|
||||
if (clientDisplayId == imeDisplayId) {
|
||||
return null;
|
||||
}
|
||||
int displayId = clientDisplayId;
|
||||
Matrix matrix = null;
|
||||
while (true) {
|
||||
final VirtualDisplayInfo info = mVirtualDisplayIdToParentMap.get(displayId);
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
if (matrix == null) {
|
||||
matrix = new Matrix(info.mMatrix);
|
||||
} else {
|
||||
matrix.postConcat(info.mMatrix);
|
||||
}
|
||||
if (info.mParentClient.mSelfReportedDisplayId == imeDisplayId) {
|
||||
return matrix;
|
||||
}
|
||||
displayId = info.mParentClient.mSelfReportedDisplayId;
|
||||
}
|
||||
curId, getSequenceNumberLocked(), suppressesSpellChecker);
|
||||
}
|
||||
|
||||
@GuardedBy("ImfLock.class")
|
||||
@@ -2574,7 +2495,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
// party code.
|
||||
return new InputBindResult(
|
||||
InputBindResult.ResultCode.ERROR_SYSTEM_NOT_READY,
|
||||
null, null, null, selectedMethodId, getSequenceNumberLocked(), null, false);
|
||||
null, null, null, selectedMethodId, getSequenceNumberLocked(), false);
|
||||
}
|
||||
|
||||
if (!InputMethodUtils.checkIfPackageBelongsToUid(mPackageManagerInternal, cs.mUid,
|
||||
@@ -2611,9 +2532,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
mCurInputConnection = inputConnection;
|
||||
mCurRemoteAccessibilityInputConnection = remoteAccessibilityInputConnection;
|
||||
mCurImeDispatcher = imeDispatcher;
|
||||
mCurVirtualDisplayToScreenMatrix =
|
||||
getVirtualDisplayToScreenMatrixLocked(cs.mSelfReportedDisplayId,
|
||||
mDisplayIdToShowIme);
|
||||
// Override the locale hints if the app is running on a virtual device.
|
||||
if (mVdmInternal == null) {
|
||||
mVdmInternal = LocalServices.getService(VirtualDeviceManagerInternal.class);
|
||||
@@ -2729,7 +2647,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
requestClientSessionForAccessibilityLocked(cs);
|
||||
return new InputBindResult(
|
||||
InputBindResult.ResultCode.SUCCESS_WAITING_IME_SESSION,
|
||||
null, null, null, getCurIdLocked(), getSequenceNumberLocked(), null, false);
|
||||
null, null, null, getCurIdLocked(), getSequenceNumberLocked(), false);
|
||||
} else {
|
||||
long bindingDuration = SystemClock.uptimeMillis() - getLastBindTimeLocked();
|
||||
if (bindingDuration < TIME_TO_RECONNECT) {
|
||||
@@ -2742,8 +2660,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
// to see if we can get back in touch with the service.
|
||||
return new InputBindResult(
|
||||
InputBindResult.ResultCode.SUCCESS_WAITING_IME_BINDING,
|
||||
null, null, null, getCurIdLocked(), getSequenceNumberLocked(), null,
|
||||
false);
|
||||
null, null, null, getCurIdLocked(), getSequenceNumberLocked(), false);
|
||||
} else {
|
||||
EventLog.writeEvent(EventLogTags.IMF_FORCE_RECONNECT_IME,
|
||||
getSelectedMethodIdLocked(), bindingDuration, 0);
|
||||
@@ -3898,7 +3815,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
}
|
||||
return new InputBindResult(
|
||||
InputBindResult.ResultCode.SUCCESS_REPORT_WINDOW_FOCUS_ONLY,
|
||||
null, null, null, null, -1, null, false);
|
||||
null, null, null, null, -1, false);
|
||||
}
|
||||
|
||||
mCurFocusedWindow = windowToken;
|
||||
@@ -4356,95 +4273,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportVirtualDisplayGeometryAsync(IInputMethodClient parentClient,
|
||||
int childDisplayId, float[] matrixValues) {
|
||||
final IInputMethodClientInvoker parentClientInvoker =
|
||||
IInputMethodClientInvoker.create(parentClient, mHandler);
|
||||
try {
|
||||
final DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(childDisplayId);
|
||||
if (displayInfo == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot find display for non-existent displayId: " + childDisplayId);
|
||||
}
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
if (callingUid != displayInfo.ownerUid) {
|
||||
throw new SecurityException("The caller doesn't own the display.");
|
||||
}
|
||||
|
||||
synchronized (ImfLock.class) {
|
||||
final ClientState cs = mClients.get(parentClientInvoker.asBinder());
|
||||
if (cs == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// null matrixValues means that the entry needs to be removed.
|
||||
if (matrixValues == null) {
|
||||
final VirtualDisplayInfo info =
|
||||
mVirtualDisplayIdToParentMap.get(childDisplayId);
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
if (info.mParentClient != cs) {
|
||||
throw new SecurityException("Only the owner client can clear"
|
||||
+ " VirtualDisplayGeometry for display #" + childDisplayId);
|
||||
}
|
||||
mVirtualDisplayIdToParentMap.remove(childDisplayId);
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualDisplayInfo info = mVirtualDisplayIdToParentMap.get(childDisplayId);
|
||||
if (info != null && info.mParentClient != cs) {
|
||||
throw new InvalidParameterException("Display #" + childDisplayId
|
||||
+ " is already registered by " + info.mParentClient);
|
||||
}
|
||||
if (info == null) {
|
||||
if (!mWindowManagerInternal.isUidAllowedOnDisplay(childDisplayId, cs.mUid)) {
|
||||
throw new SecurityException(cs + " cannot access to display #"
|
||||
+ childDisplayId);
|
||||
}
|
||||
info = new VirtualDisplayInfo(cs, new Matrix());
|
||||
mVirtualDisplayIdToParentMap.put(childDisplayId, info);
|
||||
}
|
||||
info.mMatrix.setValues(matrixValues);
|
||||
|
||||
if (mCurClient == null || mCurClient.mCurSession == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Matrix matrix = null;
|
||||
int displayId = mCurClient.mSelfReportedDisplayId;
|
||||
boolean needToNotify = false;
|
||||
while (true) {
|
||||
needToNotify |= (displayId == childDisplayId);
|
||||
final VirtualDisplayInfo next = mVirtualDisplayIdToParentMap.get(displayId);
|
||||
if (next == null) {
|
||||
break;
|
||||
}
|
||||
if (matrix == null) {
|
||||
matrix = new Matrix(next.mMatrix);
|
||||
} else {
|
||||
matrix.postConcat(next.mMatrix);
|
||||
}
|
||||
if (next.mParentClient.mSelfReportedDisplayId == mCurTokenDisplayId) {
|
||||
if (needToNotify) {
|
||||
final float[] values = new float[9];
|
||||
matrix.getValues(values);
|
||||
mCurClient.mClient.updateVirtualDisplayToScreenMatrix(
|
||||
getSequenceNumberLocked(), values);
|
||||
}
|
||||
break;
|
||||
}
|
||||
displayId = info.mParentClient.mSelfReportedDisplayId;
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
if (parentClientInvoker != null) {
|
||||
parentClientInvoker.throwExceptionFromSystem(t.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeImeSurfaceFromWindowAsync(IBinder windowToken) {
|
||||
// No permission check, because we'll only execute the request if the calling window is
|
||||
@@ -5857,7 +5685,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
final InputBindResult res = new InputBindResult(
|
||||
InputBindResult.ResultCode.SUCCESS_WITH_ACCESSIBILITY_SESSION,
|
||||
imeSession, accessibilityInputMethodSessions, null, getCurIdLocked(),
|
||||
getSequenceNumberLocked(), mCurVirtualDisplayToScreenMatrix, false);
|
||||
getSequenceNumberLocked(), false);
|
||||
mCurClient.mClient.onBindAccessibilityService(res, accessibilityConnectionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import android.app.ActivityManagerInternal;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.display.DisplayManagerInternal;
|
||||
import android.hardware.input.IInputManager;
|
||||
import android.hardware.input.InputManagerGlobal;
|
||||
import android.os.Binder;
|
||||
@@ -95,14 +94,12 @@ public class InputMethodManagerServiceTestBase {
|
||||
null,
|
||||
"0",
|
||||
0,
|
||||
null,
|
||||
false);
|
||||
|
||||
@Mock protected WindowManagerInternal mMockWindowManagerInternal;
|
||||
@Mock protected ActivityManagerInternal mMockActivityManagerInternal;
|
||||
@Mock protected PackageManagerInternal mMockPackageManagerInternal;
|
||||
@Mock protected InputManagerInternal mMockInputManagerInternal;
|
||||
@Mock protected DisplayManagerInternal mMockDisplayManagerInternal;
|
||||
@Mock protected UserManagerInternal mMockUserManagerInternal;
|
||||
@Mock protected InputMethodBindingController mMockInputMethodBindingController;
|
||||
@Mock protected IInputMethodClient mMockInputMethodClient;
|
||||
@@ -165,8 +162,6 @@ public class InputMethodManagerServiceTestBase {
|
||||
.when(() -> LocalServices.getService(PackageManagerInternal.class));
|
||||
doReturn(mMockInputManagerInternal)
|
||||
.when(() -> LocalServices.getService(InputManagerInternal.class));
|
||||
doReturn(mMockDisplayManagerInternal)
|
||||
.when(() -> LocalServices.getService(DisplayManagerInternal.class));
|
||||
doReturn(mMockUserManagerInternal)
|
||||
.when(() -> LocalServices.getService(UserManagerInternal.class));
|
||||
doReturn(mMockImeTargetVisibilityPolicy)
|
||||
|
||||
Reference in New Issue
Block a user