Merge "Remove AndroidFuture from ShortcutService's internal api"

This commit is contained in:
TreeHugger Robot
2021-11-01 20:36:25 +00:00
committed by Android (Google) Code Review
3 changed files with 549 additions and 842 deletions

View File

@@ -26,29 +26,28 @@ import com.android.internal.infra.AndroidFuture;
/** {@hide} */
interface IShortcutService {
AndroidFuture setDynamicShortcuts(String packageName,
in ParceledListSlice shortcutInfoList, int userId);
AndroidFuture addDynamicShortcuts(String packageName,
in ParceledListSlice shortcutInfoList, int userId);
AndroidFuture removeDynamicShortcuts(String packageName, in List shortcutIds, int userId);
AndroidFuture removeAllDynamicShortcuts(String packageName, int userId);
AndroidFuture updateShortcuts(String packageName, in ParceledListSlice shortcuts,
boolean setDynamicShortcuts(String packageName, in ParceledListSlice shortcutInfoList,
int userId);
AndroidFuture requestPinShortcut(String packageName, in ShortcutInfo shortcut,
in IntentSender resultIntent, int userId);
AndroidFuture<Intent> createShortcutResultIntent(String packageName, in ShortcutInfo shortcut,
boolean addDynamicShortcuts(String packageName, in ParceledListSlice shortcutInfoList,
int userId);
AndroidFuture disableShortcuts(String packageName, in List shortcutIds,
void removeDynamicShortcuts(String packageName, in List<String> shortcutIds, int userId);
void removeAllDynamicShortcuts(String packageName, int userId);
boolean updateShortcuts(String packageName, in ParceledListSlice shortcuts, int userId);
void requestPinShortcut(String packageName, in ShortcutInfo shortcut,
in IntentSender resultIntent, int userId, in AndroidFuture<String> ret);
void createShortcutResultIntent(String packageName, in ShortcutInfo shortcut, int userId,
in AndroidFuture<Intent> ret);
void disableShortcuts(String packageName, in List<String> shortcutIds,
CharSequence disabledMessage, int disabledMessageResId, int userId);
AndroidFuture enableShortcuts(String packageName, in List shortcutIds, int userId);
void enableShortcuts(String packageName, in List<String> shortcutIds, int userId);
int getMaxShortcutCountPerActivity(String packageName, int userId);
@@ -58,27 +57,26 @@ interface IShortcutService {
int getIconMaxDimensions(String packageName, int userId);
AndroidFuture reportShortcutUsed(String packageName, String shortcutId, int userId);
void reportShortcutUsed(String packageName, String shortcutId, int userId);
void resetThrottling(); // system only API for developer opsions
AndroidFuture onApplicationActive(String packageName, int userId); // system only API for sysUI
void onApplicationActive(String packageName, int userId); // system only API for sysUI
byte[] getBackupPayload(int user);
AndroidFuture applyRestore(in byte[] payload, int user);
void applyRestore(in byte[] payload, int user);
boolean isRequestPinItemSupported(int user, int requestType);
// System API used by framework's ShareSheet (ChooserActivity)
AndroidFuture<ParceledListSlice> getShareTargets(String packageName, in IntentFilter filter,
int userId);
ParceledListSlice getShareTargets(String packageName, in IntentFilter filter, int userId);
boolean hasShareTargets(String packageName, String packageToCheck, int userId);
AndroidFuture removeLongLivedShortcuts(String packageName, in List shortcutIds, int userId);
void removeLongLivedShortcuts(String packageName, in List<String> shortcutIds, int userId);
AndroidFuture<ParceledListSlice> getShortcuts(String packageName, int matchFlags, int userId);
ParceledListSlice getShortcuts(String packageName, int matchFlags, int userId);
AndroidFuture pushDynamicShortcut(String packageName, in ShortcutInfo shortcut, int userId);
void pushDynamicShortcut(String packageName, in ShortcutInfo shortcut, int userId);
}

View File

@@ -145,9 +145,8 @@ public class ShortcutManager {
@WorkerThread
public boolean setDynamicShortcuts(@NonNull List<ShortcutInfo> shortcutInfoList) {
try {
return ((boolean) getFutureOrThrow(mService.setDynamicShortcuts(
mContext.getPackageName(), new ParceledListSlice(
shortcutInfoList), injectMyUserId())));
return mService.setDynamicShortcuts(mContext.getPackageName(), new ParceledListSlice(
shortcutInfoList), injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -166,8 +165,8 @@ public class ShortcutManager {
@NonNull
public List<ShortcutInfo> getDynamicShortcuts() {
try {
return getFutureOrThrow(mService.getShortcuts(mContext.getPackageName(),
FLAG_MATCH_DYNAMIC, injectMyUserId())).getList();
return mService.getShortcuts(mContext.getPackageName(),
FLAG_MATCH_DYNAMIC, injectMyUserId()).getList();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -186,8 +185,8 @@ public class ShortcutManager {
@NonNull
public List<ShortcutInfo> getManifestShortcuts() {
try {
return getFutureOrThrow(mService.getShortcuts(mContext.getPackageName(),
FLAG_MATCH_MANIFEST, injectMyUserId())).getList();
return mService.getShortcuts(mContext.getPackageName(),
FLAG_MATCH_MANIFEST, injectMyUserId()).getList();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -215,8 +214,8 @@ public class ShortcutManager {
@NonNull
public List<ShortcutInfo> getShortcuts(@ShortcutMatchFlags int matchFlags) {
try {
return getFutureOrThrow(mService.getShortcuts(mContext.getPackageName(), matchFlags,
injectMyUserId())).getList();
return mService.getShortcuts(mContext.getPackageName(), matchFlags,
injectMyUserId()).getList();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -238,9 +237,8 @@ public class ShortcutManager {
@WorkerThread
public boolean addDynamicShortcuts(@NonNull List<ShortcutInfo> shortcutInfoList) {
try {
return (boolean) getFutureOrThrow(mService.addDynamicShortcuts(
mContext.getPackageName(), new ParceledListSlice(shortcutInfoList),
injectMyUserId()));
return mService.addDynamicShortcuts(mContext.getPackageName(),
new ParceledListSlice(shortcutInfoList), injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -253,8 +251,8 @@ public class ShortcutManager {
*/
public void removeDynamicShortcuts(@NonNull List<String> shortcutIds) {
try {
getFutureOrThrow(mService.removeDynamicShortcuts(mContext.getPackageName(), shortcutIds,
injectMyUserId()));
mService.removeDynamicShortcuts(mContext.getPackageName(), shortcutIds,
injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -267,8 +265,7 @@ public class ShortcutManager {
*/
public void removeAllDynamicShortcuts() {
try {
getFutureOrThrow(mService.removeAllDynamicShortcuts(mContext.getPackageName(),
injectMyUserId()));
mService.removeAllDynamicShortcuts(mContext.getPackageName(), injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -281,8 +278,8 @@ public class ShortcutManager {
*/
public void removeLongLivedShortcuts(@NonNull List<String> shortcutIds) {
try {
getFutureOrThrow(mService.removeLongLivedShortcuts(mContext.getPackageName(),
shortcutIds, injectMyUserId()));
mService.removeLongLivedShortcuts(mContext.getPackageName(), shortcutIds,
injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -301,8 +298,8 @@ public class ShortcutManager {
@NonNull
public List<ShortcutInfo> getPinnedShortcuts() {
try {
return getFutureOrThrow(mService.getShortcuts(mContext.getPackageName(),
FLAG_MATCH_PINNED, injectMyUserId())).getList();
return mService.getShortcuts(mContext.getPackageName(), FLAG_MATCH_PINNED,
injectMyUserId()).getList();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -323,8 +320,8 @@ public class ShortcutManager {
@WorkerThread
public boolean updateShortcuts(@NonNull List<ShortcutInfo> shortcutInfoList) {
try {
return (boolean) getFutureOrThrow(mService.updateShortcuts(mContext.getPackageName(),
new ParceledListSlice(shortcutInfoList), injectMyUserId()));
return mService.updateShortcuts(mContext.getPackageName(),
new ParceledListSlice(shortcutInfoList), injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -341,9 +338,9 @@ public class ShortcutManager {
*/
public void disableShortcuts(@NonNull List<String> shortcutIds) {
try {
getFutureOrThrow(mService.disableShortcuts(mContext.getPackageName(), shortcutIds,
mService.disableShortcuts(mContext.getPackageName(), shortcutIds,
/* disabledMessage =*/ null, /* disabledMessageResId =*/ 0,
injectMyUserId()));
injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -354,9 +351,9 @@ public class ShortcutManager {
*/
public void disableShortcuts(@NonNull List<String> shortcutIds, int disabledMessageResId) {
try {
getFutureOrThrow(mService.disableShortcuts(mContext.getPackageName(), shortcutIds,
mService.disableShortcuts(mContext.getPackageName(), shortcutIds,
/* disabledMessage =*/ null, disabledMessageResId,
injectMyUserId()));
injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -382,9 +379,9 @@ public class ShortcutManager {
*/
public void disableShortcuts(@NonNull List<String> shortcutIds, CharSequence disabledMessage) {
try {
getFutureOrThrow(mService.disableShortcuts(mContext.getPackageName(), shortcutIds,
mService.disableShortcuts(mContext.getPackageName(), shortcutIds,
disabledMessage, /* disabledMessageResId =*/ 0,
injectMyUserId()));
injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -400,8 +397,7 @@ public class ShortcutManager {
*/
public void enableShortcuts(@NonNull List<String> shortcutIds) {
try {
getFutureOrThrow(mService.enableShortcuts(
mContext.getPackageName(), shortcutIds, injectMyUserId()));
mService.enableShortcuts(mContext.getPackageName(), shortcutIds, injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -522,8 +518,7 @@ public class ShortcutManager {
*/
public void reportShortcutUsed(String shortcutId) {
try {
getFutureOrThrow(mService.reportShortcutUsed(mContext.getPackageName(), shortcutId,
injectMyUserId()));
mService.reportShortcutUsed(mContext.getPackageName(), shortcutId, injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -601,8 +596,10 @@ public class ShortcutManager {
public boolean requestPinShortcut(@NonNull ShortcutInfo shortcut,
@Nullable IntentSender resultIntent) {
try {
return (boolean) getFutureOrThrow(mService.requestPinShortcut(mContext.getPackageName(),
shortcut, resultIntent, injectMyUserId()));
AndroidFuture<String> ret = new AndroidFuture<>();
mService.requestPinShortcut(mContext.getPackageName(), shortcut, resultIntent,
injectMyUserId(), ret);
return Boolean.parseBoolean(getFutureOrThrow(ret));
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -627,9 +624,11 @@ public class ShortcutManager {
*/
@WorkerThread
public Intent createShortcutResultIntent(@NonNull ShortcutInfo shortcut) {
final AndroidFuture<Intent> ret = new AndroidFuture<>();
try {
return getFutureOrThrow(mService.createShortcutResultIntent(mContext.getPackageName(),
shortcut, injectMyUserId()));
mService.createShortcutResultIntent(mContext.getPackageName(),
shortcut, injectMyUserId(), ret);
return getFutureOrThrow(ret);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -645,7 +644,7 @@ public class ShortcutManager {
*/
public void onApplicationActive(@NonNull String packageName, @UserIdInt int userId) {
try {
getFutureOrThrow(mService.onApplicationActive(packageName, userId));
mService.onApplicationActive(packageName, userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -671,8 +670,8 @@ public class ShortcutManager {
@RequiresPermission(Manifest.permission.MANAGE_APP_PREDICTIONS)
public List<ShareShortcutInfo> getShareTargets(@NonNull IntentFilter filter) {
try {
return getFutureOrThrow(mService.getShareTargets(mContext.getPackageName(), filter,
injectMyUserId())).getList();
return mService.getShareTargets(
mContext.getPackageName(), filter, injectMyUserId()).getList();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -782,8 +781,7 @@ public class ShortcutManager {
*/
public void pushDynamicShortcut(@NonNull ShortcutInfo shortcut) {
try {
getFutureOrThrow(mService.pushDynamicShortcut(
mContext.getPackageName(), shortcut, injectMyUserId()));
mService.pushDynamicShortcut(mContext.getPackageName(), shortcut, injectMyUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}

File diff suppressed because it is too large Load Diff