summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author PETER LIANG <peterliang@google.com> 2019-12-05 06:41:31 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-12-05 06:41:31 +0000
commit35fc4484fb6d970eb564070af619cd277e4e4132 (patch)
tree2b46c4c6698b2b24066eeb284241d12648740ab7
parent1e7dc81c592576ef07ea33f715090babdf3c8b3d (diff)
parentd4d499cc997077b44e2a7a59d544783a21219c25 (diff)
Merge "Support the rich content for accessibility service (2/n)"
-rw-r--r--api/current.txt4
-rw-r--r--core/java/android/accessibilityservice/AccessibilityServiceInfo.java72
-rw-r--r--core/res/res/values/attrs.xml8
-rw-r--r--core/res/res/values/public.xml2
4 files changed, 86 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index a0e80c7dcffb..f8b3bac8589e 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -299,6 +299,7 @@ package android {
field public static final int animateFirstView = 16843477; // 0x10102d5
field public static final int animateLayoutChanges = 16843506; // 0x10102f2
field public static final int animateOnClick = 16843356; // 0x101025c
+ field public static final int animatedImageDrawable = 16844298; // 0x101060a
field public static final int animation = 16843213; // 0x10101cd
field public static final int animationCache = 16842989; // 0x10100ed
field public static final int animationDuration = 16843026; // 0x1010112
@@ -723,6 +724,7 @@ package android {
field public static final int host = 16842792; // 0x1010028
field public static final int hotSpotX = 16844055; // 0x1010517
field public static final int hotSpotY = 16844056; // 0x1010518
+ field public static final int htmlDescription = 16844299; // 0x101060b
field public static final int hyphenationFrequency = 16843998; // 0x10104de
field public static final int icon = 16842754; // 0x1010002
field @Deprecated public static final int iconPreview = 16843337; // 0x1010249
@@ -2926,6 +2928,7 @@ package android.accessibilityservice {
method public int describeContents();
method public static String feedbackTypeToString(int);
method public static String flagToString(int);
+ method public int getAnimatedImageRes();
method @Deprecated public boolean getCanRetrieveWindowContent();
method public int getCapabilities();
method @Deprecated public String getDescription();
@@ -2935,6 +2938,7 @@ package android.accessibilityservice {
method public android.content.pm.ResolveInfo getResolveInfo();
method public String getSettingsActivityName();
method public String loadDescription(android.content.pm.PackageManager);
+ method @Nullable public String loadHtmlDescription(@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);
diff --git a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
index 3db0b2612c78..7fd01dbf95fb 100644
--- a/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
+++ b/core/java/android/accessibilityservice/AccessibilityServiceInfo.java
@@ -20,6 +20,8 @@ import static android.content.pm.PackageManager.FEATURE_FINGERPRINT;
import android.annotation.IntDef;
import android.annotation.IntRange;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledAfter;
@@ -512,6 +514,21 @@ public class AccessibilityServiceInfo implements Parcelable {
private static final long REQUEST_ACCESSIBILITY_BUTTON_CHANGE = 136293963L;
/**
+ * Resource id of the animated image of the accessibility service.
+ */
+ private int mAnimatedImageRes;
+
+ /**
+ * Resource id of the html description of the accessibility service.
+ */
+ private int mHtmlDescriptionRes;
+
+ /**
+ * Non localized html description of the accessibility service.
+ */
+ private String mNonLocalizedHtmlDescription;
+
+ /**
* Creates a new instance.
*/
public AccessibilityServiceInfo() {
@@ -626,6 +643,20 @@ public class AccessibilityServiceInfo implements Parcelable {
mNonLocalizedSummary = nonLocalizedSummary.toString().trim();
}
}
+ peekedValue = asAttributes.peekValue(
+ com.android.internal.R.styleable.AccessibilityService_animatedImageDrawable);
+ if (peekedValue != null) {
+ mAnimatedImageRes = peekedValue.resourceId;
+ }
+ peekedValue = asAttributes.peekValue(
+ com.android.internal.R.styleable.AccessibilityService_htmlDescription);
+ if (peekedValue != null) {
+ mHtmlDescriptionRes = peekedValue.resourceId;
+ final CharSequence nonLocalizedHtmlDescription = peekedValue.coerceToString();
+ if (nonLocalizedHtmlDescription != null) {
+ mNonLocalizedHtmlDescription = nonLocalizedHtmlDescription.toString().trim();
+ }
+ }
asAttributes.recycle();
} catch (NameNotFoundException e) {
throw new XmlPullParserException( "Unable to create context for: "
@@ -727,6 +758,18 @@ public class AccessibilityServiceInfo implements Parcelable {
}
/**
+ * The animated image resource id.
+ * <p>
+ * <strong>Statically set from
+ * {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
+ * </p>
+ * @return The animated image resource id.
+ */
+ public int getAnimatedImageRes() {
+ return mAnimatedImageRes;
+ }
+
+ /**
* Whether this service can retrieve the current window's content.
* <p>
* <strong>Statically set from
@@ -833,6 +876,29 @@ public class AccessibilityServiceInfo implements Parcelable {
}
/**
+ * The localized html description of the accessibility service.
+ * <p>
+ * <strong>Statically set from
+ * {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
+ * </p>
+ * @return The localized html description.
+ */
+ @Nullable
+ public String loadHtmlDescription(@NonNull PackageManager packageManager) {
+ if (mHtmlDescriptionRes == 0) {
+ return mNonLocalizedHtmlDescription;
+ }
+
+ final ServiceInfo serviceInfo = mResolveInfo.serviceInfo;
+ final CharSequence htmlDescription = packageManager.getText(serviceInfo.packageName,
+ mHtmlDescriptionRes, serviceInfo.applicationInfo);
+ if (htmlDescription != null) {
+ return htmlDescription.toString().trim();
+ }
+ return null;
+ }
+
+ /**
* Set the recommended time that non-interactive controls need to remain on the screen to
* support the user.
* <p>
@@ -915,7 +981,10 @@ public class AccessibilityServiceInfo implements Parcelable {
parcel.writeInt(mSummaryResId);
parcel.writeString(mNonLocalizedSummary);
parcel.writeInt(mDescriptionResId);
+ parcel.writeInt(mAnimatedImageRes);
+ parcel.writeInt(mHtmlDescriptionRes);
parcel.writeString(mNonLocalizedDescription);
+ parcel.writeString(mNonLocalizedHtmlDescription);
}
private void initFromParcel(Parcel parcel) {
@@ -934,7 +1003,10 @@ public class AccessibilityServiceInfo implements Parcelable {
mSummaryResId = parcel.readInt();
mNonLocalizedSummary = parcel.readString();
mDescriptionResId = parcel.readInt();
+ mAnimatedImageRes = parcel.readInt();
+ mHtmlDescriptionRes = parcel.readInt();
mNonLocalizedDescription = parcel.readString();
+ mNonLocalizedHtmlDescription = parcel.readString();
}
@Override
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 234ffee3baa8..38d3e9ccaf6b 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3750,6 +3750,14 @@
</p>
-->
<attr name="canRequestFingerprintGestures" format="boolean" />
+
+ <!-- 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.-->
+ <attr name="htmlDescription" format="string"/>
+
<!-- Short description of the accessibility service purpose or behavior.-->
<attr name="description" />
<!-- Brief summary of the accessibility service purpose or behavior. -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 57e0e1b5c931..78c4efec5b72 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -3002,6 +3002,8 @@
<public name="forceQueryable" />
<!-- @hide @SystemApi -->
<public name="resourcesMap" />
+ <public name="animatedImageDrawable"/>
+ <public name="htmlDescription"/>
</public-group>
<public-group type="drawable" first-id="0x010800b5">