Revise the modifier and naming of public APIs for allow rich content.
Change "int getAnimatedImageRes()" to "Drawable loadAnimatedImage(PackageManager packageManager)" Bug: 142532186 Test: atest AccessibilityShortcutInfoTest & manual test Change-Id: I2583a5c2427449bca68af29a0a40215dd0cb9085
This commit is contained in:
@@ -2979,7 +2979,6 @@ 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();
|
||||
@@ -2988,6 +2987,7 @@ package android.accessibilityservice {
|
||||
method public int getNonInteractiveUiTimeoutMillis();
|
||||
method public android.content.pm.ResolveInfo getResolveInfo();
|
||||
method public String getSettingsActivityName();
|
||||
method @Nullable public android.graphics.drawable.Drawable loadAnimatedImage(@NonNull android.content.pm.PackageManager);
|
||||
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);
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.compat.annotation.EnabledAfter;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
@@ -34,6 +35,7 @@ import android.content.pm.ServiceInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
@@ -786,11 +788,32 @@ public class AccessibilityServiceInfo implements Parcelable {
|
||||
* {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
|
||||
* </p>
|
||||
* @return The animated image resource id.
|
||||
* @hide
|
||||
*/
|
||||
public int getAnimatedImageRes() {
|
||||
return mAnimatedImageRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The animated image drawable.
|
||||
* <p>
|
||||
* <strong>Statically set from
|
||||
* {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
|
||||
* </p>
|
||||
* @return The animated image drawable.
|
||||
*/
|
||||
@Nullable
|
||||
public Drawable loadAnimatedImage(@NonNull PackageManager packageManager) {
|
||||
if (mAnimatedImageRes == /* invalid */ 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String packageName = mComponentName.getPackageName();
|
||||
final ApplicationInfo applicationInfo = mResolveInfo.serviceInfo.applicationInfo;
|
||||
|
||||
return packageManager.getDrawable(packageName, mAnimatedImageRes, applicationInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this service can retrieve the current window's content.
|
||||
* <p>
|
||||
|
||||
@@ -22,10 +22,12 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Xml;
|
||||
|
||||
@@ -193,11 +195,30 @@ public final class AccessibilityShortcutInfo {
|
||||
* The animated image resource id of the accessibility shortcut target.
|
||||
*
|
||||
* @return The animated image resource id.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public int getAnimatedImageRes() {
|
||||
return mAnimatedImageRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The animated image drawable of the accessibility shortcut target.
|
||||
*
|
||||
* @return The animated image drawable.
|
||||
*/
|
||||
@Nullable
|
||||
public Drawable loadAnimatedImage(@NonNull PackageManager packageManager) {
|
||||
if (mAnimatedImageRes == /* invalid */ 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String packageName = mComponentName.getPackageName();
|
||||
final ApplicationInfo applicationInfo = mActivityInfo.applicationInfo;
|
||||
|
||||
return packageManager.getDrawable(packageName, mAnimatedImageRes, applicationInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* The localized html description of the accessibility shortcut target.
|
||||
*
|
||||
|
||||
@@ -89,6 +89,12 @@ public class AccessibilityShortcutInfoTest {
|
||||
mShortcutInfo.getAnimatedImageRes(), is(R.drawable.bitmap_drawable));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadAnimatedImage() {
|
||||
assertNotNull("Can't find animated image",
|
||||
mShortcutInfo.loadAnimatedImage(mPackageManager));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHtmlDescription() {
|
||||
final String htmlDescription = mTargetContext.getResources()
|
||||
|
||||
Reference in New Issue
Block a user