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

This commit is contained in:
TreeHugger Robot
2023-02-21 03:13:07 +00:00
committed by Android (Google) Code Review

View File

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