Merge "Remove ShortcutManager" into nyc-dev
This commit is contained in:
@@ -8192,7 +8192,6 @@ package android.content {
|
||||
field public static final java.lang.String RESTRICTIONS_SERVICE = "restrictions";
|
||||
field public static final java.lang.String SEARCH_SERVICE = "search";
|
||||
field public static final java.lang.String SENSOR_SERVICE = "sensor";
|
||||
field public static final java.lang.String SHORTCUT_SERVICE = "shortcut";
|
||||
field public static final java.lang.String STORAGE_SERVICE = "storage";
|
||||
field public static final java.lang.String SYSTEM_HEALTH_SERVICE = "systemhealth";
|
||||
field public static final java.lang.String TELECOM_SERVICE = "telecom";
|
||||
@@ -9502,20 +9501,13 @@ package android.content.pm {
|
||||
|
||||
public class LauncherApps {
|
||||
method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
|
||||
method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo);
|
||||
method public android.os.ParcelFileDescriptor getShortcutIconFd(java.lang.String, java.lang.String, android.os.UserHandle);
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getShortcuts(android.content.pm.LauncherApps.ShortcutQuery, android.os.UserHandle);
|
||||
method public boolean hasShortcutHostPermission();
|
||||
method public boolean isActivityEnabled(android.content.ComponentName, android.os.UserHandle);
|
||||
method public boolean isPackageEnabled(java.lang.String, android.os.UserHandle);
|
||||
method public void pinShortcuts(java.lang.String, java.util.List<java.lang.String>, android.os.UserHandle);
|
||||
method public void registerCallback(android.content.pm.LauncherApps.Callback);
|
||||
method public void registerCallback(android.content.pm.LauncherApps.Callback, android.os.Handler);
|
||||
method public android.content.pm.LauncherActivityInfo resolveActivity(android.content.Intent, android.os.UserHandle);
|
||||
method public void startAppDetailsActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
|
||||
method public void startMainActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
|
||||
method public boolean startShortcut(java.lang.String, java.lang.String, android.graphics.Rect, android.os.Bundle, android.os.UserHandle);
|
||||
method public boolean startShortcut(android.content.pm.ShortcutInfo, android.graphics.Rect, android.os.Bundle);
|
||||
method public void unregisterCallback(android.content.pm.LauncherApps.Callback);
|
||||
}
|
||||
|
||||
@@ -9528,19 +9520,6 @@ package android.content.pm {
|
||||
method public void onPackagesSuspended(java.lang.String[], android.os.UserHandle);
|
||||
method public abstract void onPackagesUnavailable(java.lang.String[], android.os.UserHandle, boolean);
|
||||
method public void onPackagesUnsuspended(java.lang.String[], android.os.UserHandle);
|
||||
method public void onShortcutsChanged(java.lang.String, java.util.List<android.content.pm.ShortcutInfo>, android.os.UserHandle);
|
||||
}
|
||||
|
||||
public static class LauncherApps.ShortcutQuery {
|
||||
ctor public LauncherApps.ShortcutQuery();
|
||||
method public void setActivity(android.content.ComponentName);
|
||||
method public void setChangedSince(long);
|
||||
method public void setPackage(java.lang.String);
|
||||
method public void setQueryFlags(int);
|
||||
method public void setShortcutIds(java.util.List<java.lang.String>);
|
||||
field public static final int FLAG_GET_DYNAMIC = 1; // 0x1
|
||||
field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4
|
||||
field public static final int FLAG_GET_PINNED = 2; // 0x2
|
||||
}
|
||||
|
||||
public class PackageInfo implements android.os.Parcelable {
|
||||
@@ -10041,66 +10020,6 @@ package android.content.pm {
|
||||
field public java.lang.String permission;
|
||||
}
|
||||
|
||||
public final class ShortcutInfo implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public android.content.ComponentName getActivityComponent();
|
||||
method public java.util.Set<java.lang.String> getCategories();
|
||||
method public android.os.PersistableBundle getExtras();
|
||||
method public int getIconResourceId();
|
||||
method public java.lang.String getId();
|
||||
method public android.content.Intent getIntent();
|
||||
method public long getLastChangedTimestamp();
|
||||
method public java.lang.String getPackageName();
|
||||
method public java.lang.String getText();
|
||||
method public java.lang.String getTitle();
|
||||
method public android.os.UserHandle getUserHandle();
|
||||
method public int getWeight();
|
||||
method public boolean hasIconFile();
|
||||
method public boolean hasIconResource();
|
||||
method public boolean hasKeyFieldsOnly();
|
||||
method public boolean isDynamic();
|
||||
method public boolean isPinned();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final int CLONE_REMOVE_FOR_CREATOR = 1; // 0x1
|
||||
field public static final int CLONE_REMOVE_FOR_LAUNCHER = 3; // 0x3
|
||||
field public static final int CLONE_REMOVE_NON_KEY_INFO = 4; // 0x4
|
||||
field public static final android.os.Parcelable.Creator<android.content.pm.ShortcutInfo> CREATOR;
|
||||
field public static final int FLAG_DYNAMIC = 1; // 0x1
|
||||
field public static final int FLAG_HAS_ICON_FILE = 8; // 0x8
|
||||
field public static final int FLAG_HAS_ICON_RES = 4; // 0x4
|
||||
field public static final int FLAG_KEY_FIELDS_ONLY = 16; // 0x10
|
||||
field public static final int FLAG_PINNED = 2; // 0x2
|
||||
field public static final java.lang.String SHORTCUT_CATEGORY_CONVERSATION = "android.shortcut.conversation";
|
||||
}
|
||||
|
||||
public static class ShortcutInfo.Builder {
|
||||
ctor public ShortcutInfo.Builder(android.content.Context);
|
||||
method public android.content.pm.ShortcutInfo build();
|
||||
method public android.content.pm.ShortcutInfo.Builder setActivityComponent(android.content.ComponentName);
|
||||
method public android.content.pm.ShortcutInfo.Builder setCategories(java.util.Set<java.lang.String>);
|
||||
method public android.content.pm.ShortcutInfo.Builder setExtras(android.os.PersistableBundle);
|
||||
method public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon);
|
||||
method public android.content.pm.ShortcutInfo.Builder setId(java.lang.String);
|
||||
method public android.content.pm.ShortcutInfo.Builder setIntent(android.content.Intent);
|
||||
method public android.content.pm.ShortcutInfo.Builder setText(java.lang.String);
|
||||
method public android.content.pm.ShortcutInfo.Builder setTitle(java.lang.String);
|
||||
method public android.content.pm.ShortcutInfo.Builder setWeight(int);
|
||||
}
|
||||
|
||||
public class ShortcutManager {
|
||||
method public boolean addDynamicShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getDynamicShortcuts();
|
||||
method public int getIconMaxDimensions();
|
||||
method public int getMaxDynamicShortcutCount();
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getPinnedShortcuts();
|
||||
method public long getRateLimitResetTime();
|
||||
method public int getRemainingCallCount();
|
||||
method public void removeAllDynamicShortcuts();
|
||||
method public void removeDynamicShortcuts(java.util.List<java.lang.String>);
|
||||
method public boolean setDynamicShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
method public boolean updateShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
}
|
||||
|
||||
public class Signature implements android.os.Parcelable {
|
||||
ctor public Signature(byte[]);
|
||||
ctor public Signature(java.lang.String);
|
||||
|
||||
@@ -8514,7 +8514,6 @@ package android.content {
|
||||
field public static final java.lang.String RESTRICTIONS_SERVICE = "restrictions";
|
||||
field public static final java.lang.String SEARCH_SERVICE = "search";
|
||||
field public static final java.lang.String SENSOR_SERVICE = "sensor";
|
||||
field public static final java.lang.String SHORTCUT_SERVICE = "shortcut";
|
||||
field public static final java.lang.String STORAGE_SERVICE = "storage";
|
||||
field public static final java.lang.String SYSTEM_HEALTH_SERVICE = "systemhealth";
|
||||
field public static final java.lang.String TELECOM_SERVICE = "telecom";
|
||||
@@ -9859,20 +9858,13 @@ package android.content.pm {
|
||||
|
||||
public class LauncherApps {
|
||||
method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
|
||||
method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo);
|
||||
method public android.os.ParcelFileDescriptor getShortcutIconFd(java.lang.String, java.lang.String, android.os.UserHandle);
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getShortcuts(android.content.pm.LauncherApps.ShortcutQuery, android.os.UserHandle);
|
||||
method public boolean hasShortcutHostPermission();
|
||||
method public boolean isActivityEnabled(android.content.ComponentName, android.os.UserHandle);
|
||||
method public boolean isPackageEnabled(java.lang.String, android.os.UserHandle);
|
||||
method public void pinShortcuts(java.lang.String, java.util.List<java.lang.String>, android.os.UserHandle);
|
||||
method public void registerCallback(android.content.pm.LauncherApps.Callback);
|
||||
method public void registerCallback(android.content.pm.LauncherApps.Callback, android.os.Handler);
|
||||
method public android.content.pm.LauncherActivityInfo resolveActivity(android.content.Intent, android.os.UserHandle);
|
||||
method public void startAppDetailsActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
|
||||
method public void startMainActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
|
||||
method public boolean startShortcut(java.lang.String, java.lang.String, android.graphics.Rect, android.os.Bundle, android.os.UserHandle);
|
||||
method public boolean startShortcut(android.content.pm.ShortcutInfo, android.graphics.Rect, android.os.Bundle);
|
||||
method public void unregisterCallback(android.content.pm.LauncherApps.Callback);
|
||||
}
|
||||
|
||||
@@ -9885,19 +9877,6 @@ package android.content.pm {
|
||||
method public void onPackagesSuspended(java.lang.String[], android.os.UserHandle);
|
||||
method public abstract void onPackagesUnavailable(java.lang.String[], android.os.UserHandle, boolean);
|
||||
method public void onPackagesUnsuspended(java.lang.String[], android.os.UserHandle);
|
||||
method public void onShortcutsChanged(java.lang.String, java.util.List<android.content.pm.ShortcutInfo>, android.os.UserHandle);
|
||||
}
|
||||
|
||||
public static class LauncherApps.ShortcutQuery {
|
||||
ctor public LauncherApps.ShortcutQuery();
|
||||
method public void setActivity(android.content.ComponentName);
|
||||
method public void setChangedSince(long);
|
||||
method public void setPackage(java.lang.String);
|
||||
method public void setQueryFlags(int);
|
||||
method public void setShortcutIds(java.util.List<java.lang.String>);
|
||||
field public static final int FLAG_GET_DYNAMIC = 1; // 0x1
|
||||
field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4
|
||||
field public static final int FLAG_GET_PINNED = 2; // 0x2
|
||||
}
|
||||
|
||||
public class PackageInfo implements android.os.Parcelable {
|
||||
@@ -10468,66 +10447,6 @@ package android.content.pm {
|
||||
field public java.lang.String permission;
|
||||
}
|
||||
|
||||
public final class ShortcutInfo implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public android.content.ComponentName getActivityComponent();
|
||||
method public java.util.Set<java.lang.String> getCategories();
|
||||
method public android.os.PersistableBundle getExtras();
|
||||
method public int getIconResourceId();
|
||||
method public java.lang.String getId();
|
||||
method public android.content.Intent getIntent();
|
||||
method public long getLastChangedTimestamp();
|
||||
method public java.lang.String getPackageName();
|
||||
method public java.lang.String getText();
|
||||
method public java.lang.String getTitle();
|
||||
method public android.os.UserHandle getUserHandle();
|
||||
method public int getWeight();
|
||||
method public boolean hasIconFile();
|
||||
method public boolean hasIconResource();
|
||||
method public boolean hasKeyFieldsOnly();
|
||||
method public boolean isDynamic();
|
||||
method public boolean isPinned();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final int CLONE_REMOVE_FOR_CREATOR = 1; // 0x1
|
||||
field public static final int CLONE_REMOVE_FOR_LAUNCHER = 3; // 0x3
|
||||
field public static final int CLONE_REMOVE_NON_KEY_INFO = 4; // 0x4
|
||||
field public static final android.os.Parcelable.Creator<android.content.pm.ShortcutInfo> CREATOR;
|
||||
field public static final int FLAG_DYNAMIC = 1; // 0x1
|
||||
field public static final int FLAG_HAS_ICON_FILE = 8; // 0x8
|
||||
field public static final int FLAG_HAS_ICON_RES = 4; // 0x4
|
||||
field public static final int FLAG_KEY_FIELDS_ONLY = 16; // 0x10
|
||||
field public static final int FLAG_PINNED = 2; // 0x2
|
||||
field public static final java.lang.String SHORTCUT_CATEGORY_CONVERSATION = "android.shortcut.conversation";
|
||||
}
|
||||
|
||||
public static class ShortcutInfo.Builder {
|
||||
ctor public ShortcutInfo.Builder(android.content.Context);
|
||||
method public android.content.pm.ShortcutInfo build();
|
||||
method public android.content.pm.ShortcutInfo.Builder setActivityComponent(android.content.ComponentName);
|
||||
method public android.content.pm.ShortcutInfo.Builder setCategories(java.util.Set<java.lang.String>);
|
||||
method public android.content.pm.ShortcutInfo.Builder setExtras(android.os.PersistableBundle);
|
||||
method public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon);
|
||||
method public android.content.pm.ShortcutInfo.Builder setId(java.lang.String);
|
||||
method public android.content.pm.ShortcutInfo.Builder setIntent(android.content.Intent);
|
||||
method public android.content.pm.ShortcutInfo.Builder setText(java.lang.String);
|
||||
method public android.content.pm.ShortcutInfo.Builder setTitle(java.lang.String);
|
||||
method public android.content.pm.ShortcutInfo.Builder setWeight(int);
|
||||
}
|
||||
|
||||
public class ShortcutManager {
|
||||
method public boolean addDynamicShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getDynamicShortcuts();
|
||||
method public int getIconMaxDimensions();
|
||||
method public int getMaxDynamicShortcutCount();
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getPinnedShortcuts();
|
||||
method public long getRateLimitResetTime();
|
||||
method public int getRemainingCallCount();
|
||||
method public void removeAllDynamicShortcuts();
|
||||
method public void removeDynamicShortcuts(java.util.List<java.lang.String>);
|
||||
method public boolean setDynamicShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
method public boolean updateShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
}
|
||||
|
||||
public class Signature implements android.os.Parcelable {
|
||||
ctor public Signature(byte[]);
|
||||
ctor public Signature(java.lang.String);
|
||||
|
||||
@@ -8199,7 +8199,6 @@ package android.content {
|
||||
field public static final java.lang.String RESTRICTIONS_SERVICE = "restrictions";
|
||||
field public static final java.lang.String SEARCH_SERVICE = "search";
|
||||
field public static final java.lang.String SENSOR_SERVICE = "sensor";
|
||||
field public static final java.lang.String SHORTCUT_SERVICE = "shortcut";
|
||||
field public static final java.lang.String STORAGE_SERVICE = "storage";
|
||||
field public static final java.lang.String SYSTEM_HEALTH_SERVICE = "systemhealth";
|
||||
field public static final java.lang.String TELECOM_SERVICE = "telecom";
|
||||
@@ -9513,20 +9512,13 @@ package android.content.pm {
|
||||
public class LauncherApps {
|
||||
ctor public LauncherApps(android.content.Context);
|
||||
method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle);
|
||||
method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo);
|
||||
method public android.os.ParcelFileDescriptor getShortcutIconFd(java.lang.String, java.lang.String, android.os.UserHandle);
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getShortcuts(android.content.pm.LauncherApps.ShortcutQuery, android.os.UserHandle);
|
||||
method public boolean hasShortcutHostPermission();
|
||||
method public boolean isActivityEnabled(android.content.ComponentName, android.os.UserHandle);
|
||||
method public boolean isPackageEnabled(java.lang.String, android.os.UserHandle);
|
||||
method public void pinShortcuts(java.lang.String, java.util.List<java.lang.String>, android.os.UserHandle);
|
||||
method public void registerCallback(android.content.pm.LauncherApps.Callback);
|
||||
method public void registerCallback(android.content.pm.LauncherApps.Callback, android.os.Handler);
|
||||
method public android.content.pm.LauncherActivityInfo resolveActivity(android.content.Intent, android.os.UserHandle);
|
||||
method public void startAppDetailsActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
|
||||
method public void startMainActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
|
||||
method public boolean startShortcut(java.lang.String, java.lang.String, android.graphics.Rect, android.os.Bundle, android.os.UserHandle);
|
||||
method public boolean startShortcut(android.content.pm.ShortcutInfo, android.graphics.Rect, android.os.Bundle);
|
||||
method public void unregisterCallback(android.content.pm.LauncherApps.Callback);
|
||||
}
|
||||
|
||||
@@ -9539,19 +9531,6 @@ package android.content.pm {
|
||||
method public void onPackagesSuspended(java.lang.String[], android.os.UserHandle);
|
||||
method public abstract void onPackagesUnavailable(java.lang.String[], android.os.UserHandle, boolean);
|
||||
method public void onPackagesUnsuspended(java.lang.String[], android.os.UserHandle);
|
||||
method public void onShortcutsChanged(java.lang.String, java.util.List<android.content.pm.ShortcutInfo>, android.os.UserHandle);
|
||||
}
|
||||
|
||||
public static class LauncherApps.ShortcutQuery {
|
||||
ctor public LauncherApps.ShortcutQuery();
|
||||
method public void setActivity(android.content.ComponentName);
|
||||
method public void setChangedSince(long);
|
||||
method public void setPackage(java.lang.String);
|
||||
method public void setQueryFlags(int);
|
||||
method public void setShortcutIds(java.util.List<java.lang.String>);
|
||||
field public static final int FLAG_GET_DYNAMIC = 1; // 0x1
|
||||
field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4
|
||||
field public static final int FLAG_GET_PINNED = 2; // 0x2
|
||||
}
|
||||
|
||||
public class PackageInfo implements android.os.Parcelable {
|
||||
@@ -10053,67 +10032,6 @@ package android.content.pm {
|
||||
field public java.lang.String permission;
|
||||
}
|
||||
|
||||
public final class ShortcutInfo implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public android.content.ComponentName getActivityComponent();
|
||||
method public java.util.Set<java.lang.String> getCategories();
|
||||
method public android.os.PersistableBundle getExtras();
|
||||
method public int getIconResourceId();
|
||||
method public java.lang.String getId();
|
||||
method public android.content.Intent getIntent();
|
||||
method public long getLastChangedTimestamp();
|
||||
method public java.lang.String getPackageName();
|
||||
method public java.lang.String getText();
|
||||
method public java.lang.String getTitle();
|
||||
method public android.os.UserHandle getUserHandle();
|
||||
method public int getWeight();
|
||||
method public boolean hasIconFile();
|
||||
method public boolean hasIconResource();
|
||||
method public boolean hasKeyFieldsOnly();
|
||||
method public boolean isDynamic();
|
||||
method public boolean isPinned();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final int CLONE_REMOVE_FOR_CREATOR = 1; // 0x1
|
||||
field public static final int CLONE_REMOVE_FOR_LAUNCHER = 3; // 0x3
|
||||
field public static final int CLONE_REMOVE_NON_KEY_INFO = 4; // 0x4
|
||||
field public static final android.os.Parcelable.Creator<android.content.pm.ShortcutInfo> CREATOR;
|
||||
field public static final int FLAG_DYNAMIC = 1; // 0x1
|
||||
field public static final int FLAG_HAS_ICON_FILE = 8; // 0x8
|
||||
field public static final int FLAG_HAS_ICON_RES = 4; // 0x4
|
||||
field public static final int FLAG_KEY_FIELDS_ONLY = 16; // 0x10
|
||||
field public static final int FLAG_PINNED = 2; // 0x2
|
||||
field public static final java.lang.String SHORTCUT_CATEGORY_CONVERSATION = "android.shortcut.conversation";
|
||||
}
|
||||
|
||||
public static class ShortcutInfo.Builder {
|
||||
ctor public ShortcutInfo.Builder(android.content.Context);
|
||||
method public android.content.pm.ShortcutInfo build();
|
||||
method public android.content.pm.ShortcutInfo.Builder setActivityComponent(android.content.ComponentName);
|
||||
method public android.content.pm.ShortcutInfo.Builder setCategories(java.util.Set<java.lang.String>);
|
||||
method public android.content.pm.ShortcutInfo.Builder setExtras(android.os.PersistableBundle);
|
||||
method public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon);
|
||||
method public android.content.pm.ShortcutInfo.Builder setId(java.lang.String);
|
||||
method public android.content.pm.ShortcutInfo.Builder setIntent(android.content.Intent);
|
||||
method public android.content.pm.ShortcutInfo.Builder setText(java.lang.String);
|
||||
method public android.content.pm.ShortcutInfo.Builder setTitle(java.lang.String);
|
||||
method public android.content.pm.ShortcutInfo.Builder setWeight(int);
|
||||
}
|
||||
|
||||
public class ShortcutManager {
|
||||
ctor public ShortcutManager(android.content.Context);
|
||||
method public boolean addDynamicShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getDynamicShortcuts();
|
||||
method public int getIconMaxDimensions();
|
||||
method public int getMaxDynamicShortcutCount();
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getPinnedShortcuts();
|
||||
method public long getRateLimitResetTime();
|
||||
method public int getRemainingCallCount();
|
||||
method public void removeAllDynamicShortcuts();
|
||||
method public void removeDynamicShortcuts(java.util.List<java.lang.String>);
|
||||
method public boolean setDynamicShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
method public boolean updateShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
}
|
||||
|
||||
public class Signature implements android.os.Parcelable {
|
||||
ctor public Signature(byte[]);
|
||||
ctor public Signature(java.lang.String);
|
||||
|
||||
@@ -3603,6 +3603,8 @@ public abstract class Context {
|
||||
*
|
||||
* @see #getSystemService
|
||||
* @see android.content.pm.ShortcutManager
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String SHORTCUT_SERVICE = "shortcut";
|
||||
|
||||
|
||||
@@ -166,6 +166,8 @@ public class LauncherApps {
|
||||
* @param shortcuts all shortcuts from the package (dynamic and/or pinned). Only "key"
|
||||
* information will be provided, as defined in {@link ShortcutInfo#hasKeyFieldsOnly()}.
|
||||
* @param user The UserHandle of the profile that generated the change.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void onShortcutsChanged(@NonNull String packageName,
|
||||
@NonNull List<ShortcutInfo> shortcuts, @NonNull UserHandle user) {
|
||||
@@ -174,6 +176,8 @@ public class LauncherApps {
|
||||
|
||||
/**
|
||||
* Represents a query passed to {@link #getShortcuts(ShortcutQuery, UserHandle)}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static class ShortcutQuery {
|
||||
/**
|
||||
@@ -422,6 +426,8 @@ public class LauncherApps {
|
||||
* the user is trying a new launcher application. The user may decide to change the default
|
||||
* launcher to the calling application again, so even if a launcher application loses
|
||||
* this permission, it does <b>not</b> have to purge pinned shortcut information.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public boolean hasShortcutHostPermission() {
|
||||
try {
|
||||
@@ -441,6 +447,8 @@ public class LauncherApps {
|
||||
* @param user The UserHandle of the profile.
|
||||
*
|
||||
* @return the IDs of {@link ShortcutInfo}s that match the query.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Nullable
|
||||
public List<ShortcutInfo> getShortcuts(@NonNull ShortcutQuery query,
|
||||
@@ -480,6 +488,8 @@ public class LauncherApps {
|
||||
* @param packageName The target package name.
|
||||
* @param shortcutIds The IDs of the shortcut to be pinned.
|
||||
* @param user The UserHandle of the profile.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void pinShortcuts(@NonNull String packageName, @NonNull List<String> shortcutIds,
|
||||
@NonNull UserHandle user) {
|
||||
@@ -519,6 +529,8 @@ public class LauncherApps {
|
||||
* #hasShortcutHostPermission()}.
|
||||
*
|
||||
* @param shortcut The target shortcut.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public ParcelFileDescriptor getShortcutIconFd(
|
||||
@NonNull ShortcutInfo shortcut) {
|
||||
@@ -536,6 +548,8 @@ public class LauncherApps {
|
||||
* @param packageName The target package name.
|
||||
* @param shortcutId The ID of the shortcut to lad rom.
|
||||
* @param user The UserHandle of the profile.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public ParcelFileDescriptor getShortcutIconFd(
|
||||
@NonNull String packageName, @NonNull String shortcutId, @NonNull UserHandle user) {
|
||||
@@ -565,6 +579,8 @@ public class LauncherApps {
|
||||
* @param user The UserHandle of the profile.
|
||||
* @return {@code false} when the shortcut is no longer valid (e.g. the creator application
|
||||
* has been uninstalled). {@code true} when the shortcut is still valid.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public boolean startShortcut(@NonNull String packageName, @NonNull String shortcutId,
|
||||
@Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions,
|
||||
@@ -584,6 +600,8 @@ public class LauncherApps {
|
||||
* @param startActivityOptions Options to pass to startActivity.
|
||||
* @return {@code false} when the shortcut is no longer valid (e.g. the creator application
|
||||
* has been uninstalled). {@code true} when the shortcut is still valid.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public boolean startShortcut(@NonNull ShortcutInfo shortcut,
|
||||
@Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions) {
|
||||
|
||||
@@ -50,6 +50,8 @@ import java.util.Set;
|
||||
* </ul>
|
||||
*
|
||||
* @see {@link ShortcutManager}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final class ShortcutInfo implements Parcelable {
|
||||
/* @hide */
|
||||
|
||||
@@ -88,6 +88,8 @@ import java.util.List;
|
||||
* Launcher applications should use {@link LauncherApps} to get shortcuts that are published from
|
||||
* applications. Launcher applications can also pin shortcuts with
|
||||
* {@link LauncherApps#pinShortcuts(String, List, UserHandle)}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class ShortcutManager {
|
||||
private static final String TAG = "ShortcutManager";
|
||||
|
||||
@@ -745,6 +745,9 @@ public class LauncherAppsService extends SystemService {
|
||||
@Override
|
||||
public void onShortcutChanged(@NonNull String packageName,
|
||||
@UserIdInt int userId) {
|
||||
if (!ShortcutService.FEATURE_ENABLED) {
|
||||
return;
|
||||
}
|
||||
postToPackageMonitorHandler(() -> onShortcutChangedInner(packageName, userId));
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,8 @@ import java.util.function.Predicate;
|
||||
public class ShortcutService extends IShortcutService.Stub {
|
||||
static final String TAG = "ShortcutService";
|
||||
|
||||
public static final boolean FEATURE_ENABLED = false;
|
||||
|
||||
static final boolean DEBUG = false; // STOPSHIP if true
|
||||
static final boolean DEBUG_LOAD = false; // STOPSHIP if true
|
||||
static final boolean DEBUG_PROCSTATE = false; // STOPSHIP if true
|
||||
@@ -319,6 +321,9 @@ public class ShortcutService extends IShortcutService.Stub {
|
||||
mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
|
||||
if (!FEATURE_ENABLED) {
|
||||
return;
|
||||
}
|
||||
mPackageMonitor.register(context, looper, UserHandle.ALL, /* externalStorage= */ false);
|
||||
|
||||
injectRegisterUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE
|
||||
@@ -419,6 +424,7 @@ public class ShortcutService extends IShortcutService.Stub {
|
||||
|
||||
/** lifecycle event */
|
||||
void onBootPhase(int phase) {
|
||||
// We want to call initialize() to initialize the configurations, so we don't disable this.
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "onBootPhase: " + phase);
|
||||
}
|
||||
@@ -431,6 +437,9 @@ public class ShortcutService extends IShortcutService.Stub {
|
||||
|
||||
/** lifecycle event */
|
||||
void handleUnlockUser(int userId) {
|
||||
if (!FEATURE_ENABLED) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
// Preload
|
||||
getUserShortcutsLocked(userId);
|
||||
@@ -441,6 +450,9 @@ public class ShortcutService extends IShortcutService.Stub {
|
||||
|
||||
/** lifecycle event */
|
||||
void handleCleanupUser(int userId) {
|
||||
if (!FEATURE_ENABLED) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
unloadUserLocked(userId);
|
||||
}
|
||||
@@ -1926,6 +1938,9 @@ public class ShortcutService extends IShortcutService.Stub {
|
||||
*/
|
||||
@Override
|
||||
public void onSystemLocaleChangedNoLock() {
|
||||
if (!FEATURE_ENABLED) {
|
||||
return;
|
||||
}
|
||||
// DO NOT HOLD ANY LOCKS HERE.
|
||||
|
||||
// We want to reset throttling for all packages for all users. But we can't just do so
|
||||
@@ -1938,7 +1953,6 @@ public class ShortcutService extends IShortcutService.Stub {
|
||||
//
|
||||
// This allows ShortcutUser's to detect the system locale change, so they can reset
|
||||
// counters.
|
||||
|
||||
mLocaleChangeSequenceNumber.incrementAndGet();
|
||||
postToHandler(() -> scheduleSaveBaseState());
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
easymocklib \
|
||||
guava \
|
||||
android-support-test \
|
||||
mockito-target \
|
||||
ShortcutManagerTestUtils
|
||||
mockito-target
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := android.test.runner
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,31 +0,0 @@
|
||||
# Copyright (C) 2016 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.
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(call all-java-files-under, src)
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
mockito-target
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_MODULE := ShortcutManagerTestUtils
|
||||
|
||||
LOCAL_SDK_VERSION := current
|
||||
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
@@ -1,516 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
package com.android.server.pm.shortcutmanagertest;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyList;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.BaseBundle;
|
||||
import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.UserHandle;
|
||||
import android.test.MoreAsserts;
|
||||
import android.util.Log;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ShortcutManagerTestUtils {
|
||||
private static final String TAG = "ShortcutManagerUtils";
|
||||
|
||||
private static final boolean ENABLE_DUMPSYS = true; // DO NOT SUBMIT WITH true
|
||||
|
||||
private static final int STANDARD_TIMEOUT_SEC = 5;
|
||||
|
||||
private ShortcutManagerTestUtils() {
|
||||
}
|
||||
|
||||
private static List<String> readAll(ParcelFileDescriptor pfd) {
|
||||
try {
|
||||
try {
|
||||
final ArrayList<String> ret = new ArrayList<>();
|
||||
try (BufferedReader r = new BufferedReader(
|
||||
new FileReader(pfd.getFileDescriptor()))) {
|
||||
String line;
|
||||
while ((line = r.readLine()) != null) {
|
||||
ret.add(line);
|
||||
}
|
||||
r.readLine();
|
||||
}
|
||||
return ret;
|
||||
} finally {
|
||||
pfd.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String concatResult(List<String> result) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (String s : result) {
|
||||
sb.append(s);
|
||||
sb.append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static List<String> runCommand(Instrumentation instrumentation, String command) {
|
||||
return runCommand(instrumentation, command, null);
|
||||
}
|
||||
private static List<String> runCommand(Instrumentation instrumentation, String command,
|
||||
Predicate<List<String>> resultAsserter) {
|
||||
Log.d(TAG, "Running command: " + command);
|
||||
final List<String> result;
|
||||
try {
|
||||
result = readAll(
|
||||
instrumentation.getUiAutomation().executeShellCommand(command));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (resultAsserter != null && !resultAsserter.test(result)) {
|
||||
fail("Command '" + command + "' failed, output was:\n" + concatResult(result));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void runCommandForNoOutput(Instrumentation instrumentation, String command) {
|
||||
runCommand(instrumentation, command, result -> result.size() == 0);
|
||||
}
|
||||
|
||||
private static List<String> runShortcutCommand(Instrumentation instrumentation, String command,
|
||||
Predicate<List<String>> resultAsserter) {
|
||||
return runCommand(instrumentation, "cmd shortcut " + command, resultAsserter);
|
||||
}
|
||||
|
||||
public static List<String> runShortcutCommandForSuccess(Instrumentation instrumentation,
|
||||
String command) {
|
||||
return runShortcutCommand(instrumentation, command, result -> result.contains("Success"));
|
||||
}
|
||||
|
||||
public static String getDefaultLauncher(Instrumentation instrumentation) {
|
||||
final String PREFIX = "Launcher: ComponentInfo{";
|
||||
final String POSTFIX = "}";
|
||||
final List<String> result = runShortcutCommandForSuccess(
|
||||
instrumentation, "get-default-launcher");
|
||||
for (String s : result) {
|
||||
if (s.startsWith(PREFIX) && s.endsWith(POSTFIX)) {
|
||||
return s.substring(PREFIX.length(), s.length() - POSTFIX.length());
|
||||
}
|
||||
}
|
||||
fail("Default launcher not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setDefaultLauncher(Instrumentation instrumentation, String component) {
|
||||
runCommandForNoOutput(instrumentation, "cmd package set-home-activity " + component);
|
||||
}
|
||||
|
||||
public static void setDefaultLauncher(Instrumentation instrumentation, Context packageContext) {
|
||||
setDefaultLauncher(instrumentation, packageContext.getPackageName()
|
||||
+ "/android.content.pm.cts.shortcutmanager.packages.Launcher");
|
||||
}
|
||||
|
||||
public static void overrideConfig(Instrumentation instrumentation, String config) {
|
||||
runShortcutCommandForSuccess(instrumentation, "override-config " + config);
|
||||
}
|
||||
|
||||
public static void resetConfig(Instrumentation instrumentation) {
|
||||
runShortcutCommandForSuccess(instrumentation, "reset-config");
|
||||
}
|
||||
|
||||
public static void resetThrottling(Instrumentation instrumentation) {
|
||||
runShortcutCommandForSuccess(instrumentation, "reset-throttling");
|
||||
}
|
||||
|
||||
public static void resetAllThrottling(Instrumentation instrumentation) {
|
||||
runShortcutCommandForSuccess(instrumentation, "reset-all-throttling");
|
||||
}
|
||||
|
||||
public static void clearShortcuts(Instrumentation instrumentation, int userId,
|
||||
String packageName) {
|
||||
runShortcutCommandForSuccess(instrumentation, "clear-shortcuts "
|
||||
+ " --user " + userId + " " + packageName);
|
||||
}
|
||||
|
||||
public static void dumpsysShortcut(Instrumentation instrumentation) {
|
||||
if (!ENABLE_DUMPSYS) {
|
||||
return;
|
||||
}
|
||||
for (String s : runCommand(instrumentation, "dumpsys shortcut")) {
|
||||
Log.e(TAG, s);
|
||||
}
|
||||
}
|
||||
|
||||
public static Bundle makeBundle(Object... keysAndValues) {
|
||||
assertTrue((keysAndValues.length % 2) == 0);
|
||||
|
||||
if (keysAndValues.length == 0) {
|
||||
return null;
|
||||
}
|
||||
final Bundle ret = new Bundle();
|
||||
|
||||
for (int i = keysAndValues.length - 2; i >= 0; i -= 2) {
|
||||
final String key = keysAndValues[i].toString();
|
||||
final Object value = keysAndValues[i + 1];
|
||||
|
||||
if (value == null) {
|
||||
ret.putString(key, null);
|
||||
} else if (value instanceof Integer) {
|
||||
ret.putInt(key, (Integer) value);
|
||||
} else if (value instanceof String) {
|
||||
ret.putString(key, (String) value);
|
||||
} else if (value instanceof Bundle) {
|
||||
ret.putBundle(key, (Bundle) value);
|
||||
} else {
|
||||
fail("Type not supported yet: " + value.getClass().getName());
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static <T> List<T> list(T... array) {
|
||||
return Arrays.asList(array);
|
||||
}
|
||||
|
||||
public static <T> Set<T> hashSet(Set<T> in) {
|
||||
return new HashSet<T>(in);
|
||||
}
|
||||
|
||||
public static <T> Set<T> set(T... values) {
|
||||
return set(v -> v, values);
|
||||
}
|
||||
|
||||
public static <T, V> Set<T> set(Function<V, T> converter, V... values) {
|
||||
return set(converter, Arrays.asList(values));
|
||||
}
|
||||
|
||||
public static <T, V> Set<T> set(Function<V, T> converter, List<V> values) {
|
||||
final HashSet<T> ret = new HashSet<>();
|
||||
for (V v : values) {
|
||||
ret.add(converter.apply(v));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void resetAll(Collection<?> mocks) {
|
||||
for (Object o : mocks) {
|
||||
reset(o);
|
||||
}
|
||||
}
|
||||
public static void assertExpectException(Class<? extends Throwable> expectedExceptionType,
|
||||
String expectedExceptionMessageRegex, Runnable r) {
|
||||
assertExpectException("", expectedExceptionType, expectedExceptionMessageRegex, r);
|
||||
}
|
||||
|
||||
public static void assertDynamicShortcutCountExceeded(Runnable r) {
|
||||
assertExpectException(IllegalArgumentException.class,
|
||||
"Max number of dynamic shortcuts exceeded", r);
|
||||
}
|
||||
|
||||
public static void assertExpectException(String message,
|
||||
Class<? extends Throwable> expectedExceptionType,
|
||||
String expectedExceptionMessageRegex, Runnable r) {
|
||||
try {
|
||||
r.run();
|
||||
Assert.fail("Expected exception type " + expectedExceptionType.getName()
|
||||
+ " was not thrown (message=" + message + ")");
|
||||
} catch (Throwable e) {
|
||||
Assert.assertTrue(
|
||||
"Expected exception type was " + expectedExceptionType.getName()
|
||||
+ " but caught " + e + " (message=" + message + ")",
|
||||
expectedExceptionType.isAssignableFrom(e.getClass()));
|
||||
if (expectedExceptionMessageRegex != null) {
|
||||
MoreAsserts.assertContainsRegex(expectedExceptionMessageRegex, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertShortcutIds(List<ShortcutInfo> actualShortcuts,
|
||||
String... expectedIds) {
|
||||
final HashSet<String> expected = new HashSet<>(list(expectedIds));
|
||||
final HashSet<String> actual = new HashSet<>();
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
actual.add(s.getId());
|
||||
}
|
||||
|
||||
// Compare the sets.
|
||||
assertEquals(expected, actual);
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllHaveIntents(
|
||||
List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertNotNull("ID " + s.getId(), s.getIntent());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllNotHaveIntents(
|
||||
List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertNull("ID " + s.getId(), s.getIntent());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllHaveTitle(
|
||||
List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertNotNull("ID " + s.getId(), s.getTitle());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllNotHaveTitle(
|
||||
List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertNull("ID " + s.getId(), s.getTitle());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllHaveIconResId(
|
||||
List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertTrue("ID " + s.getId() + " not have icon res ID", s.hasIconResource());
|
||||
assertFalse("ID " + s.getId() + " shouldn't have icon FD", s.hasIconFile());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllHaveIconFile(
|
||||
List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertFalse("ID " + s.getId() + " shouldn't have icon res ID", s.hasIconResource());
|
||||
assertTrue("ID " + s.getId() + " not have icon FD", s.hasIconFile());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllHaveIcon(
|
||||
List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertTrue("ID " + s.getId() + " has no icon ", s.hasIconFile() || s.hasIconResource());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllKeyFieldsOnly(
|
||||
List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertTrue("ID " + s.getId(), s.hasKeyFieldsOnly());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllNotKeyFieldsOnly(
|
||||
List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertFalse("ID " + s.getId(), s.hasKeyFieldsOnly());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllDynamic(List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertTrue("ID " + s.getId(), s.isDynamic());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllPinned(List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertTrue("ID " + s.getId(), s.isPinned());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> assertAllDynamicOrPinned(
|
||||
List<ShortcutInfo> actualShortcuts) {
|
||||
for (ShortcutInfo s : actualShortcuts) {
|
||||
assertTrue("ID " + s.getId(), s.isDynamic() || s.isPinned());
|
||||
}
|
||||
return actualShortcuts;
|
||||
}
|
||||
|
||||
public static void assertDynamicOnly(ShortcutInfo si) {
|
||||
assertTrue(si.isDynamic());
|
||||
assertFalse(si.isPinned());
|
||||
}
|
||||
|
||||
public static void assertPinnedOnly(ShortcutInfo si) {
|
||||
assertFalse(si.isDynamic());
|
||||
assertTrue(si.isPinned());
|
||||
}
|
||||
|
||||
public static void assertDynamicAndPinned(ShortcutInfo si) {
|
||||
assertTrue(si.isDynamic());
|
||||
assertTrue(si.isPinned());
|
||||
}
|
||||
|
||||
public static void assertBitmapSize(int expectedWidth, int expectedHeight, Bitmap bitmap) {
|
||||
assertEquals("width", expectedWidth, bitmap.getWidth());
|
||||
assertEquals("height", expectedHeight, bitmap.getHeight());
|
||||
}
|
||||
|
||||
public static <T> void assertAllUnique(Collection<T> list) {
|
||||
final Set<Object> set = new HashSet<>();
|
||||
for (T item : list) {
|
||||
if (set.contains(item)) {
|
||||
fail("Duplicate item found: " + item + " (in the list: " + list + ")");
|
||||
}
|
||||
set.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static ShortcutInfo findShortcut(List<ShortcutInfo> list, String id) {
|
||||
for (ShortcutInfo si : list) {
|
||||
if (si.getId().equals(id)) {
|
||||
return si;
|
||||
}
|
||||
}
|
||||
fail("Shortcut " + id + " not found in the list");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Bitmap pfdToBitmap(ParcelFileDescriptor pfd) {
|
||||
assertNotNull(pfd);
|
||||
try {
|
||||
try {
|
||||
return BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor());
|
||||
} finally {
|
||||
pfd.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertBundleEmpty(BaseBundle b) {
|
||||
assertTrue(b == null || b.size() == 0);
|
||||
}
|
||||
|
||||
public static void assertCallbackNotReceived(LauncherApps.Callback mock) {
|
||||
verify(mock, times(0)).onShortcutsChanged(anyString(), anyList(),
|
||||
any(UserHandle.class));
|
||||
}
|
||||
|
||||
public static void assertCallbackReceived(LauncherApps.Callback mock,
|
||||
UserHandle user, String packageName, String... ids) {
|
||||
verify(mock).onShortcutsChanged(eq(packageName), checkShortcutIds(ids),
|
||||
eq(user));
|
||||
}
|
||||
|
||||
public static boolean checkAssertSuccess(Runnable r) {
|
||||
try {
|
||||
r.run();
|
||||
return true;
|
||||
} catch (AssertionError e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T checkArgument(Predicate<T> checker, String description,
|
||||
List<T> matchedCaptor) {
|
||||
final Matcher<T> m = new BaseMatcher<T>() {
|
||||
@Override
|
||||
public boolean matches(Object item) {
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
final T value = (T) item;
|
||||
if (!checker.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (matchedCaptor != null) {
|
||||
matchedCaptor.add(value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description d) {
|
||||
d.appendText(description);
|
||||
}
|
||||
};
|
||||
return Mockito.argThat(m);
|
||||
}
|
||||
|
||||
public static List<ShortcutInfo> checkShortcutIds(String... ids) {
|
||||
return checkArgument((List<ShortcutInfo> list) -> {
|
||||
final Set<String> actualSet = set(si -> si.getId(), list);
|
||||
return actualSet.equals(set(ids));
|
||||
|
||||
}, "Shortcut IDs=[" + Arrays.toString(ids) + "]", null);
|
||||
}
|
||||
|
||||
public static void waitUntil(String message, BooleanSupplier condition) {
|
||||
waitUntil(message, condition, STANDARD_TIMEOUT_SEC);
|
||||
}
|
||||
|
||||
public static void waitUntil(String message, BooleanSupplier condition, int timeoutSeconds) {
|
||||
final long timeout = System.currentTimeMillis() + (timeoutSeconds * 1000L);
|
||||
while (System.currentTimeMillis() < timeout) {
|
||||
if (condition.getAsBoolean()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
fail("Timed out for: " + message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user