Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91944cec authored by Nikolas Havrikov's avatar Nikolas Havrikov
Browse files

Avoid calculating the same time span twice

Bug: 205676419
Test: make
Change-Id: Iea3dff8bd25d4404e4164c32db1216418cffbc63
parent 9bc49a5a
Loading
Loading
Loading
Loading
+32 −28
Original line number Diff line number Diff line
@@ -2523,8 +2523,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                return new InputBindResult(
                        InputBindResult.ResultCode.SUCCESS_WAITING_IME_SESSION,
                        null, null, getCurId(), getSequenceNumber(), false);
            } else if (SystemClock.uptimeMillis()
                    < (getLastBindTime() + TIME_TO_RECONNECT)) {
            } else {
                long bindingDuration = SystemClock.uptimeMillis() - getLastBindTime();
                if (bindingDuration < TIME_TO_RECONNECT) {
                    // In this case we have connected to the service, but
                    // don't yet have its interface.  If it hasn't been too
                    // long since we did the connection, we'll return to
@@ -2537,7 +2538,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                            null, null, getCurId(), getSequenceNumber(), false);
                } else {
                    EventLog.writeEvent(EventLogTags.IMF_FORCE_RECONNECT_IME,
                        getSelectedMethodId(), SystemClock.uptimeMillis() - getLastBindTime(), 0);
                            getSelectedMethodId(), bindingDuration, 0);
                }
            }
        }
        return null;
@@ -3260,21 +3262,23 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                mVisibleBound = true;
            }
            res = true;
        } else if (hasConnection() && SystemClock.uptimeMillis()
                >= (getLastBindTime() + TIME_TO_RECONNECT)) {
        } else {
            long bindingDuration = SystemClock.uptimeMillis() - getLastBindTime();
            if (hasConnection() && bindingDuration >= TIME_TO_RECONNECT) {
                // The client has asked to have the input method shown, but
                // we have been sitting here too long with a connection to the
                // service and no interface received, so let's disconnect/connect
                // to try to prod things along.
                EventLog.writeEvent(EventLogTags.IMF_FORCE_RECONNECT_IME, getSelectedMethodId(),
                    SystemClock.uptimeMillis() - getLastBindTime(), 1);
                        bindingDuration, 1);
                Slog.w(TAG, "Force disconnect/connect to the IME in showCurrentInputLocked()");
                mContext.unbindService(this);
                bindCurrentInputMethodServiceLocked(getCurIntent(), this, mImeConnectionBindFlags);
            } else {
                if (DEBUG) {
                    Slog.d(TAG, "Can't show input: connection = " + hasConnection() + ", time = "
                        + ((getLastBindTime() + TIME_TO_RECONNECT) - SystemClock.uptimeMillis()));
                            + (TIME_TO_RECONNECT - bindingDuration));
                }
            }
        }