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

Commit f9184d6a authored by menghanli's avatar menghanli
Browse files

Add new intro attributes for accessibility

- Accessibilty service: AccessibilityService_intro
- Accesibility shortcut: AccessibilityShortcutTarget_intro

Bug: 218407448
Test: atest AccessibilityShortcutInfoTest
Change-Id: Ia9977a74e4f60d6ee36e6028ec24d9271656ce40
parent 5ac50a8f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -866,6 +866,7 @@ package android {
    field public static final int installLocation = 16843447; // 0x10102b7
    field public static final int interactiveUiTimeout = 16844181; // 0x1010595
    field public static final int interpolator = 16843073; // 0x1010141
    field public static final int intro;
    field public static final int isAccessibilityTool = 16844353; // 0x1010641
    field public static final int isAlwaysSyncable = 16843571; // 0x1010333
    field public static final int isAsciiCapable = 16843753; // 0x10103e9
@@ -3247,6 +3248,7 @@ package android.accessibilityservice {
    method @Nullable public String getTileServiceClassName();
    method public boolean isAccessibilityTool();
    method public String loadDescription(android.content.pm.PackageManager);
    method @Nullable public CharSequence loadIntro(@NonNull android.content.pm.PackageManager);
    method public CharSequence loadSummary(android.content.pm.PackageManager);
    method public void setInteractiveUiTimeoutMillis(@IntRange(from=0) int);
    method public void setNonInteractiveUiTimeoutMillis(@IntRange(from=0) int);
+35 −0
Original line number Diff line number Diff line
@@ -568,6 +568,11 @@ public class AccessibilityServiceInfo implements Parcelable {
     */
    private String mNonLocalizedSummary;

    /**
     * Resource id of the intro of the accessibility service.
     */
    private int mIntroResId;

    /**
     * Resource id of the description of the accessibility service.
     */
@@ -737,6 +742,11 @@ public class AccessibilityServiceInfo implements Parcelable {
                    R.styleable.AccessibilityService_isAccessibilityTool, false);
            mTileServiceClassName = asAttributes.getString(
                    com.android.internal.R.styleable.AccessibilityService_tileService);
            peekedValue = asAttributes.peekValue(
                    com.android.internal.R.styleable.AccessibilityService_intro);
            if (peekedValue != null) {
                mIntroResId = peekedValue.resourceId;
            }
            asAttributes.recycle();
        } catch (NameNotFoundException e) {
            throw new XmlPullParserException( "Unable to create context for: "
@@ -956,6 +966,29 @@ public class AccessibilityServiceInfo implements Parcelable {
        return null;
    }

    /**
     * The localized intro of the accessibility service.
     * <p>
     *    <strong>Statically set from
     *    {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
     * </p>
     * @return The localized intro if available, and {@code null} if a intro
     * has not been provided.
     */
    @Nullable
    public CharSequence loadIntro(@NonNull PackageManager packageManager) {
        if (mIntroResId == /* invalid */ 0) {
            return null;
        }
        ServiceInfo serviceInfo = mResolveInfo.serviceInfo;
        CharSequence intro = packageManager.getText(serviceInfo.packageName,
                mIntroResId, serviceInfo.applicationInfo);
        if (intro != null) {
            return intro.toString().trim();
        }
        return null;
    }

    /**
     * Gets the non-localized description of the accessibility service.
     * <p>
@@ -1114,6 +1147,7 @@ public class AccessibilityServiceInfo implements Parcelable {
        parcel.writeString(mNonLocalizedDescription);
        parcel.writeBoolean(mIsAccessibilityTool);
        parcel.writeString(mTileServiceClassName);
        parcel.writeInt(mIntroResId);
    }

    private void initFromParcel(Parcel parcel) {
@@ -1137,6 +1171,7 @@ public class AccessibilityServiceInfo implements Parcelable {
        mNonLocalizedDescription = parcel.readString();
        mIsAccessibilityTool = parcel.readBoolean();
        mTileServiceClassName = parcel.readString();
        mIntroResId = parcel.readInt();
    }

    @Override
+18 −0
Original line number Diff line number Diff line
@@ -69,6 +69,11 @@ public final class AccessibilityShortcutInfo {
     */
    private final ActivityInfo mActivityInfo;

    /**
     * Resource id of the intro of the accessibility shortcut target.
     */
    private final int mIntroResId;

    /**
     * Resource id of the summary of the accessibility shortcut target.
     */
@@ -160,6 +165,9 @@ public final class AccessibilityShortcutInfo {
            // Get tile service class name
            mTileServiceClassName = asAttributes.getString(
                    com.android.internal.R.styleable.AccessibilityShortcutTarget_tileService);
            // Gets intro
            mIntroResId = asAttributes.getResourceId(
                    com.android.internal.R.styleable.AccessibilityShortcutTarget_intro, 0);
            asAttributes.recycle();

            if ((mDescriptionResId == 0 && mHtmlDescriptionRes == 0) || mSummaryResId == 0) {
@@ -202,6 +210,16 @@ public final class AccessibilityShortcutInfo {
        return loadResourceString(packageManager, mActivityInfo, mSummaryResId);
    }

    /**
     * The localized intro of the accessibility shortcut target.
     *
     * @return The localized intro.
     */
    @Nullable
    public String loadIntro(@NonNull PackageManager packageManager) {
        return loadResourceString(packageManager, mActivityInfo, mIntroResId);
    }

    /**
     * The localized description of the accessibility shortcut target.
     *
+13 −8
Original line number Diff line number Diff line
@@ -3991,29 +3991,32 @@
        <!-- Animated image of the accessibility service purpose or behavior, to help users
             understand how the service can help them. -->
        <attr name="animatedImageDrawable" format="reference"/>
        <!-- Html description of the accessibility service, to help users understand
             how the service can help them.-->
        <!-- Html description of the accessibility service usage, availability, or limitations (e.g.
             isn't supported by all apps). -->
        <attr name="htmlDescription" format="reference"/>
        <!-- Short description of the accessibility service purpose or behavior.-->
        <!-- Description of the accessibility service usage, availability, or limitations (e.g.
             isn't supported by all apps). -->
        <attr name="description" />
        <!-- Brief summary of the accessibility service purpose or behavior. -->
        <attr name="summary" />
        <!-- Detailed intro of the accessibility service purpose or behavior. -->
        <attr name="intro" format="reference" />
    </declare-styleable>
    <!-- Use <code>accessibility-shortcut-target</code> as the root tag of the XML resource that
         describes an activity, which is referenced from the
         <code>android.accessibilityshortcut.target</code> meta-data entry. -->
    <declare-styleable name="AccessibilityShortcutTarget">
        <!-- Short description of the target of accessibility shortcut purpose or behavior.-->
        <!-- Description of the target of accessibility shortcut usage, availability, or limitations
             (e.g. isn't supported by all apps). -->
        <attr name="description" />
        <!-- Brief summary of the target of accessibility shortcut purpose or behavior. -->
        <attr name="summary" />
        <!-- Animated image of the target of accessibility shortcut purpose or behavior, to help
             users understand how the target of accessibility shortcut can help them.-->
        <attr name="animatedImageDrawable" format="reference"/>
        <!-- Html description of the target of accessibility shortcut purpose or behavior, to help
             users understand how the target of accessibility shortcut can help them. -->
        <!-- Html description of the target of accessibility shortcut usage, availability, or
             limitations (e.g. isn't supported by all apps). -->
        <attr name="htmlDescription" format="reference"/>
        <!-- Component name of an activity that allows the user to modify the settings for this
             target of accessibility shortcut. -->
@@ -4023,6 +4026,8 @@
             settings to remind users this accessibility service has a
             {@link android.service.quicksettings.TileService}. -->
        <attr name="tileService" format="string" />
        <!-- Detailed intro of the target of accessibility shortcut purpose or behavior. -->
        <attr name="intro" format="reference" />
    </declare-styleable>
    <!-- Use <code>print-service</code> as the root tag of the XML resource that
+1 −0
Original line number Diff line number Diff line
@@ -3278,6 +3278,7 @@
    <public name="windowSplashScreenBehavior" />
    <public name="allowUntrustedActivityEmbedding" />
    <public name="knownActivityEmbeddingCerts" />
    <public name="intro" />
  </staging-public-group>

  <staging-public-group type="id" first-id="0x01de0000">
Loading