Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +108 −72 Original line number Original line Diff line number Diff line Loading @@ -1812,8 +1812,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. } } @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") @Override private boolean isInputShownLocked() { public boolean isInputShownLocked() { return mVisibilityStateComputer.isInputShown(); return mVisibilityStateComputer.isInputShown(); } } Loading Loading @@ -3004,17 +3003,41 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. } } } } @GuardedBy("ImfLock.class") private void sendResultReceiverFailureLocked(@Nullable ResultReceiver resultReceiver) { final boolean isInputShown = mVisibilityStateComputer.isInputShown(); resultReceiver.send(isInputShown ? InputMethodManager.RESULT_UNCHANGED_SHOWN : InputMethodManager.RESULT_UNCHANGED_HIDDEN, null); } @Override @Override public boolean showSoftInput(IInputMethodClient client, IBinder windowToken, public boolean showSoftInput(IInputMethodClient client, IBinder windowToken, @NonNull ImeTracker.Token statsToken, @InputMethodManager.ShowFlags int flags, @NonNull ImeTracker.Token statsToken, @InputMethodManager.ShowFlags int flags, int lastClickToolType, ResultReceiver resultReceiver, int lastClickToolType, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { @SoftInputShowHideReason int reason) { Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showSoftInput"); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showSoftInput"); final int uid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(uid); ImeTracing.getInstance().triggerManagerServiceDump( ImeTracing.getInstance().triggerManagerServiceDump( "InputMethodManagerService#showSoftInput", mDumper); "InputMethodManagerService#showSoftInput", mDumper); synchronized (ImfLock.class) { synchronized (ImfLock.class) { final boolean result = showSoftInputLocked(client, windowToken, statsToken, flags, lastClickToolType, resultReceiver, reason); // When ZeroJankProxy is enabled, the app has already received "true" as the return // value, and expect "resultReceiver" to be notified later. See b/327751155. if (!result && Flags.useZeroJankProxy()) { sendResultReceiverFailureLocked(resultReceiver); } return result; // ignored when ZeroJankProxy is enabled. } } @GuardedBy("ImfLock.class") private boolean showSoftInputLocked(IInputMethodClient client, IBinder windowToken, @NonNull ImeTracker.Token statsToken, @InputMethodManager.ShowFlags int flags, int lastClickToolType, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { final int uid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(uid); final int userId = resolveImeUserIdLocked(callingUserId); final int userId = resolveImeUserIdLocked(callingUserId); if (!canInteractWithImeLocked(uid, client, "showSoftInput", statsToken, if (!canInteractWithImeLocked(uid, client, "showSoftInput", statsToken, userId)) { userId)) { Loading Loading @@ -3051,7 +3074,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } } } } } // TODO(b/353463205) check callers to see if we can make statsToken @NonNull // TODO(b/353463205) check callers to see if we can make statsToken @NonNull boolean showCurrentInputInternal(IBinder windowToken, @Nullable ImeTracker.Token statsToken) { boolean showCurrentInputInternal(IBinder windowToken, @Nullable ImeTracker.Token statsToken) { Loading Loading @@ -3444,11 +3466,26 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. public boolean hideSoftInput(IInputMethodClient client, IBinder windowToken, public boolean hideSoftInput(IInputMethodClient client, IBinder windowToken, @NonNull ImeTracker.Token statsToken, @InputMethodManager.HideFlags int flags, @NonNull ImeTracker.Token statsToken, @InputMethodManager.HideFlags int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { final int uid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(uid); ImeTracing.getInstance().triggerManagerServiceDump( ImeTracing.getInstance().triggerManagerServiceDump( "InputMethodManagerService#hideSoftInput", mDumper); "InputMethodManagerService#hideSoftInput", mDumper); synchronized (ImfLock.class) { synchronized (ImfLock.class) { final boolean result = hideSoftInputLocked(client, windowToken, statsToken, flags, resultReceiver, reason); // When ZeroJankProxy is enabled, the app has already received "true" as the return // value, and expect "resultReceiver" to be notified later. See b/327751155. if (!result && Flags.useZeroJankProxy()) { sendResultReceiverFailureLocked(resultReceiver); } return result; // ignored when ZeroJankProxy is enabled. } } @GuardedBy("ImfLock.class") private boolean hideSoftInputLocked(IInputMethodClient client, IBinder windowToken, @NonNull ImeTracker.Token statsToken, @InputMethodManager.HideFlags int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { final int uid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(uid); final int userId = resolveImeUserIdLocked(callingUserId); final int userId = resolveImeUserIdLocked(callingUserId); if (!canInteractWithImeLocked(uid, client, "hideSoftInput", statsToken, userId)) { if (!canInteractWithImeLocked(uid, client, "hideSoftInput", statsToken, userId)) { if (isInputShownLocked()) { if (isInputShownLocked()) { Loading Loading @@ -3481,15 +3518,14 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. } } return false; return false; } else { } else { return InputMethodManagerService.this.hideCurrentInputLocked(windowToken, return InputMethodManagerService.this.hideCurrentInputLocked( statsToken, flags, resultReceiver, reason, userId); windowToken, statsToken, flags, resultReceiver, reason, userId); } } } finally { } finally { Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } } } } } @Override @Override @IInputMethodManagerImpl.PermissionVerified(Manifest.permission.TEST_INPUT_METHOD) @IInputMethodManagerImpl.PermissionVerified(Manifest.permission.TEST_INPUT_METHOD) Loading services/core/java/com/android/server/inputmethod/ZeroJankProxy.java +4 −36 Original line number Original line Diff line number Diff line Loading @@ -86,8 +86,6 @@ final class ZeroJankProxy implements IInputMethodManagerImpl.Callback { interface Callback extends IInputMethodManagerImpl.Callback { interface Callback extends IInputMethodManagerImpl.Callback { @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") ClientState getClientStateLocked(IInputMethodClient client); ClientState getClientStateLocked(IInputMethodClient client); @GuardedBy("ImfLock.class") boolean isInputShownLocked(); } } private final Callback mInner; private final Callback mInner; Loading Loading @@ -178,19 +176,8 @@ final class ZeroJankProxy implements IInputMethodManagerImpl.Callback { @Nullable ImeTracker.Token statsToken, @InputMethodManager.ShowFlags int flags, @Nullable ImeTracker.Token statsToken, @InputMethodManager.ShowFlags int flags, @MotionEvent.ToolType int lastClickToolType, ResultReceiver resultReceiver, @MotionEvent.ToolType int lastClickToolType, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { @SoftInputShowHideReason int reason) { offload( offload(() -> mInner.showSoftInput( () -> { client, windowToken, statsToken, flags, lastClickToolType, resultReceiver, reason)); if (!mInner.showSoftInput( client, windowToken, statsToken, flags, lastClickToolType, resultReceiver, reason)) { sendResultReceiverFailure(resultReceiver); } }); return true; return true; } } Loading @@ -198,30 +185,11 @@ final class ZeroJankProxy implements IInputMethodManagerImpl.Callback { public boolean hideSoftInput(IInputMethodClient client, IBinder windowToken, public boolean hideSoftInput(IInputMethodClient client, IBinder windowToken, @Nullable ImeTracker.Token statsToken, @InputMethodManager.HideFlags int flags, @Nullable ImeTracker.Token statsToken, @InputMethodManager.HideFlags int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { offload( offload(() -> mInner.hideSoftInput( () -> { client, windowToken, statsToken, flags, resultReceiver, reason)); if (!mInner.hideSoftInput( client, windowToken, statsToken, flags, resultReceiver, reason)) { sendResultReceiverFailure(resultReceiver); } }); return true; return true; } } private void sendResultReceiverFailure(@Nullable ResultReceiver resultReceiver) { if (resultReceiver == null) { return; } final boolean isInputShown; synchronized (ImfLock.class) { isInputShown = mInner.isInputShownLocked(); } resultReceiver.send(isInputShown ? InputMethodManager.RESULT_UNCHANGED_SHOWN : InputMethodManager.RESULT_UNCHANGED_HIDDEN, null); } @Override @Override @IInputMethodManagerImpl.PermissionVerified(Manifest.permission.TEST_INPUT_METHOD) @IInputMethodManagerImpl.PermissionVerified(Manifest.permission.TEST_INPUT_METHOD) public void hideSoftInputFromServerForTest() { public void hideSoftInputFromServerForTest() { Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +108 −72 Original line number Original line Diff line number Diff line Loading @@ -1812,8 +1812,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. } } @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") @Override private boolean isInputShownLocked() { public boolean isInputShownLocked() { return mVisibilityStateComputer.isInputShown(); return mVisibilityStateComputer.isInputShown(); } } Loading Loading @@ -3004,17 +3003,41 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. } } } } @GuardedBy("ImfLock.class") private void sendResultReceiverFailureLocked(@Nullable ResultReceiver resultReceiver) { final boolean isInputShown = mVisibilityStateComputer.isInputShown(); resultReceiver.send(isInputShown ? InputMethodManager.RESULT_UNCHANGED_SHOWN : InputMethodManager.RESULT_UNCHANGED_HIDDEN, null); } @Override @Override public boolean showSoftInput(IInputMethodClient client, IBinder windowToken, public boolean showSoftInput(IInputMethodClient client, IBinder windowToken, @NonNull ImeTracker.Token statsToken, @InputMethodManager.ShowFlags int flags, @NonNull ImeTracker.Token statsToken, @InputMethodManager.ShowFlags int flags, int lastClickToolType, ResultReceiver resultReceiver, int lastClickToolType, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { @SoftInputShowHideReason int reason) { Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showSoftInput"); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showSoftInput"); final int uid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(uid); ImeTracing.getInstance().triggerManagerServiceDump( ImeTracing.getInstance().triggerManagerServiceDump( "InputMethodManagerService#showSoftInput", mDumper); "InputMethodManagerService#showSoftInput", mDumper); synchronized (ImfLock.class) { synchronized (ImfLock.class) { final boolean result = showSoftInputLocked(client, windowToken, statsToken, flags, lastClickToolType, resultReceiver, reason); // When ZeroJankProxy is enabled, the app has already received "true" as the return // value, and expect "resultReceiver" to be notified later. See b/327751155. if (!result && Flags.useZeroJankProxy()) { sendResultReceiverFailureLocked(resultReceiver); } return result; // ignored when ZeroJankProxy is enabled. } } @GuardedBy("ImfLock.class") private boolean showSoftInputLocked(IInputMethodClient client, IBinder windowToken, @NonNull ImeTracker.Token statsToken, @InputMethodManager.ShowFlags int flags, int lastClickToolType, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { final int uid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(uid); final int userId = resolveImeUserIdLocked(callingUserId); final int userId = resolveImeUserIdLocked(callingUserId); if (!canInteractWithImeLocked(uid, client, "showSoftInput", statsToken, if (!canInteractWithImeLocked(uid, client, "showSoftInput", statsToken, userId)) { userId)) { Loading Loading @@ -3051,7 +3074,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } } } } } // TODO(b/353463205) check callers to see if we can make statsToken @NonNull // TODO(b/353463205) check callers to see if we can make statsToken @NonNull boolean showCurrentInputInternal(IBinder windowToken, @Nullable ImeTracker.Token statsToken) { boolean showCurrentInputInternal(IBinder windowToken, @Nullable ImeTracker.Token statsToken) { Loading Loading @@ -3444,11 +3466,26 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. public boolean hideSoftInput(IInputMethodClient client, IBinder windowToken, public boolean hideSoftInput(IInputMethodClient client, IBinder windowToken, @NonNull ImeTracker.Token statsToken, @InputMethodManager.HideFlags int flags, @NonNull ImeTracker.Token statsToken, @InputMethodManager.HideFlags int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { final int uid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(uid); ImeTracing.getInstance().triggerManagerServiceDump( ImeTracing.getInstance().triggerManagerServiceDump( "InputMethodManagerService#hideSoftInput", mDumper); "InputMethodManagerService#hideSoftInput", mDumper); synchronized (ImfLock.class) { synchronized (ImfLock.class) { final boolean result = hideSoftInputLocked(client, windowToken, statsToken, flags, resultReceiver, reason); // When ZeroJankProxy is enabled, the app has already received "true" as the return // value, and expect "resultReceiver" to be notified later. See b/327751155. if (!result && Flags.useZeroJankProxy()) { sendResultReceiverFailureLocked(resultReceiver); } return result; // ignored when ZeroJankProxy is enabled. } } @GuardedBy("ImfLock.class") private boolean hideSoftInputLocked(IInputMethodClient client, IBinder windowToken, @NonNull ImeTracker.Token statsToken, @InputMethodManager.HideFlags int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { final int uid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(uid); final int userId = resolveImeUserIdLocked(callingUserId); final int userId = resolveImeUserIdLocked(callingUserId); if (!canInteractWithImeLocked(uid, client, "hideSoftInput", statsToken, userId)) { if (!canInteractWithImeLocked(uid, client, "hideSoftInput", statsToken, userId)) { if (isInputShownLocked()) { if (isInputShownLocked()) { Loading Loading @@ -3481,15 +3518,14 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. } } return false; return false; } else { } else { return InputMethodManagerService.this.hideCurrentInputLocked(windowToken, return InputMethodManagerService.this.hideCurrentInputLocked( statsToken, flags, resultReceiver, reason, userId); windowToken, statsToken, flags, resultReceiver, reason, userId); } } } finally { } finally { Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } } } } } @Override @Override @IInputMethodManagerImpl.PermissionVerified(Manifest.permission.TEST_INPUT_METHOD) @IInputMethodManagerImpl.PermissionVerified(Manifest.permission.TEST_INPUT_METHOD) Loading
services/core/java/com/android/server/inputmethod/ZeroJankProxy.java +4 −36 Original line number Original line Diff line number Diff line Loading @@ -86,8 +86,6 @@ final class ZeroJankProxy implements IInputMethodManagerImpl.Callback { interface Callback extends IInputMethodManagerImpl.Callback { interface Callback extends IInputMethodManagerImpl.Callback { @GuardedBy("ImfLock.class") @GuardedBy("ImfLock.class") ClientState getClientStateLocked(IInputMethodClient client); ClientState getClientStateLocked(IInputMethodClient client); @GuardedBy("ImfLock.class") boolean isInputShownLocked(); } } private final Callback mInner; private final Callback mInner; Loading Loading @@ -178,19 +176,8 @@ final class ZeroJankProxy implements IInputMethodManagerImpl.Callback { @Nullable ImeTracker.Token statsToken, @InputMethodManager.ShowFlags int flags, @Nullable ImeTracker.Token statsToken, @InputMethodManager.ShowFlags int flags, @MotionEvent.ToolType int lastClickToolType, ResultReceiver resultReceiver, @MotionEvent.ToolType int lastClickToolType, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { @SoftInputShowHideReason int reason) { offload( offload(() -> mInner.showSoftInput( () -> { client, windowToken, statsToken, flags, lastClickToolType, resultReceiver, reason)); if (!mInner.showSoftInput( client, windowToken, statsToken, flags, lastClickToolType, resultReceiver, reason)) { sendResultReceiverFailure(resultReceiver); } }); return true; return true; } } Loading @@ -198,30 +185,11 @@ final class ZeroJankProxy implements IInputMethodManagerImpl.Callback { public boolean hideSoftInput(IInputMethodClient client, IBinder windowToken, public boolean hideSoftInput(IInputMethodClient client, IBinder windowToken, @Nullable ImeTracker.Token statsToken, @InputMethodManager.HideFlags int flags, @Nullable ImeTracker.Token statsToken, @InputMethodManager.HideFlags int flags, ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { ResultReceiver resultReceiver, @SoftInputShowHideReason int reason) { offload( offload(() -> mInner.hideSoftInput( () -> { client, windowToken, statsToken, flags, resultReceiver, reason)); if (!mInner.hideSoftInput( client, windowToken, statsToken, flags, resultReceiver, reason)) { sendResultReceiverFailure(resultReceiver); } }); return true; return true; } } private void sendResultReceiverFailure(@Nullable ResultReceiver resultReceiver) { if (resultReceiver == null) { return; } final boolean isInputShown; synchronized (ImfLock.class) { isInputShown = mInner.isInputShownLocked(); } resultReceiver.send(isInputShown ? InputMethodManager.RESULT_UNCHANGED_SHOWN : InputMethodManager.RESULT_UNCHANGED_HIDDEN, null); } @Override @Override @IInputMethodManagerImpl.PermissionVerified(Manifest.permission.TEST_INPUT_METHOD) @IInputMethodManagerImpl.PermissionVerified(Manifest.permission.TEST_INPUT_METHOD) public void hideSoftInputFromServerForTest() { public void hideSoftInputFromServerForTest() { Loading