Merge "Implement IMMS#mCurFocusedWindowEditorInfo" into udc-dev
This commit is contained in:
@@ -532,6 +532,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
/**
|
/**
|
||||||
* The client that is currently bound to an input method.
|
* The client that is currently bound to an input method.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
private ClientState mCurClient;
|
private ClientState mCurClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -557,10 +558,25 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
int mCurFocusedWindowSoftInputMode;
|
int mCurFocusedWindowSoftInputMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client by which {@link #mCurFocusedWindow} was reported.
|
* The client by which {@link #mCurFocusedWindow} was reported. This gets updated whenever an
|
||||||
|
* IME-focusable window gained focus (without necessarily starting an input connection),
|
||||||
|
* while {@link #mCurClient} only gets updated when we actually start an input connection.
|
||||||
|
*
|
||||||
|
* @see #mCurFocusedWindow
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
ClientState mCurFocusedWindowClient;
|
ClientState mCurFocusedWindowClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The editor info by which {@link #mCurFocusedWindow} was reported. This differs from
|
||||||
|
* {@link #mCurEditorInfo} the same way {@link #mCurFocusedWindowClient} differs
|
||||||
|
* from {@link #mCurClient}.
|
||||||
|
*
|
||||||
|
* @see #mCurFocusedWindow
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
EditorInfo mCurFocusedWindowEditorInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link IRemoteInputConnection} last provided by the current client.
|
* The {@link IRemoteInputConnection} last provided by the current client.
|
||||||
*/
|
*/
|
||||||
@@ -580,6 +596,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
/**
|
/**
|
||||||
* The {@link EditorInfo} last provided by the current client.
|
* The {@link EditorInfo} last provided by the current client.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
EditorInfo mCurEditorInfo;
|
EditorInfo mCurEditorInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2265,6 +2282,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
if (mCurFocusedWindowClient == cs) {
|
if (mCurFocusedWindowClient == cs) {
|
||||||
mCurFocusedWindowClient = null;
|
mCurFocusedWindowClient = null;
|
||||||
|
mCurFocusedWindowEditorInfo = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3453,10 +3471,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) {
|
ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) {
|
||||||
// Create statsToken is none exists.
|
// Create statsToken is none exists.
|
||||||
if (statsToken == null) {
|
if (statsToken == null) {
|
||||||
// TODO(b/261565259): to avoid using null, add package name in ClientState
|
statsToken = createStatsTokenForFocusedClient(true /* show */,
|
||||||
final String packageName = (mCurEditorInfo != null) ? mCurEditorInfo.packageName : null;
|
|
||||||
final int uid = mCurClient != null ? mCurClient.mUid : -1;
|
|
||||||
statsToken = ImeTracker.forLogging().onRequestShow(packageName, uid,
|
|
||||||
ImeTracker.ORIGIN_SERVER_START_INPUT, reason);
|
ImeTracker.ORIGIN_SERVER_START_INPUT, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3530,17 +3545,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) {
|
int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) {
|
||||||
// Create statsToken is none exists.
|
// Create statsToken is none exists.
|
||||||
if (statsToken == null) {
|
if (statsToken == null) {
|
||||||
// TODO(b/261565259): to avoid using null, add package name in ClientState
|
statsToken = createStatsTokenForFocusedClient(false /* show */,
|
||||||
final String packageName = (mCurEditorInfo != null) ? mCurEditorInfo.packageName : null;
|
|
||||||
final int uid;
|
|
||||||
if (mCurClient != null) {
|
|
||||||
uid = mCurClient.mUid;
|
|
||||||
} else if (mCurFocusedWindowClient != null) {
|
|
||||||
uid = mCurFocusedWindowClient.mUid;
|
|
||||||
} else {
|
|
||||||
uid = -1;
|
|
||||||
}
|
|
||||||
statsToken = ImeTracker.forLogging().onRequestHide(packageName, uid,
|
|
||||||
ImeTracker.ORIGIN_SERVER_HIDE_INPUT, reason);
|
ImeTracker.ORIGIN_SERVER_HIDE_INPUT, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3775,6 +3780,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mCurFocusedWindow = windowToken;
|
mCurFocusedWindow = windowToken;
|
||||||
mCurFocusedWindowSoftInputMode = softInputMode;
|
mCurFocusedWindowSoftInputMode = softInputMode;
|
||||||
mCurFocusedWindowClient = cs;
|
mCurFocusedWindowClient = cs;
|
||||||
|
mCurFocusedWindowEditorInfo = editorInfo;
|
||||||
mCurPerceptible = true;
|
mCurPerceptible = true;
|
||||||
|
|
||||||
// We want to start input before showing the IME, but after closing
|
// We want to start input before showing the IME, but after closing
|
||||||
@@ -4703,7 +4709,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
mWindowManagerInternal.onToggleImeRequested(
|
mWindowManagerInternal.onToggleImeRequested(
|
||||||
show, mCurFocusedWindow, requestToken, mCurTokenDisplayId);
|
show, mCurFocusedWindow, requestToken, mCurTokenDisplayId);
|
||||||
mSoftInputShowHideHistory.addEntry(new SoftInputShowHideHistory.Entry(
|
mSoftInputShowHideHistory.addEntry(new SoftInputShowHideHistory.Entry(
|
||||||
mCurFocusedWindowClient, mCurEditorInfo, info.focusedWindowName,
|
mCurFocusedWindowClient, mCurFocusedWindowEditorInfo, info.focusedWindowName,
|
||||||
mCurFocusedWindowSoftInputMode, reason, mInFullscreenMode,
|
mCurFocusedWindowSoftInputMode, reason, mInFullscreenMode,
|
||||||
info.requestWindowName, info.imeControlTargetName, info.imeLayerTargetName,
|
info.requestWindowName, info.imeControlTargetName, info.imeLayerTargetName,
|
||||||
info.imeSurfaceParentName));
|
info.imeSurfaceParentName));
|
||||||
@@ -5751,9 +5757,11 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
// We cannot simply distinguish a bad IME that reports an arbitrary package name from
|
// We cannot simply distinguish a bad IME that reports an arbitrary package name from
|
||||||
// an unfortunate IME whose internal state is already obsolete due to the asynchronous
|
// an unfortunate IME whose internal state is already obsolete due to the asynchronous
|
||||||
// nature of our system. Let's compare it with our internal record.
|
// nature of our system. Let's compare it with our internal record.
|
||||||
if (!TextUtils.equals(mCurEditorInfo.packageName, packageName)) {
|
final var curPackageName = mCurEditorInfo != null
|
||||||
|
? mCurEditorInfo.packageName : null;
|
||||||
|
if (!TextUtils.equals(curPackageName, packageName)) {
|
||||||
Slog.e(TAG, "Ignoring createInputContentUriToken mCurEditorInfo.packageName="
|
Slog.e(TAG, "Ignoring createInputContentUriToken mCurEditorInfo.packageName="
|
||||||
+ mCurEditorInfo.packageName + " packageName=" + packageName);
|
+ curPackageName + " packageName=" + packageName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// This user ID can never bee spoofed.
|
// This user ID can never bee spoofed.
|
||||||
@@ -6514,6 +6522,30 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
return mImeTrackerService;
|
return mImeTrackerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an IME request tracking token for the current focused client.
|
||||||
|
*
|
||||||
|
* @param show whether this is a show or a hide request.
|
||||||
|
* @param origin the origin of the IME request.
|
||||||
|
* @param reason the reason why the IME request was created.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
private ImeTracker.Token createStatsTokenForFocusedClient(boolean show,
|
||||||
|
@ImeTracker.Origin int origin, @SoftInputShowHideReason int reason) {
|
||||||
|
final int uid = mCurFocusedWindowClient != null
|
||||||
|
? mCurFocusedWindowClient.mUid
|
||||||
|
: -1;
|
||||||
|
final var packageName = mCurFocusedWindowEditorInfo != null
|
||||||
|
? mCurFocusedWindowEditorInfo.packageName
|
||||||
|
: "uid(" + uid + ")";
|
||||||
|
|
||||||
|
if (show) {
|
||||||
|
return ImeTracker.forLogging().onRequestShow(packageName, uid, origin, reason);
|
||||||
|
} else {
|
||||||
|
return ImeTracker.forLogging().onRequestHide(packageName, uid, origin, reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final class InputMethodPrivilegedOperationsImpl
|
private static final class InputMethodPrivilegedOperationsImpl
|
||||||
extends IInputMethodPrivilegedOperations.Stub {
|
extends IInputMethodPrivilegedOperations.Stub {
|
||||||
private final InputMethodManagerService mImms;
|
private final InputMethodManagerService mImms;
|
||||||
|
|||||||
Reference in New Issue
Block a user