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

Commit b360b995 authored by Tarandeep Singh's avatar Tarandeep Singh
Browse files

Add new SystemApi InputMethod attr isVrOnly.

In order to support VR-only InputMethod, new attribute 'isVrOnly' is
added.

Bug: 63037786
Test: atest InputMethodInfoTest
Change-Id: Iab936df9972212f56277ef9c18d9e1f67f92a913
parent 1523386d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ package android {
  }

  public static final class R.attr {
    field public static final int isVrOnly = 16844152; // 0x1010578
    field public static final int requiredSystemPropertyName = 16844133; // 0x1010565
    field public static final int requiredSystemPropertyValue = 16844134; // 0x1010566
    field public static final int searchKeyphrase = 16843871; // 0x101045f
+25 −3
Original line number Diff line number Diff line
@@ -66,6 +66,11 @@ public final class InputMethodInfo implements Parcelable {
     */
    final ResolveInfo mService;

    /**
     * IME only supports VR mode.
     */
    final boolean mIsVrOnly;

    /**
     * The unique string Id to identify the input method.  This is generated
     * from the input method component.
@@ -149,6 +154,7 @@ public final class InputMethodInfo implements Parcelable {

        PackageManager pm = context.getPackageManager();
        String settingsActivityComponent = null;
        boolean isVrOnly;
        int isDefaultResId = 0;

        XmlResourceParser parser = null;
@@ -179,6 +185,7 @@ public final class InputMethodInfo implements Parcelable {
                    com.android.internal.R.styleable.InputMethod);
            settingsActivityComponent = sa.getString(
                    com.android.internal.R.styleable.InputMethod_settingsActivity);
            isVrOnly = sa.getBoolean(com.android.internal.R.styleable.InputMethod_isVrOnly, false);
            isDefaultResId = sa.getResourceId(
                    com.android.internal.R.styleable.InputMethod_isDefault, 0);
            supportsSwitchingToNextInputMethod = sa.getBoolean(
@@ -254,6 +261,8 @@ public final class InputMethodInfo implements Parcelable {
        mIsDefaultResId = isDefaultResId;
        mIsAuxIme = isAuxIme;
        mSupportsSwitchingToNextInputMethod = supportsSwitchingToNextInputMethod;
        // TODO(b/68948291): remove this meta-data before release.
        mIsVrOnly = isVrOnly || service.serviceInfo.metaData.getBoolean("isVrOnly", false);
    }

    InputMethodInfo(Parcel source) {
@@ -262,6 +271,7 @@ public final class InputMethodInfo implements Parcelable {
        mIsDefaultResId = source.readInt();
        mIsAuxIme = source.readInt() == 1;
        mSupportsSwitchingToNextInputMethod = source.readInt() == 1;
        mIsVrOnly = source.readBoolean();
        mService = ResolveInfo.CREATOR.createFromParcel(source);
        mSubtypes = new InputMethodSubtypeArray(source);
        mForceDefault = false;
@@ -274,7 +284,8 @@ public final class InputMethodInfo implements Parcelable {
            CharSequence label, String settingsActivity) {
        this(buildDummyResolveInfo(packageName, className, label), false /* isAuxIme */,
                settingsActivity, null /* subtypes */, 0 /* isDefaultResId */,
                false /* forceDefault */, true /* supportsSwitchingToNextInputMethod */);
                false /* forceDefault */, true /* supportsSwitchingToNextInputMethod */,
                false /* isVrOnly */);
    }

    /**
@@ -285,7 +296,7 @@ public final class InputMethodInfo implements Parcelable {
            String settingsActivity, List<InputMethodSubtype> subtypes, int isDefaultResId,
            boolean forceDefault) {
        this(ri, isAuxIme, settingsActivity, subtypes, isDefaultResId, forceDefault,
                true /* supportsSwitchingToNextInputMethod */);
                true /* supportsSwitchingToNextInputMethod */, false /* isVrOnly */);
    }

    /**
@@ -294,7 +305,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 supportsSwitchingToNextInputMethod, boolean isVrOnly) {
        final ServiceInfo si = ri.serviceInfo;
        mService = ri;
        mId = new ComponentName(si.packageName, si.name).flattenToShortString();
@@ -304,6 +315,7 @@ public final class InputMethodInfo implements Parcelable {
        mSubtypes = new InputMethodSubtypeArray(subtypes);
        mForceDefault = forceDefault;
        mSupportsSwitchingToNextInputMethod = supportsSwitchingToNextInputMethod;
        mIsVrOnly = isVrOnly;
    }

    private static ResolveInfo buildDummyResolveInfo(String packageName, String className,
@@ -397,6 +409,14 @@ public final class InputMethodInfo implements Parcelable {
        return mSettingsActivityName;
    }

    /**
     * Returns true if IME supports VR mode only.
     * @hide
     */
    public boolean isVrOnly() {
        return mIsVrOnly;
    }

    /**
     * Return the count of the subtypes of Input Method.
     */
@@ -444,6 +464,7 @@ public final class InputMethodInfo implements Parcelable {
    public void dump(Printer pw, String prefix) {
        pw.println(prefix + "mId=" + mId
                + " mSettingsActivityName=" + mSettingsActivityName
                + " mIsVrOnly=" + mIsVrOnly
                + " mSupportsSwitchingToNextInputMethod=" + mSupportsSwitchingToNextInputMethod);
        pw.println(prefix + "mIsDefaultResId=0x"
                + Integer.toHexString(mIsDefaultResId));
@@ -509,6 +530,7 @@ public final class InputMethodInfo implements Parcelable {
        dest.writeInt(mIsDefaultResId);
        dest.writeInt(mIsAuxIme ? 1 : 0);
        dest.writeInt(mSupportsSwitchingToNextInputMethod ? 1 : 0);
        dest.writeBoolean(mIsVrOnly);
        mService.writeToParcel(dest, flags);
        mSubtypes.writeToParcel(dest);
    }
+3 −0
Original line number Diff line number Diff line
@@ -3294,6 +3294,9 @@
             and subtype in order to provide the consistent user experience in switching
             between IMEs and subtypes. -->
        <attr name="supportsSwitchingToNextInputMethod" format="boolean" />
        <!-- Specifies if an IME can only be used while a device is in VR mode or on a dedicated
             device -->
        <attr name="isVrOnly" format="boolean"/>
        <attr name="__removed2" format="boolean" />
    </declare-styleable>

+2 −0
Original line number Diff line number Diff line
@@ -2856,6 +2856,8 @@
      <public name="buttonCornerRadius" />
      <public name="versionCodeMajor" />
      <public name="versionMajor" />
      <!-- @hide @SystemApi -->
      <public name="isVrOnly"/>
    </public-group>

    <public-group type="style" first-id="0x010302e0">
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
    Copyright (C) 2017 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<input-method
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:settingsActivity="com.android.inputmethod.latin.settings.SettingsActivity"
    android:isVrOnly="true">
</input-method>
Loading