Merge "Fix potential trace{Begin, End} mis-match issues in IMMS" into udc-dev am: da896af691

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21507352

Change-Id: I74ae6374a47dd07a8be16465650fd7194b8d2113
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2023-02-21 04:33:43 +00:00
committed by Automerger Merge Worker

View File

@@ -4549,19 +4549,23 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
@BinderThread
private void applyImeVisibility(IBinder token, IBinder windowToken, boolean setVisible,
@Nullable ImeTracker.Token statsToken) {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.applyImeVisibility");
synchronized (ImfLock.class) {
if (!calledWithValidTokenLocked(token)) {
ImeTracker.forLogging().onFailed(statsToken,
ImeTracker.PHASE_SERVER_APPLY_IME_VISIBILITY);
return;
try {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.applyImeVisibility");
synchronized (ImfLock.class) {
if (!calledWithValidTokenLocked(token)) {
ImeTracker.forLogging().onFailed(statsToken,
ImeTracker.PHASE_SERVER_APPLY_IME_VISIBILITY);
return;
}
final IBinder requestToken = mVisibilityStateComputer.getWindowTokenFrom(
windowToken);
mVisibilityApplier.applyImeVisibility(requestToken, statsToken,
setVisible ? ImeVisibilityStateComputer.STATE_SHOW_IME
: ImeVisibilityStateComputer.STATE_HIDE_IME);
}
final IBinder requestToken = mVisibilityStateComputer.getWindowTokenFrom(windowToken);
mVisibilityApplier.applyImeVisibility(requestToken, statsToken,
setVisible ? ImeVisibilityStateComputer.STATE_SHOW_IME
: ImeVisibilityStateComputer.STATE_HIDE_IME);
} finally {
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
@BinderThread
@@ -4632,39 +4636,45 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
@BinderThread
private void hideMySoftInput(@NonNull IBinder token, int flags,
@SoftInputShowHideReason int reason) {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.hideMySoftInput");
synchronized (ImfLock.class) {
if (!calledWithValidTokenLocked(token)) {
return;
}
final long ident = Binder.clearCallingIdentity();
try {
hideCurrentInputLocked(mLastImeTargetWindow, null /* statsToken */, flags,
null /* resultReceiver */, reason);
} finally {
Binder.restoreCallingIdentity(ident);
try {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.hideMySoftInput");
synchronized (ImfLock.class) {
if (!calledWithValidTokenLocked(token)) {
return;
}
final long ident = Binder.clearCallingIdentity();
try {
hideCurrentInputLocked(mLastImeTargetWindow, null /* statsToken */, flags,
null /* resultReceiver */, reason);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
} finally {
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
@BinderThread
private void showMySoftInput(@NonNull IBinder token, int flags) {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showMySoftInput");
synchronized (ImfLock.class) {
if (!calledWithValidTokenLocked(token)) {
return;
}
final long ident = Binder.clearCallingIdentity();
try {
showCurrentInputLocked(mLastImeTargetWindow, null /* statsToken */, flags,
null /* resultReceiver */,
SoftInputShowHideReason.SHOW_SOFT_INPUT_FROM_IME);
} finally {
Binder.restoreCallingIdentity(ident);
try {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showMySoftInput");
synchronized (ImfLock.class) {
if (!calledWithValidTokenLocked(token)) {
return;
}
final long ident = Binder.clearCallingIdentity();
try {
showCurrentInputLocked(mLastImeTargetWindow, null /* statsToken */, flags,
null /* resultReceiver */,
SoftInputShowHideReason.SHOW_SOFT_INPUT_FROM_IME);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
} finally {
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
@VisibleForTesting