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

Commit 6307641d authored by Taran Singh's avatar Taran Singh
Browse files

Scribe in IMF: Handwriting support API 1/N

Introduce new API for declaring Scribe support in IMEs.

CTS-Coverage-Bug: 210917621
Bug: 203086136

Change-Id: Ie012d865d58e6d41fe6ab6de479dd6ed86e6106c
parent 8d7fb9d8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1420,6 +1420,7 @@ package android {
    field public static final int supportsMultipleDisplays = 16844182; // 0x1010596
    field public static final int supportsPictureInPicture = 16844023; // 0x10104f7
    field public static final int supportsRtl = 16843695; // 0x10103af
    field public static final int supportsStylusHandwriting;
    field public static final int supportsSwitchingToNextInputMethod = 16843755; // 0x10103eb
    field public static final int supportsUploading = 16843419; // 0x101029b
    field public static final int suppressesSpellChecker = 16844355; // 0x1010643
@@ -52832,6 +52833,7 @@ package android.view.inputmethod {
    method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
    method public CharSequence loadLabel(android.content.pm.PackageManager);
    method public boolean shouldShowInInputMethodPicker();
    method public boolean supportsStylusHandwriting();
    method public boolean suppressesSpellChecker();
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.InputMethodInfo> CREATOR;
+28 −6
Original line number Diff line number Diff line
@@ -140,6 +140,12 @@ public final class InputMethodInfo implements Parcelable {
     */
    private final int mHandledConfigChanges;

    /**
     * The flag whether this IME supports Handwriting using stylus input.
     */
    private final boolean mSupportsStylusHandwriting;


    /**
     * @param service the {@link ResolveInfo} corresponds in which the IME is implemented.
     * @return a unique ID to be returned by {@link #getId()}. We have used
@@ -234,6 +240,8 @@ public final class InputMethodInfo implements Parcelable {
                    com.android.internal.R.styleable.InputMethod_showInInputMethodPicker, true);
            mHandledConfigChanges = sa.getInt(
                    com.android.internal.R.styleable.InputMethod_configChanges, 0);
            mSupportsStylusHandwriting = sa.getBoolean(
                    com.android.internal.R.styleable.InputMethod_supportsStylusHandwriting, false);
            sa.recycle();

            final int depth = parser.getDepth();
@@ -323,6 +331,7 @@ public final class InputMethodInfo implements Parcelable {
        mService = ResolveInfo.CREATOR.createFromParcel(source);
        mSubtypes = new InputMethodSubtypeArray(source);
        mHandledConfigChanges = source.readInt();
        mSupportsStylusHandwriting = source.readBoolean();
        mForceDefault = false;
    }

@@ -335,7 +344,7 @@ public final class InputMethodInfo implements Parcelable {
                settingsActivity, null /* subtypes */, 0 /* isDefaultResId */,
                false /* forceDefault */, true /* supportsSwitchingToNextInputMethod */,
                false /* inlineSuggestionsEnabled */, false /* isVrOnly */,
                0 /* handledConfigChanges */);
                0 /* handledConfigChanges */, false /* supportsStylusHandwriting */);
    }

    /**
@@ -349,7 +358,8 @@ public final class InputMethodInfo implements Parcelable {
        this(buildFakeResolveInfo(packageName, className, label), false /* isAuxIme */,
                settingsActivity, null /* subtypes */, 0 /* isDefaultResId */,
                false /* forceDefault */, true /* supportsSwitchingToNextInputMethod */,
                false /* inlineSuggestionsEnabled */, false /* isVrOnly */, handledConfigChanges);
                false /* inlineSuggestionsEnabled */, false /* isVrOnly */, handledConfigChanges,
                false /* supportsStylusHandwriting */);
    }

    /**
@@ -361,7 +371,8 @@ public final class InputMethodInfo implements Parcelable {
            boolean forceDefault) {
        this(ri, isAuxIme, settingsActivity, subtypes, isDefaultResId, forceDefault,
                true /* supportsSwitchingToNextInputMethod */, false /* inlineSuggestionsEnabled */,
                false /* isVrOnly */, 0 /* handledconfigChanges */);
                false /* isVrOnly */, 0 /* handledconfigChanges */,
                false /* supportsStylusHandwriting */);
    }

    /**
@@ -373,7 +384,7 @@ public final class InputMethodInfo implements Parcelable {
            boolean supportsSwitchingToNextInputMethod, boolean isVrOnly) {
        this(ri, isAuxIme, settingsActivity, subtypes, isDefaultResId, forceDefault,
                supportsSwitchingToNextInputMethod, false /* inlineSuggestionsEnabled */, isVrOnly,
                0 /* handledConfigChanges */);
                0 /* handledConfigChanges */, false /* supportsStylusHandwriting */);
    }

    /**
@@ -383,7 +394,7 @@ public final class InputMethodInfo implements Parcelable {
    public InputMethodInfo(ResolveInfo ri, boolean isAuxIme, String settingsActivity,
            List<InputMethodSubtype> subtypes, int isDefaultResId, boolean forceDefault,
            boolean supportsSwitchingToNextInputMethod, boolean inlineSuggestionsEnabled,
            boolean isVrOnly, int handledConfigChanges) {
            boolean isVrOnly, int handledConfigChanges, boolean supportsStylusHandwriting) {
        final ServiceInfo si = ri.serviceInfo;
        mService = ri;
        mId = new ComponentName(si.packageName, si.name).flattenToShortString();
@@ -398,6 +409,7 @@ public final class InputMethodInfo implements Parcelable {
        mShowInInputMethodPicker = true;
        mIsVrOnly = isVrOnly;
        mHandledConfigChanges = handledConfigChanges;
        mSupportsStylusHandwriting = supportsStylusHandwriting;
    }

    private static ResolveInfo buildFakeResolveInfo(String packageName, String className,
@@ -556,6 +568,14 @@ public final class InputMethodInfo implements Parcelable {
        return mHandledConfigChanges;
    }

    /**
     * Returns if IME supports handwriting using stylus input.
     * @attr ref android.R.styleable#InputMethod_supportsStylusHandwriting
     */
    public boolean supportsStylusHandwriting() {
        return mSupportsStylusHandwriting;
    }

    public void dump(Printer pw, String prefix) {
        pw.println(prefix + "mId=" + mId
                + " mSettingsActivityName=" + mSettingsActivityName
@@ -563,7 +583,8 @@ public final class InputMethodInfo implements Parcelable {
                + " mSupportsSwitchingToNextInputMethod=" + mSupportsSwitchingToNextInputMethod
                + " mInlineSuggestionsEnabled=" + mInlineSuggestionsEnabled
                + " mSuppressesSpellChecker=" + mSuppressesSpellChecker
                + " mShowInInputMethodPicker=" + mShowInInputMethodPicker);
                + " mShowInInputMethodPicker=" + mShowInInputMethodPicker
                + " mSupportsStylusHandwriting=" + mSupportsStylusHandwriting);
        pw.println(prefix + "mIsDefaultResId=0x"
                + Integer.toHexString(mIsDefaultResId));
        pw.println(prefix + "Service:");
@@ -667,6 +688,7 @@ public final class InputMethodInfo implements Parcelable {
        mService.writeToParcel(dest, flags);
        mSubtypes.writeToParcel(dest);
        dest.writeInt(mHandledConfigChanges);
        dest.writeBoolean(mSupportsStylusHandwriting);
    }

    /**
+3 −0
Original line number Diff line number Diff line
@@ -3638,6 +3638,9 @@
             to re-retrieve all resources (including view layouts, drawables, etc)
             to correctly handle any configuration change.-->
        <attr name="configChanges" />
        <!-- Specifies whether the IME supports Handwriting using stylus. Defaults to false. -->
        <attr name="supportsStylusHandwriting" format="boolean" />
    </declare-styleable>
    <!-- This is the subtype of InputMethod. Subtype can describe locales (for example, en_US and
+1 −0
Original line number Diff line number Diff line
@@ -3249,6 +3249,7 @@
    <public name="canDisplayOnRemoteDevices" />
    <public name="supportedTypes" />
    <public name="resetEnabledSettingsOnAppDataCleared" />
    <public name="supportsStylusHandwriting" />
  </staging-public-group>

  <staging-public-group type="id" first-id="0x01de0000">
+5 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ final class InputMethodBindingController {
    private IBinder mCurToken;
    private int mCurSeq;
    private boolean mVisibleBound;
    private boolean mSupportsStylusHw;

    /**
     * Binding flags for establishing connection to the {@link InputMethodService}.
@@ -295,6 +296,10 @@ final class InputMethodBindingController {
                    mService.scheduleNotifyImeUidToAudioService(mCurMethodUid);
                    mService.reRequestCurrentClientSessionLocked();
                }
                mSupportsStylusHw = mMethodMap.get(mSelectedMethodId).supportsStylusHandwriting();
                if (mSupportsStylusHw) {
                    // TODO init Handwriting spy.
                }
            }
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        }