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

Commit 430e1722 authored by Nikolas Havrikov's avatar Nikolas Havrikov
Browse files

Extract updating binding intent

This is a step in a larger refactoring.
This also fixes logging of the unsuccessful intent.

Bug: 205676419
Test: make
Change-Id: I4141939a974064e19009194a19acfd1edea7b3c5
parent 67723bf2
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -2509,15 +2509,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

        unbindCurrentMethodLocked();

        setCurIntent(new Intent(InputMethod.SERVICE_INTERFACE));
        getCurIntent().setComponent(info.getComponent());
        getCurIntent().putExtra(Intent.EXTRA_CLIENT_LABEL,
                com.android.internal.R.string.input_method_binding_label);
        getCurIntent().putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity(
                mContext, 0, new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS),
                PendingIntent.FLAG_IMMUTABLE));
        Intent intent = createImeBindingIntent(info.getComponent());
        setCurIntent(intent);

        if (bindCurrentInputMethodServiceLocked(getCurIntent(), this, mImeConnectionBindFlags)) {
        if (bindCurrentInputMethodServiceLocked(intent, this, mImeConnectionBindFlags)) {
            setLastBindTime(SystemClock.uptimeMillis());
            setHasConnection(true);
            setCurId(info.getId());
@@ -2537,10 +2532,22 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    null, null, getCurId(), getSequenceNumber(), false);
        }
        setCurIntent(null);
        Slog.w(TAG, "Failure connecting to input method service: " + getCurIntent());
        Slog.w(TAG, "Failure connecting to input method service: " + intent);
        return InputBindResult.IME_NOT_CONNECTED;
    }

    @NonNull
    private Intent createImeBindingIntent(ComponentName component) {
        Intent intent = new Intent(InputMethod.SERVICE_INTERFACE);
        intent.setComponent(component);
        intent.putExtra(Intent.EXTRA_CLIENT_LABEL,
                com.android.internal.R.string.input_method_binding_label);
        intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity(
                mContext, 0, new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS),
                PendingIntent.FLAG_IMMUTABLE));
        return intent;
    }

    @FunctionalInterface
    interface ImeDisplayValidator {
        @DisplayImePolicy int getDisplayImePolicy(int displayId);