summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorFabian Kozynski <kozynski@google.com>2021-09-14 12:18:59 -0400
committerFabian Kozynski <kozynski@google.com>2021-10-05 10:25:29 -0400
commitc511e019f0ed5adff773b0787f6848101a32b8a0 (patch)
tree9ce66d954bd38b928d0a3903d55bb40f404cd8e4 /core/java
parentee089dd126e4111999da9156d7c02f86fe55dd77 (diff)
Make API one-way
Convert the return values to values that will be returned through the callback. Separate the ranges by SUCCESS of the request or ERROR. Test: CTS tests Fixes: 199829900 Change-Id: If32083e52ed87a79953c952bbaadd8d977e0226c
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/StatusBarManager.java63
-rw-r--r--core/java/com/android/internal/statusbar/IStatusBarService.aidl2
2 files changed, 31 insertions, 34 deletions
diff --git a/core/java/android/app/StatusBarManager.java b/core/java/android/app/StatusBarManager.java
index ee50634492bb..53dcef75da00 100644
--- a/core/java/android/app/StatusBarManager.java
+++ b/core/java/android/app/StatusBarManager.java
@@ -228,55 +228,53 @@ public class StatusBarManager {
/** @hide */
public static final int TILE_ADD_REQUEST_RESULT_DIALOG_DISMISSED = 3;
- /** @hide */
- @IntDef(prefix = {"TILE_ADD_REQUEST_RESULT_"}, value = {
- TILE_ADD_REQUEST_RESULT_TILE_NOT_ADDED,
- TILE_ADD_REQUEST_RESULT_TILE_ALREADY_ADDED,
- TILE_ADD_REQUEST_RESULT_TILE_ADDED,
- TILE_ADD_REQUEST_RESULT_DIALOG_DISMISSED
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface RequestResult {}
-
/**
- * Indicates that the request was sent successfully. Does not indicate that the user
- * has accepted the request.
+ * Values greater or equal to this value indicate an error in the request.
*/
- public static final int TILE_ADD_REQUEST_ANSWER_SUCCESS = 0;
+ private static final int TILE_ADD_REQUEST_FIRST_ERROR_CODE = 1000;
+
/**
* Indicates that this package does not match that of the
* {@link android.service.quicksettings.TileService}.
*/
- public static final int TILE_ADD_REQUEST_ANSWER_FAILED_MISMATCHED_PACKAGE = 1;
+ public static final int TILE_ADD_REQUEST_ERROR_MISMATCHED_PACKAGE =
+ TILE_ADD_REQUEST_FIRST_ERROR_CODE;
/**
* Indicates that there's a request in progress for this package.
*/
- public static final int TILE_ADD_REQUEST_ANSWER_FAILED_REQUEST_IN_PROGRESS = 2;
+ public static final int TILE_ADD_REQUEST_ERROR_REQUEST_IN_PROGRESS =
+ TILE_ADD_REQUEST_FIRST_ERROR_CODE + 1;
/**
* Indicates that the component does not match an enabled
* {@link android.service.quicksettings.TileService} for the current user.
*/
- public static final int TILE_ADD_REQUEST_ANSWER_FAILED_BAD_COMPONENT = 3;
+ public static final int TILE_ADD_REQUEST_ERROR_BAD_COMPONENT =
+ TILE_ADD_REQUEST_FIRST_ERROR_CODE + 2;
/**
* Indicates that the user is not the current user.
*/
- public static final int TILE_ADD_REQUEST_ANSWER_FAILED_NOT_CURRENT_USER = 4;
+ public static final int TILE_ADD_REQUEST_ERROR_NOT_CURRENT_USER =
+ TILE_ADD_REQUEST_FIRST_ERROR_CODE + 3;
/**
- * The request could not be processed due to an unkonwn reason.
+ * The request could not be processed because no fulfilling service was found. This could be
+ * a temporary issue (for example, SystemUI has crashed).
*/
- public static final int TILE_ADD_REQUEST_ANSWER_FAILED_UNKNOWN_REASON = 5;
+ public static final int TILE_ADD_REQUEST_ERROR_NO_STATUS_BAR_SERVICE =
+ TILE_ADD_REQUEST_FIRST_ERROR_CODE + 4;
/** @hide */
- @IntDef(prefix = {"TILE_ADD_REQUEST_ANSWER_"}, value = {
- TILE_ADD_REQUEST_ANSWER_SUCCESS,
- TILE_ADD_REQUEST_ANSWER_FAILED_MISMATCHED_PACKAGE,
- TILE_ADD_REQUEST_ANSWER_FAILED_REQUEST_IN_PROGRESS,
- TILE_ADD_REQUEST_ANSWER_FAILED_BAD_COMPONENT,
- TILE_ADD_REQUEST_ANSWER_FAILED_NOT_CURRENT_USER,
- TILE_ADD_REQUEST_ANSWER_FAILED_UNKNOWN_REASON
+ @IntDef(prefix = {"TILE_ADD_REQUEST"}, value = {
+ TILE_ADD_REQUEST_RESULT_TILE_NOT_ADDED,
+ TILE_ADD_REQUEST_RESULT_TILE_ALREADY_ADDED,
+ TILE_ADD_REQUEST_RESULT_TILE_ADDED,
+ TILE_ADD_REQUEST_ERROR_MISMATCHED_PACKAGE,
+ TILE_ADD_REQUEST_ERROR_REQUEST_IN_PROGRESS,
+ TILE_ADD_REQUEST_ERROR_BAD_COMPONENT,
+ TILE_ADD_REQUEST_ERROR_NOT_CURRENT_USER,
+ TILE_ADD_REQUEST_ERROR_NO_STATUS_BAR_SERVICE
})
@Retention(RetentionPolicy.SOURCE)
- public @interface RequestAnswer {}
+ public @interface RequestResult {}
@UnsupportedAppUsage
private Context mContext;
@@ -626,12 +624,10 @@ public class StatusBarManager {
* @param icon icon to use in the tile shown to the user.
* @param resultExecutor an executor to run the callback on
* @param resultCallback callback to indicate the {@link RequestResult}.
- * @return whether the request was successfully sent.
*
* @see android.service.quicksettings.TileService
*/
- @RequestAnswer
- public int requestAddTileService(
+ public void requestAddTileService(
@NonNull ComponentName tileServiceComponentName,
@NonNull CharSequence tileLabel,
@NonNull Icon icon,
@@ -644,14 +640,16 @@ public class StatusBarManager {
Objects.requireNonNull(resultExecutor);
Objects.requireNonNull(resultCallback);
if (!tileServiceComponentName.getPackageName().equals(mContext.getPackageName())) {
- return TILE_ADD_REQUEST_ANSWER_FAILED_MISMATCHED_PACKAGE;
+ resultExecutor.execute(
+ () -> resultCallback.accept(TILE_ADD_REQUEST_ERROR_MISMATCHED_PACKAGE));
+ return;
}
int userId = mContext.getUserId();
RequestResultCallback callbackProxy = new RequestResultCallback(resultExecutor,
resultCallback);
IStatusBarService svc = getService();
try {
- return svc.requestAddTile(
+ svc.requestAddTile(
tileServiceComponentName,
tileLabel,
icon,
@@ -661,7 +659,6 @@ public class StatusBarManager {
} catch (RemoteException ex) {
ex.rethrowFromSystemServer();
}
- return TILE_ADD_REQUEST_ANSWER_FAILED_UNKNOWN_REASON;
}
/** @hide */
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index 92031b4e14ae..49c32be9b43a 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -160,5 +160,5 @@ interface IStatusBarService
*/
void suppressAmbientDisplay(boolean suppress);
- int requestAddTile(in ComponentName componentName, in CharSequence label, in Icon icon, int userId, in IAddTileResultCallback callback);
+ void requestAddTile(in ComponentName componentName, in CharSequence label, in Icon icon, int userId, in IAddTileResultCallback callback);
}