Merge "Merge \"Address API council feedback (continued)\" into nyc-mr1-dev am: 01e51e59dd" into nyc-mr1-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
bd7d03ab6a
@@ -9529,8 +9529,8 @@ package android.content.pm {
|
||||
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 startShortcut(java.lang.String, java.lang.String, android.graphics.Rect, android.os.Bundle, android.os.UserHandle);
|
||||
method public void startShortcut(android.content.pm.ShortcutInfo, android.graphics.Rect, android.os.Bundle);
|
||||
method public void unregisterCallback(android.content.pm.LauncherApps.Callback);
|
||||
}
|
||||
|
||||
@@ -10104,14 +10104,13 @@ package android.content.pm {
|
||||
public class ShortcutManager {
|
||||
method public boolean addDynamicShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>, int);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>, java.lang.String);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>, java.lang.CharSequence);
|
||||
method public void enableShortcuts(java.util.List<java.lang.String>);
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getDynamicShortcuts();
|
||||
method public int getIconMaxHeight();
|
||||
method public int getIconMaxWidth();
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getManifestShortcuts();
|
||||
method public int getMaxShortcutCountForActivity();
|
||||
method public int getMaxShortcutCountPerActivity();
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getPinnedShortcuts();
|
||||
method public long getRateLimitResetTime();
|
||||
method public int getRemainingCallCount();
|
||||
|
||||
@@ -9884,8 +9884,8 @@ package android.content.pm {
|
||||
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 startShortcut(java.lang.String, java.lang.String, android.graphics.Rect, android.os.Bundle, android.os.UserHandle);
|
||||
method public void startShortcut(android.content.pm.ShortcutInfo, android.graphics.Rect, android.os.Bundle);
|
||||
method public void unregisterCallback(android.content.pm.LauncherApps.Callback);
|
||||
}
|
||||
|
||||
@@ -10529,14 +10529,13 @@ package android.content.pm {
|
||||
public class ShortcutManager {
|
||||
method public boolean addDynamicShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>, int);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>, java.lang.String);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>, java.lang.CharSequence);
|
||||
method public void enableShortcuts(java.util.List<java.lang.String>);
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getDynamicShortcuts();
|
||||
method public int getIconMaxHeight();
|
||||
method public int getIconMaxWidth();
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getManifestShortcuts();
|
||||
method public int getMaxShortcutCountForActivity();
|
||||
method public int getMaxShortcutCountPerActivity();
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getPinnedShortcuts();
|
||||
method public long getRateLimitResetTime();
|
||||
method public int getRemainingCallCount();
|
||||
|
||||
@@ -9541,8 +9541,8 @@ package android.content.pm {
|
||||
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 startShortcut(java.lang.String, java.lang.String, android.graphics.Rect, android.os.Bundle, android.os.UserHandle);
|
||||
method public void startShortcut(android.content.pm.ShortcutInfo, android.graphics.Rect, android.os.Bundle);
|
||||
method public void unregisterCallback(android.content.pm.LauncherApps.Callback);
|
||||
}
|
||||
|
||||
@@ -10118,14 +10118,13 @@ package android.content.pm {
|
||||
ctor public ShortcutManager(android.content.Context);
|
||||
method public boolean addDynamicShortcuts(java.util.List<android.content.pm.ShortcutInfo>);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>, int);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>, java.lang.String);
|
||||
method public void disableShortcuts(java.util.List<java.lang.String>, java.lang.CharSequence);
|
||||
method public void enableShortcuts(java.util.List<java.lang.String>);
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getDynamicShortcuts();
|
||||
method public int getIconMaxHeight();
|
||||
method public int getIconMaxWidth();
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getManifestShortcuts();
|
||||
method public int getMaxShortcutCountForActivity();
|
||||
method public int getMaxShortcutCountPerActivity();
|
||||
method public java.util.List<android.content.pm.ShortcutInfo> getPinnedShortcuts();
|
||||
method public long getRateLimitResetTime();
|
||||
method public int getRemainingCallCount();
|
||||
|
||||
@@ -41,12 +41,12 @@ interface IShortcutService {
|
||||
|
||||
boolean updateShortcuts(String packageName, in ParceledListSlice shortcuts, int userId);
|
||||
|
||||
void disableShortcuts(String packageName, in List shortcutIds, String disabledMessage,
|
||||
void disableShortcuts(String packageName, in List shortcutIds, CharSequence disabledMessage,
|
||||
int disabledMessageResId, int userId);
|
||||
|
||||
void enableShortcuts(String packageName, in List shortcutIds, int userId);
|
||||
|
||||
int getMaxShortcutCountForActivity(String packageName, int userId);
|
||||
int getMaxShortcutCountPerActivity(String packageName, int userId);
|
||||
|
||||
int getRemainingCallCount(String packageName, int userId);
|
||||
|
||||
|
||||
@@ -651,13 +651,11 @@ public class LauncherApps {
|
||||
* @param sourceBounds The Rect containing the source bounds of the clicked icon.
|
||||
* @param startActivityOptions Options to pass to startActivity.
|
||||
* @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.
|
||||
*/
|
||||
public boolean startShortcut(@NonNull String packageName, @NonNull String shortcutId,
|
||||
public void startShortcut(@NonNull String packageName, @NonNull String shortcutId,
|
||||
@Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions,
|
||||
@NonNull UserHandle user) {
|
||||
return startShortcut(packageName, shortcutId, sourceBounds, startActivityOptions,
|
||||
startShortcut(packageName, shortcutId, sourceBounds, startActivityOptions,
|
||||
user.getIdentifier());
|
||||
}
|
||||
|
||||
@@ -670,21 +668,19 @@ public class LauncherApps {
|
||||
* @param shortcut The target shortcut.
|
||||
* @param sourceBounds The Rect containing the source bounds of the clicked icon.
|
||||
* @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.
|
||||
*/
|
||||
public boolean startShortcut(@NonNull ShortcutInfo shortcut,
|
||||
public void startShortcut(@NonNull ShortcutInfo shortcut,
|
||||
@Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions) {
|
||||
return startShortcut(shortcut.getPackage(), shortcut.getId(),
|
||||
startShortcut(shortcut.getPackage(), shortcut.getId(),
|
||||
sourceBounds, startActivityOptions,
|
||||
shortcut.getUserId());
|
||||
}
|
||||
|
||||
private boolean startShortcut(@NonNull String packageName, @NonNull String shortcutId,
|
||||
private void startShortcut(@NonNull String packageName, @NonNull String shortcutId,
|
||||
@Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions,
|
||||
int userId) {
|
||||
try {
|
||||
return mService.startShortcut(mContext.getPackageName(), packageName, shortcutId,
|
||||
mService.startShortcut(mContext.getPackageName(), packageName, shortcutId,
|
||||
sourceBounds, startActivityOptions, userId);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.util.List;
|
||||
*
|
||||
* An application can publish shortcuts with {@link #setDynamicShortcuts(List)} and
|
||||
* {@link #addDynamicShortcuts(List)}. There can be at most
|
||||
* {@link #getMaxShortcutCountForActivity()} number of dynamic shortcuts at a time from the
|
||||
* {@link #getMaxShortcutCountPerActivity()} number of dynamic shortcuts at a time from the
|
||||
* same application.
|
||||
* A dynamic shortcut can be deleted with {@link #removeDynamicShortcuts(List)}, and apps
|
||||
* can also use {@link #removeAllDynamicShortcuts()} to delete all dynamic shortcuts.
|
||||
@@ -53,7 +53,7 @@ import java.util.List;
|
||||
* <p>The number of pinned shortcuts does not affect the number of dynamic shortcuts that can be
|
||||
* published by an application at a time.
|
||||
* No matter how many pinned shortcuts that Launcher has for an application, the
|
||||
* application can still always publish {@link #getMaxShortcutCountForActivity()} number of
|
||||
* application can still always publish {@link #getMaxShortcutCountPerActivity()} number of
|
||||
* dynamic
|
||||
* shortcuts.
|
||||
*
|
||||
@@ -135,7 +135,7 @@ public class ShortcutManager {
|
||||
* @return {@code true} if the call has succeeded. {@code false} if the call is rate-limited.
|
||||
*
|
||||
* @throws IllegalArgumentException if {@code shortcutInfoList} contains more than
|
||||
* {@link #getMaxShortcutCountForActivity()} shortcuts.
|
||||
* {@link #getMaxShortcutCountPerActivity()} shortcuts.
|
||||
*/
|
||||
public boolean setDynamicShortcuts(@NonNull List<ShortcutInfo> shortcutInfoList) {
|
||||
try {
|
||||
@@ -148,7 +148,7 @@ public class ShortcutManager {
|
||||
|
||||
/**
|
||||
* Return all dynamic shortcuts from the caller application. The number of result items
|
||||
* will not exceed the value returned by {@link #getMaxShortcutCountForActivity()}.
|
||||
* will not exceed the value returned by {@link #getMaxShortcutCountPerActivity()}.
|
||||
*/
|
||||
@NonNull
|
||||
public List<ShortcutInfo> getDynamicShortcuts() {
|
||||
@@ -259,7 +259,7 @@ public class ShortcutManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Javadoc
|
||||
* @hide old signature, kept for unit testing.
|
||||
*/
|
||||
public void disableShortcuts(@NonNull List<String> shortcutIds, int disabledMessageResId) {
|
||||
try {
|
||||
@@ -272,9 +272,16 @@ public class ShortcutManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Javadoc
|
||||
* @hide old signature, kept for unit testing.
|
||||
*/
|
||||
public void disableShortcuts(@NonNull List<String> shortcutIds, String disabledMessage) {
|
||||
disableShortcuts(shortcutIds, (CharSequence) disabledMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Javadoc
|
||||
*/
|
||||
public void disableShortcuts(@NonNull List<String> shortcutIds, CharSequence disabledMessage) {
|
||||
try {
|
||||
mService.disableShortcuts(mContext.getPackageName(), shortcutIds,
|
||||
disabledMessage, /* disabledMessageResId =*/ 0,
|
||||
@@ -295,13 +302,21 @@ public class ShortcutManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @hide old signature, kept for unit testing.
|
||||
*/
|
||||
public int getMaxShortcutCountForActivity() {
|
||||
return getMaxShortcutCountPerActivity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the max number of dynamic shortcuts + manifest shortcuts that each launcher icon
|
||||
* can have at a time.
|
||||
*/
|
||||
public int getMaxShortcutCountForActivity() {
|
||||
public int getMaxShortcutCountPerActivity() {
|
||||
try {
|
||||
return mService.getMaxShortcutCountForActivity(
|
||||
return mService.getMaxShortcutCountPerActivity(
|
||||
mContext.getPackageName(), injectMyUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
|
||||
@@ -1652,7 +1652,7 @@ public class ShortcutService extends IShortcutService.Stub {
|
||||
|
||||
@Override
|
||||
public void disableShortcuts(String packageName, List shortcutIds,
|
||||
String disabledMessage, int disabledMessageResId, @UserIdInt int userId) {
|
||||
CharSequence disabledMessage, int disabledMessageResId, @UserIdInt int userId) {
|
||||
verifyCaller(packageName, userId);
|
||||
Preconditions.checkNotNull(shortcutIds, "shortcutIds must be provided");
|
||||
|
||||
@@ -1661,9 +1661,12 @@ public class ShortcutService extends IShortcutService.Stub {
|
||||
|
||||
ps.ensureImmutableShortcutsNotIncludedWithIds((List<String>) shortcutIds);
|
||||
|
||||
final String disabledMessageString =
|
||||
(disabledMessage == null) ? null : disabledMessage.toString();
|
||||
|
||||
for (int i = shortcutIds.size() - 1; i >= 0; i--) {
|
||||
ps.disableWithId(Preconditions.checkStringNotEmpty((String) shortcutIds.get(i)),
|
||||
disabledMessage, disabledMessageResId,
|
||||
disabledMessageString, disabledMessageResId,
|
||||
/* overrideImmutable=*/ false);
|
||||
}
|
||||
|
||||
@@ -1774,7 +1777,7 @@ public class ShortcutService extends IShortcutService.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxShortcutCountForActivity(String packageName, @UserIdInt int userId)
|
||||
public int getMaxShortcutCountPerActivity(String packageName, @UserIdInt int userId)
|
||||
throws RemoteException {
|
||||
verifyCaller(packageName, userId);
|
||||
|
||||
|
||||
@@ -1331,8 +1331,8 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
|
||||
protected Intent launchShortcutAndGetIntent(
|
||||
@NonNull String packageName, @NonNull String shortcutId, int userId) {
|
||||
reset(mServiceContext);
|
||||
assertTrue(mLauncherApps.startShortcut(packageName, shortcutId, null, null,
|
||||
UserHandle.of(userId)));
|
||||
mLauncherApps.startShortcut(packageName, shortcutId, null, null,
|
||||
UserHandle.of(userId));
|
||||
|
||||
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
verify(mServiceContext).startActivityAsUser(
|
||||
@@ -1346,8 +1346,8 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
|
||||
@NonNull String packageName, @NonNull String shortcutId, int userId) {
|
||||
reset(mServiceContext);
|
||||
|
||||
assertTrue(mLauncherApps.startShortcut(
|
||||
getShortcutInfoAsLauncher(packageName, shortcutId, userId), null, null));
|
||||
mLauncherApps.startShortcut(
|
||||
getShortcutInfoAsLauncher(packageName, shortcutId, userId), null, null);
|
||||
|
||||
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
verify(mServiceContext).startActivityAsUser(
|
||||
@@ -1363,15 +1363,12 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
|
||||
assertNotNull(launchShortcutAndGetIntent_withShortcutInfo(packageName, shortcutId, userId));
|
||||
}
|
||||
|
||||
// TODO Fix all tests using it.
|
||||
protected void assertShortcutNotLaunchable(@NonNull String packageName,
|
||||
@NonNull String shortcutId, int userId) {
|
||||
try {
|
||||
final boolean ok = mLauncherApps.startShortcut(packageName, shortcutId, null, null,
|
||||
mLauncherApps.startShortcut(packageName, shortcutId, null, null,
|
||||
UserHandle.of(userId));
|
||||
if (!ok) {
|
||||
return; // didn't launch, okay.
|
||||
}
|
||||
fail();
|
||||
} catch (SecurityException expected) {
|
||||
// security exception is okay too.
|
||||
}
|
||||
|
||||
@@ -1540,6 +1540,8 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest {
|
||||
/**
|
||||
* This is similar to the above test, except it used "disable" instead of "remove". It also
|
||||
* does "enable".
|
||||
*
|
||||
* TODO Fix the commented out tests.
|
||||
*/
|
||||
public void testDisableAndEnableShortcuts() {
|
||||
runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
|
||||
@@ -1613,17 +1615,17 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest {
|
||||
mLauncherApps.getShortcuts(buildQuery(/* time =*/ 0, CALLING_PACKAGE_1,
|
||||
/* activity =*/ null, ShortcutQuery.FLAG_GET_PINNED), getCallingUser())))),
|
||||
"s2");
|
||||
assertFalse(mLauncherApps.startShortcut(
|
||||
CALLING_PACKAGE_1, "s2", null, null, HANDLE_USER_0));
|
||||
// assertFalse(mLauncherApps.startShortcut(
|
||||
// CALLING_PACKAGE_1, "s2", null, null, HANDLE_USER_0));
|
||||
|
||||
assertShortcutIds(assertAllPinned(assertAllNotKeyFieldsOnly(
|
||||
mLauncherApps.getShortcuts(buildQuery(/* time =*/ 0, CALLING_PACKAGE_2,
|
||||
/* activity =*/ null, ShortcutQuery.FLAG_GET_PINNED), getCallingUser()))),
|
||||
"s3", "s4");
|
||||
assertFalse(mLauncherApps.startShortcut(
|
||||
CALLING_PACKAGE_2, "s3", null, null, HANDLE_USER_0));
|
||||
assertTrue(mLauncherApps.startShortcut(
|
||||
CALLING_PACKAGE_2, "s4", null, null, HANDLE_USER_0));
|
||||
// assertFalse(mLauncherApps.startShortcut(
|
||||
// CALLING_PACKAGE_2, "s3", null, null, HANDLE_USER_0));
|
||||
// assertTrue(mLauncherApps.startShortcut(
|
||||
// CALLING_PACKAGE_2, "s4", null, null, HANDLE_USER_0));
|
||||
|
||||
assertShortcutIds(assertAllPinned(assertAllNotKeyFieldsOnly(assertAllEnabled(
|
||||
mLauncherApps.getShortcuts(buildQuery(/* time =*/ 0, CALLING_PACKAGE_3,
|
||||
@@ -1643,8 +1645,8 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest {
|
||||
mLauncherApps.getShortcuts(buildQuery(/* time =*/ 0, CALLING_PACKAGE_1,
|
||||
/* activity =*/ null, ShortcutQuery.FLAG_GET_PINNED), getCallingUser())))),
|
||||
"s2");
|
||||
assertTrue(mLauncherApps.startShortcut(
|
||||
CALLING_PACKAGE_1, "s2", null, null, HANDLE_USER_0));
|
||||
// assertTrue(mLauncherApps.startShortcut(
|
||||
// CALLING_PACKAGE_1, "s2", null, null, HANDLE_USER_0));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user