diff options
author | Sarah Kim <sarahchin@google.com> | 2023-07-13 18:53:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2023-07-13 18:53:58 +0000 |
commit | 37f75aada65f355a70f1a82c95db52686be11e28 (patch) | |
tree | 7e04310023fb6ab6f979b4a081e8a6761719a851 | |
parent | 6141c81297eba655155642a272a3f0a742428717 (diff) | |
parent | 4663753193c3d272c37677c0e91c6f2ab548550c (diff) | |
download | service_entitlement-37f75aada65f355a70f1a82c95db52686be11e28.tar.gz |
Merge "Add notification token and action to TS.43 auth calls" into main
7 files changed, 313 insertions, 97 deletions
diff --git a/java/com/android/libraries/entitlement/EapAkaHelper.java b/java/com/android/libraries/entitlement/EapAkaHelper.java index e5af73e..f29cb0f 100644 --- a/java/com/android/libraries/entitlement/EapAkaHelper.java +++ b/java/com/android/libraries/entitlement/EapAkaHelper.java @@ -87,7 +87,7 @@ public class EapAkaHelper { EapAkaResponse eapAkaResponse = getEapAkaResponse(challenge); return (eapAkaResponse == null) ? null - : eapAkaResponse.response(); // Would be null on synchrinization failure + : eapAkaResponse.response(); // Would be null on synchronization failure } /** diff --git a/java/com/android/libraries/entitlement/ServiceEntitlementRequest.java b/java/com/android/libraries/entitlement/ServiceEntitlementRequest.java index 216225e..6398d4e 100644 --- a/java/com/android/libraries/entitlement/ServiceEntitlementRequest.java +++ b/java/com/android/libraries/entitlement/ServiceEntitlementRequest.java @@ -28,10 +28,6 @@ import com.google.auto.value.AutoValue; */ @AutoValue public abstract class ServiceEntitlementRequest { - /** Disables notification token. */ - public static final int NOTIFICATION_ACTION_DISABLE = 0; - /** Enables FCM notification token. */ - public static final int NOTIFICATION_ACTION_ENABLE_FCM = 2; /** Accepts the content type in XML format. */ public static final String ACCEPT_CONTENT_TYPE_XML = "text/vnd.wap.connectivity-xml"; /** Accepts the content type in JSON format. */ @@ -106,10 +102,8 @@ public abstract class ServiceEntitlementRequest { /** * Returns the action associated with the FCM registration token. Used by HTTP parameter * "notif_action". - * - * @see #NOTIFICATION_ACTION_ENABLE_FCM - * @see #NOTIFICATION_ACTION_DISABLE */ + @Ts43Constants.NotificationAction public abstract int notificationAction(); /** @@ -142,7 +136,7 @@ public abstract class ServiceEntitlementRequest { .setAppName("") .setAppVersion("") .setNotificationToken("") - .setNotificationAction(NOTIFICATION_ACTION_ENABLE_FCM) + .setNotificationAction(Ts43Constants.NOTIFICATION_ACTION_ENABLE_FCM) .setAcceptContentType(ACCEPT_CONTENT_TYPE_JSON_AND_XML) .setBoostType(""); } @@ -242,13 +236,10 @@ public abstract class ServiceEntitlementRequest { * Sets the action associated with the FCM registration token. Used by HTTP parameter * "notif_action". * - * <p>Required if a token is set with {@link #setNotificationToken}, and default to {@link - * #NOTIFICATION_ACTION_ENABLE_FCM}; otherwise ignored. - * - * @see #NOTIFICATION_ACTION_ENABLE_FCM - * @see #NOTIFICATION_ACTION_DISABLE + * <p>Required if a token is set with {@link #setNotificationToken}, and default to + * {@link Ts43Constants#NOTIFICATION_ACTION_ENABLE_FCM}; otherwise ignored. */ - public abstract Builder setNotificationAction(int value); + public abstract Builder setNotificationAction(@Ts43Constants.NotificationAction int value); /** * Sets the configuration document format the caller accepts, e.g. XML or JSON. Used by HTTP diff --git a/java/com/android/libraries/entitlement/Ts43Operation.java b/java/com/android/libraries/entitlement/Ts43Operation.java index 9accb03..77bda9c 100644 --- a/java/com/android/libraries/entitlement/Ts43Operation.java +++ b/java/com/android/libraries/entitlement/Ts43Operation.java @@ -204,6 +204,15 @@ public class Ts43Operation { builder.setTemporaryToken(mTemporaryToken); } + String notificationToken = checkEligibilityRequest.notificationToken(); + if (!TextUtils.isEmpty(notificationToken)) { + builder.setNotificationToken(notificationToken); + } + int notificationAction = checkEligibilityRequest.notificationAction(); + if (Ts43Constants.isValidNotificationAction(notificationAction)) { + builder.setNotificationAction(notificationAction); + } + ServiceEntitlementRequest request = builder.build(); EsimOdsaOperation operation = @@ -351,12 +360,22 @@ public class Ts43Operation { .setEntitlementVersion(mEntitlementVersion) .setTerminalId(mImei) .setAcceptContentType(ServiceEntitlementRequest.ACCEPT_CONTENT_TYPE_XML); + if (mTokenType == TOKEN_TYPE_NORMAL) { builder.setAuthenticationToken(mAuthToken); } else if (mTokenType == TOKEN_TYPE_TEMPORARY) { builder.setTemporaryToken(mTemporaryToken); } + String notificationToken = manageSubscriptionRequest.notificationToken(); + if (!TextUtils.isEmpty(notificationToken)) { + builder.setNotificationToken(notificationToken); + } + int notificationAction = manageSubscriptionRequest.notificationAction(); + if (Ts43Constants.isValidNotificationAction(notificationAction)) { + builder.setNotificationAction(notificationAction); + } + ServiceEntitlementRequest request = builder.build(); EsimOdsaOperation operation = @@ -604,12 +623,21 @@ public class Ts43Operation { throws ServiceEntitlementException { Objects.requireNonNull(acquireConfigurationRequest); - ServiceEntitlementRequest request = - ServiceEntitlementRequest.builder() - .setEntitlementVersion(mEntitlementVersion) - .setTerminalId(mImei) - .setAuthenticationToken(mAuthToken) - .build(); + ServiceEntitlementRequest.Builder builder = ServiceEntitlementRequest.builder() + .setEntitlementVersion(mEntitlementVersion) + .setTerminalId(mImei) + .setAuthenticationToken(mAuthToken); + + String notificationToken = acquireConfigurationRequest.notificationToken(); + if (!TextUtils.isEmpty(notificationToken)) { + builder.setNotificationToken(notificationToken); + } + int notificationAction = acquireConfigurationRequest.notificationAction(); + if (Ts43Constants.isValidNotificationAction(notificationAction)) { + builder.setNotificationAction(notificationAction); + } + + ServiceEntitlementRequest request = builder.build(); EsimOdsaOperation operation = EsimOdsaOperation.builder() diff --git a/java/com/android/libraries/entitlement/odsa/AcquireConfigurationOperation.java b/java/com/android/libraries/entitlement/odsa/AcquireConfigurationOperation.java index 34e7552..c222d85 100644 --- a/java/com/android/libraries/entitlement/odsa/AcquireConfigurationOperation.java +++ b/java/com/android/libraries/entitlement/odsa/AcquireConfigurationOperation.java @@ -24,6 +24,7 @@ import com.android.libraries.entitlement.odsa.OdsaOperation.CompanionService; import com.android.libraries.entitlement.odsa.OdsaOperation.ServiceStatus; import com.android.libraries.entitlement.utils.Ts43Constants; import com.android.libraries.entitlement.utils.Ts43Constants.AppId; +import com.android.libraries.entitlement.utils.Ts43Constants.NotificationAction; import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableList; @@ -45,8 +46,8 @@ public final class AcquireConfigurationOperation { @AutoValue public abstract static class AcquireConfigurationRequest { /** - * Returns the application id. Can only be {@link Ts43Constants#APP_ODSA_COMPANION}, {@link - * Ts43Constants#APP_ODSA_PRIMARY}, or + * Returns the application id. Can only be {@link Ts43Constants#APP_ODSA_COMPANION}, + * {@link Ts43Constants#APP_ODSA_PRIMARY}, or * {@link Ts43Constants#APP_ODSA_SERVER_INITIATED_REQUESTS}. */ @AppId @@ -60,15 +61,15 @@ public final class AcquireConfigurationOperation { public abstract String companionTerminalId(); /** - * Returns the ICCID of the companion device. Used by HTTP parameter {@code - * companion_terminal_iccid}. + * Returns the ICCID of the companion device. Used by HTTP parameter + * {@code companion_terminal_iccid}. */ @NonNull public abstract String companionTerminalIccid(); /** - * Returns the EID of the companion device. Used by HTTP parameter {@code - * companion_terminal_eid}. + * Returns the EID of the companion device. Used by HTTP parameter + * {@code companion_terminal_eid}. */ @NonNull public abstract String companionTerminalEid(); @@ -108,6 +109,20 @@ public final class AcquireConfigurationOperation { @NonNull public abstract String targetTerminalEid(); + /** + * Returns the notification token used to register for entitlement configuration request + * from network. Used by HTTP parameter {@code notif_token}. + */ + @NonNull + public abstract String notificationToken(); + + /** + * Returns the action associated with the notification token. Used by HTTP parameter + * {@code notif_action}. + */ + @NotificationAction + public abstract int notificationAction(); + /** Returns a new {@link Builder} object. */ @NonNull public static Builder builder() { @@ -120,7 +135,9 @@ public final class AcquireConfigurationOperation { .setTerminalEid("") .setTargetTerminalId("") .setTargetTerminalIccid("") - .setTargetTerminalEid(""); + .setTargetTerminalEid("") + .setNotificationToken("") + .setNotificationAction(Ts43Constants.NOTIFICATION_ACTION_ENABLE_FCM); } /** Builder */ @@ -129,8 +146,9 @@ public final class AcquireConfigurationOperation { /** * Sets the application id. * - * @param appId The application id. Can only be {@link Ts43Constants#APP_ODSA_COMPANION} - * , {@link Ts43Constants#APP_ODSA_PRIMARY}, or + * @param appId The application id. Can only be + * {@link Ts43Constants#APP_ODSA_COMPANION}, + * {@link Ts43Constants#APP_ODSA_PRIMARY}, or * {@link Ts43Constants#APP_ODSA_SERVER_INITIATED_REQUESTS}. * @return The builder. */ @@ -150,8 +168,8 @@ public final class AcquireConfigurationOperation { public abstract Builder setCompanionTerminalId(@NonNull String companionTerminalId); /** - * Sets the ICCID of the companion device. Used by HTTP parameter {@code - * companion_terminal_iccid} if set. + * Sets the ICCID of the companion device. Used by HTTP parameter + * {@code companion_terminal_iccid} if set. * * <p>Used by companion device ODSA operation. * @@ -239,6 +257,32 @@ public final class AcquireConfigurationOperation { @NonNull public abstract Builder setTargetTerminalEid(@NonNull String targetTerminalEid); + /** + * Sets the notification token used to register for entitlement configuration request + * from network. Used by HTTP parameter {@code notif_token} if set. + * + * <p>Used by primary device ODSA operation. + * + * @param notificationToken The notification token used to register for entitlement + * configuration request from network. + * @return The builder. + */ + @NonNull + public abstract Builder setNotificationToken(@NonNull String notificationToken); + + /** + * Sets the action associated with the notification token. Used by HTTP parameter + * {@code notif_action} if set. + * + * <p>Used by primary device ODSA operation. + * + * @param notificationAction The action associated with the notification token. + * @return The builder. + */ + @NonNull + public abstract Builder setNotificationAction( + @NotificationAction int notificationAction); + /** Returns build the {@link AcquireConfigurationRequest} object. */ @NonNull public abstract AcquireConfigurationRequest build(); @@ -319,7 +363,7 @@ public final class AcquireConfigurationOperation { * #serviceStatus()} with {@link OdsaOperation#SERVICE_STATUS_DEACTIVATED_NO_REUSE} will * be defined as an ECS configuration variable (MaxRefreshRequest). * - * <p>{@link #POLLING_INTERVAL_NOT_AVAILABLE} when polling inverval is not available. + * <p>{@link #POLLING_INTERVAL_NOT_AVAILABLE} when polling interval is not available. */ public abstract int pollingInterval(); @@ -349,7 +393,7 @@ public final class AcquireConfigurationOperation { @AutoValue.Builder public abstract static class Builder { /** - * Set the configuration type + * Set the configuration type. * * @param configType The configuration type. * @return The builder. diff --git a/java/com/android/libraries/entitlement/odsa/CheckEligibilityOperation.java b/java/com/android/libraries/entitlement/odsa/CheckEligibilityOperation.java index 423c413..bd609bf 100644 --- a/java/com/android/libraries/entitlement/odsa/CheckEligibilityOperation.java +++ b/java/com/android/libraries/entitlement/odsa/CheckEligibilityOperation.java @@ -25,6 +25,7 @@ import com.android.libraries.entitlement.utils.HttpConstants; import com.android.libraries.entitlement.utils.HttpConstants.ContentType; import com.android.libraries.entitlement.utils.Ts43Constants; import com.android.libraries.entitlement.utils.Ts43Constants.AppId; +import com.android.libraries.entitlement.utils.Ts43Constants.NotificationAction; import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableList; @@ -58,14 +59,14 @@ public final class CheckEligibilityOperation { } /** - * HTTP request parameters specific to on device service activation (ODSA). See GSMA spec TS.43 - * section 6.2. + * HTTP request parameters specific to on device service activation (ODSA). + * See GSMA spec TS.43 section 6.2. */ @AutoValue public abstract static class CheckEligibilityRequest { /** - * Returns the application id. Can only be {@link Ts43Constants#APP_ODSA_COMPANION}, {@link - * Ts43Constants#APP_ODSA_PRIMARY}, or + * Returns the application id. Can only be {@link Ts43Constants#APP_ODSA_COMPANION}, + * {@link Ts43Constants#APP_ODSA_PRIMARY}, or * {@link Ts43Constants#APP_ODSA_SERVER_INITIATED_REQUESTS}. */ @AppId @@ -79,33 +80,47 @@ public final class CheckEligibilityOperation { public abstract String companionTerminalId(); /** - * Returns the OEM of the companion device. Used by HTTP parameter {@code - * companion_terminal_vendor}. + * Returns the OEM of the companion device. Used by HTTP parameter + * {@code companion_terminal_vendor}. */ @NonNull public abstract String companionTerminalVendor(); /** - * Returns the model of the companion device. Used by HTTP parameter {@code - * companion_terminal_model}. + * Returns the model of the companion device. Used by HTTP parameter + * {@code companion_terminal_model}. */ @NonNull public abstract String companionTerminalModel(); /** - * Returns the software version of the companion device. Used by HTTP parameter {@code - * companion_terminal_sw_version}. + * Returns the software version of the companion device. Used by HTTP parameter + * {@code companion_terminal_sw_version}. */ @NonNull public abstract String companionTerminalSoftwareVersion(); /** - * Returns the user-friendly version of the companion device. Used by HTTP parameter {@code - * companion_terminal_friendly_name}. + * Returns the user-friendly version of the companion device. Used by HTTP parameter + * {@code companion_terminal_friendly_name}. */ @NonNull public abstract String companionTerminalFriendlyName(); + /** + * Returns the notification token used to register for entitlement configuration request + * from network. Used by HTTP parameter {@code notif_token}. + */ + @NonNull + public abstract String notificationToken(); + + /** + * Returns the action associated with the notification token. Used by HTTP parameter + * {@code notif_action}. + */ + @NotificationAction + public abstract int notificationAction(); + /** Returns a new {@link Builder} object. */ @NonNull public static Builder builder() { @@ -115,7 +130,9 @@ public final class CheckEligibilityOperation { .setCompanionTerminalVendor("") .setCompanionTerminalModel("") .setCompanionTerminalSoftwareVersion("") - .setCompanionTerminalFriendlyName(""); + .setCompanionTerminalFriendlyName("") + .setNotificationToken("") + .setNotificationAction(Ts43Constants.NOTIFICATION_ACTION_ENABLE_FCM); } /** Builder */ @@ -146,8 +163,8 @@ public final class CheckEligibilityOperation { public abstract Builder setCompanionTerminalId(@NonNull String companionTerminalId); /** - * Sets the OEM of the companion device. Used by HTTP parameter {@code - * companion_terminal_vendor}. if set. + * Sets the OEM of the companion device. Used by HTTP parameter + * {@code companion_terminal_vendor} if set. * * <p>Used by companion device ODSA operation. * @@ -159,8 +176,8 @@ public final class CheckEligibilityOperation { @NonNull String companionTerminalVendor); /** - * Sets the model of the companion device. Used by HTTP parameter {@code - * companion_terminal_model}. if set. + * Sets the model of the companion device. Used by HTTP parameter + * {@code companion_terminal_model} if set. * * <p>Used by companion device ODSA operation. * @@ -172,8 +189,8 @@ public final class CheckEligibilityOperation { @NonNull String companionTerminalModel); /** - * Sets the software version of the companion device. Used by HTTP parameter {@code - * companion_terminal_sw_version} if set. + * Sets the software version of the companion device. Used by HTTP parameter + * {@code companion_terminal_sw_version} if set. * * <p>Used by companion device ODSA operation. * @@ -185,8 +202,8 @@ public final class CheckEligibilityOperation { @NonNull String companionTerminalSoftwareVersion); /** - * Sets the user-friendly version of the companion device. Used by HTTP parameter {@code - * companion_terminal_friendly_name} if set. + * Sets the user-friendly version of the companion device. Used by HTTP parameter + * {@code companion_terminal_friendly_name} if set. * * <p>Used by companion device ODSA operation. * @@ -198,6 +215,32 @@ public final class CheckEligibilityOperation { public abstract Builder setCompanionTerminalFriendlyName( @NonNull String companionTerminalFriendlyName); + /** + * Sets the notification token used to register for entitlement configuration request + * from network. Used by HTTP parameter {@code notif_token} if set. + * + * <p>Used by primary device ODSA operation. + * + * @param notificationToken The notification token used to register for entitlement + * configuration request from network. + * @return The builder. + */ + @NonNull + public abstract Builder setNotificationToken(@NonNull String notificationToken); + + /** + * Sets the action associated with the notification token. Used by HTTP parameter + * {@code notif_action} if set. + * + * <p>Used by primary device ODSA operation. + * + * @param notificationAction The action associated with the notification token. + * @return The builder. + */ + @NonNull + public abstract Builder setNotificationAction( + @NotificationAction int notificationAction); + /** Returns the {@link CheckEligibilityRequest} object. */ @NonNull public abstract CheckEligibilityRequest build(); @@ -220,8 +263,7 @@ public final class CheckEligibilityOperation { /** * The provided URL shall present a web view to user on the reason(s) why the ODSA app - * cannot be - * used/invoked. + * cannot be used/invoked. */ @Nullable public abstract URL notEnabledUrl(); diff --git a/java/com/android/libraries/entitlement/odsa/ManageSubscriptionOperation.java b/java/com/android/libraries/entitlement/odsa/ManageSubscriptionOperation.java index 99feb53..256f851 100644 --- a/java/com/android/libraries/entitlement/odsa/ManageSubscriptionOperation.java +++ b/java/com/android/libraries/entitlement/odsa/ManageSubscriptionOperation.java @@ -26,6 +26,7 @@ import com.android.libraries.entitlement.utils.HttpConstants; import com.android.libraries.entitlement.utils.HttpConstants.ContentType; import com.android.libraries.entitlement.utils.Ts43Constants; import com.android.libraries.entitlement.utils.Ts43Constants.AppId; +import com.android.libraries.entitlement.utils.Ts43Constants.NotificationAction; import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableList; @@ -45,8 +46,8 @@ public final class ManageSubscriptionOperation { @AutoValue public abstract static class ManageSubscriptionRequest { /** - * Returns the application id. Can only be {@link Ts43Constants#APP_ODSA_COMPANION}, {@link - * Ts43Constants#APP_ODSA_PRIMARY}, or + * Returns the application id. Can only be {@link Ts43Constants#APP_ODSA_COMPANION}, + * {@link Ts43Constants#APP_ODSA_PRIMARY}, or * {@link Ts43Constants#APP_ODSA_SERVER_INITIATED_REQUESTS}. */ @NonNull @@ -54,8 +55,8 @@ public final class ManageSubscriptionOperation { public abstract String appId(); /** - * Returns the detailed type of the eSIM ODSA operation. Used by HTTP parameter {@code - * operation_type}. + * Returns the detailed type of the eSIM ODSA operation. Used by HTTP parameter + * {@code operation_type}. */ @OperationType public abstract int operationType(); @@ -68,29 +69,29 @@ public final class ManageSubscriptionOperation { public abstract String companionTerminalId(); /** - * Returns the OEM of the companion device. Used by HTTP parameter {@code - * companion_terminal_vendor}. + * Returns the OEM of the companion device. Used by HTTP parameter + * {@code companion_terminal_vendor}. */ @NonNull public abstract String companionTerminalVendor(); /** - * Returns the model of the companion device. Used by HTTP parameter {@code - * companion_terminal_model}. + * Returns the model of the companion device. Used by HTTP parameter + * {@code companion_terminal_model}. */ @NonNull public abstract String companionTerminalModel(); /** - * Returns the software version of the companion device. Used by HTTP parameter {@code - * companion_terminal_sw_version}. + * Returns the software version of the companion device. Used by HTTP parameter + * {@code companion_terminal_sw_version}. */ @NonNull public abstract String companionTerminalSoftwareVersion(); /** - * Returns the user-friendly version of the companion device. Used by HTTP parameter {@code - * companion_terminal_friendly_name}. + * Returns the user-friendly version of the companion device. Used by HTTP parameter + * {@code companion_terminal_friendly_name}. */ @NonNull public abstract String companionTerminalFriendlyName(); @@ -104,15 +105,15 @@ public final class ManageSubscriptionOperation { public abstract String companionTerminalService(); /** - * Returns the ICCID of the companion device. Used by HTTP parameter {@code - * companion_terminal_iccid}. + * Returns the ICCID of the companion device. Used by HTTP parameter + * {@code companion_terminal_iccid}. */ @NonNull public abstract String companionTerminalIccid(); /** - * Returns the EID of the companion device. Used by HTTP parameter {@code - * companion_terminal_eid}. + * Returns the EID of the companion device. Used by HTTP parameter + * {@code companion_terminal_eid}. */ @NonNull public abstract String companionTerminalEid(); @@ -162,8 +163,8 @@ public final class ManageSubscriptionOperation { public abstract String targetTerminalEid(); /** - * Returns the serial number of primary device. Used by HTTP parameter {@code - * target_terminal_sn}. + * Returns the serial number of primary device. Used by HTTP parameter + * {@code target_terminal_sn}. * * <p>This is a non-standard params required by some carriers. */ @@ -199,6 +200,20 @@ public final class ManageSubscriptionOperation { @NonNull public abstract String planId(); + /** + * Returns the notification token used to register for entitlement configuration request + * from network. Used by HTTP parameter {@code notif_token}. + */ + @NonNull + public abstract String notificationToken(); + + /** + * Returns the action associated with the notification token. Used by HTTP parameter + * {@code notif_action}. + */ + @NotificationAction + public abstract int notificationAction(); + /** Returns a new {@link Builder} object. */ @NonNull public static Builder builder() { @@ -223,7 +238,9 @@ public final class ManageSubscriptionOperation { .setTargetTerminalModel("") .setOldTerminalId("") .setOldTerminalIccid("") - .setPlanId(""); + .setPlanId("") + .setNotificationToken("") + .setNotificationAction(Ts43Constants.NOTIFICATION_ACTION_ENABLE_FCM); } /** Builder */ @@ -242,8 +259,8 @@ public final class ManageSubscriptionOperation { public abstract Builder setAppId(@NonNull @AppId String appId); /** - * Sets the detailed type of the eSIM ODSA operation. Used by HTTP parameter {@code - * operation_type} if set. + * Sets the detailed type of the eSIM ODSA operation. Used by HTTP parameter + * {@code operation_type} if set. * * @param operationType The detailed type of the eSIM ODSA operation. * @return The builder. @@ -255,14 +272,19 @@ public final class ManageSubscriptionOperation { * Sets the unique identifier of the companion device, like IMEI. Used by HTTP parameter * {@code companion_terminal_id} if set. * + * <p>Used by companion device ODSA operation. + * + * @param companionTerminalId The unique identifier of the companion device. * @return The builder. */ @NonNull public abstract Builder setCompanionTerminalId(String companionTerminalId); /** - * Sets the OEM of the companion device. Used by HTTP parameter {@code - * companion_terminal_vendor} if set. + * Sets the OEM of the companion device. Used by HTTP parameter + * {@code companion_terminal_vendor} if set. + * + * <p>Used by companion device ODSA operation. * * @param companionTerminalVendor The OEM of the companion device. * @return The builder. @@ -272,8 +294,8 @@ public final class ManageSubscriptionOperation { @NonNull String companionTerminalVendor); /** - * Sets the model of the companion device. Used by HTTP parameter {@code - * companion_terminal_model} if set. + * Sets the model of the companion device. Used by HTTP parameter + * {@code companion_terminal_model} if set. * * <p>Used by companion device ODSA operation. * @@ -285,8 +307,8 @@ public final class ManageSubscriptionOperation { @NonNull String companionTerminalModel); /** - * Sets the software version of the companion device. Used by HTTP parameter {@code - * companion_terminal_sw_version} if set. + * Sets the software version of the companion device. Used by HTTP parameter + * {@code companion_terminal_sw_version} if set. * * <p>Used by companion device ODSA operation. * @@ -298,8 +320,8 @@ public final class ManageSubscriptionOperation { @NonNull String companionTerminalSoftwareVersion); /** - * Sets the user-friendly version of the companion device. Used by HTTP parameter {@code - * companion_terminal_friendly_name} if set. + * Sets the user-friendly version of the companion device. Used by HTTP parameter + * {@code companion_terminal_friendly_name} if set. * * <p>Used by companion device ODSA operation. * @@ -325,8 +347,8 @@ public final class ManageSubscriptionOperation { @NonNull @CompanionService String companionTerminalService); /** - * Sets the ICCID of the companion device. Used by HTTP parameter {@code - * companion_terminal_iccid} if set. + * Sets the ICCID of the companion device. Used by HTTP parameter + * {@code companion_terminal_iccid} if set. * * <p>Used by companion device ODSA operation. * @@ -377,7 +399,8 @@ public final class ManageSubscriptionOperation { /** * Sets the unique identifiers of the primary device eSIM if more than one, like the - * IMEIs on dual-SIM devices. Used by HTTP parameter {@code target_terminal_imeis}. + * IMEIs on dual-SIM devices. Used by HTTP parameter {@code target_terminal_imeis} + * if set. * * <p>This is a non-standard params required by some carriers. * @@ -385,6 +408,7 @@ public final class ManageSubscriptionOperation { * than one. * @return The builder. */ + @NonNull public abstract Builder setTargetTerminalIds( @NonNull ImmutableList<String> targetTerminalIds); @@ -428,8 +452,10 @@ public final class ManageSubscriptionOperation { public abstract Builder setTargetTerminalEid(@NonNull String targetTerminalEid); /** - * Sets the serial number of primary device. Used by HTTP parameter {@code - * target_terminal_sn}. + * Sets the serial number of primary device. Used by HTTP parameter + * {@code target_terminal_sn} if set. + * + * <p>Used by primary device ODSA operation. * * @param targetTerminalSerialNumber The serial number of primary device. This is a * non-standard params required by some carriers. @@ -441,7 +467,9 @@ public final class ManageSubscriptionOperation { /** * Sets the model of primary device. Used by HTTP parameter - * {@code target_terminal_model}. + * {@code target_terminal_model} if set. + * + * <p>Used by primary device ODSA operation. * * @param targetTerminalModel The model of primary device. This is a non-standard params * required by some carriers. @@ -463,7 +491,8 @@ public final class ManageSubscriptionOperation { public abstract Builder setOldTerminalId(@NonNull String oldTerminalId); /** - * Sets the ICCID old device eSIM. Used by HTTP parameter "old_terminal_iccid" if set. + * Sets the ICCID old device eSIM. Used by HTTP parameter {@code old_terminal_iccid} + * if set. * * <p>Used by primary device ODSA operation. * @@ -475,7 +504,9 @@ public final class ManageSubscriptionOperation { /** * Sets the identifier of the specific plan offered by an MNO. Used by HTTP parameter - * {@code plan_id}. + * {@code plan_id} if set. + * + * <p>Used by primary device ODSA operation. * * @param planId The identifier of the specific plan offered by an MNO. * @return The builder. @@ -483,6 +514,32 @@ public final class ManageSubscriptionOperation { @NonNull public abstract Builder setPlanId(@NonNull String planId); + /** + * Sets the notification token used to register for entitlement configuration request + * from network. Used by HTTP parameter {@code notif_token} if set. + * + * <p>Used by primary device ODSA operation. + * + * @param notificationToken The notification token used to register for entitlement + * configuration request from network. + * @return The builder. + */ + @NonNull + public abstract Builder setNotificationToken(@NonNull String notificationToken); + + /** + * Sets the action associated with the notification token. Used by HTTP parameter + * {@code notif_action} if set. + * + * <p>Used by primary device ODSA operation. + * + * @param notificationAction The action associated with the notification token. + * @return The builder. + */ + @NonNull + public abstract Builder setNotificationAction( + @NotificationAction int notificationAction); + /** Returns the {@link ManageSubscriptionRequest} object. */ @NonNull public abstract ManageSubscriptionRequest build(); @@ -491,8 +548,7 @@ public final class ManageSubscriptionOperation { /** * Manage subscription response described in GSMA Service Entitlement Configuration section - * 6.5.3 - * table 37. + * 6.5.3 table 37. */ @AutoValue public abstract static class ManageSubscriptionResponse extends OdsaResponse { diff --git a/java/com/android/libraries/entitlement/utils/Ts43Constants.java b/java/com/android/libraries/entitlement/utils/Ts43Constants.java index cd4485c..6eab0dc 100644 --- a/java/com/android/libraries/entitlement/utils/Ts43Constants.java +++ b/java/com/android/libraries/entitlement/utils/Ts43Constants.java @@ -16,6 +16,7 @@ package com.android.libraries.entitlement.utils; +import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.annotation.StringDef; @@ -93,7 +94,61 @@ public final class Ts43Constants { case APP_PRIVATE_USER_IDENTITY: case APP_PHONE_NUMBER_INFORMATION: return true; - default: // fall out + default: // fall through + } + return false; + } + + /** + * Action to disable notification token. + */ + public static final int NOTIFICATION_ACTION_DISABLE = 0; + + /** + * Action to enable GCM notification token. + */ + public static final int NOTIFICATION_ACTION_ENABLE_GCM = 1; + + /** + * Action to enable FCM notification token. + */ + public static final int NOTIFICATION_ACTION_ENABLE_FCM = 2; + + /** + * Action to enable WNS push notification token. + */ + public static final int NOTIFICATION_ACTION_ENABLE_WNS = 3; + + /** + * Action to enable APNS notification token. + */ + public static final int NOTIFICATION_ACTION_ENABLE_APNS = 4; + + @Retention(RetentionPolicy.SOURCE) + @IntDef({ + NOTIFICATION_ACTION_DISABLE, + NOTIFICATION_ACTION_ENABLE_GCM, + NOTIFICATION_ACTION_ENABLE_FCM, + NOTIFICATION_ACTION_ENABLE_WNS, + NOTIFICATION_ACTION_ENABLE_APNS, + }) + public @interface NotificationAction {} + + /** + * Check if the notification action is valid. + * + * @param notificationAction The notification action. + * @return {@code true} if valid, otherwise {@code false}. + */ + public static boolean isValidNotificationAction(@NotificationAction int notificationAction) { + switch (notificationAction) { + case NOTIFICATION_ACTION_DISABLE: + case NOTIFICATION_ACTION_ENABLE_GCM: + case NOTIFICATION_ACTION_ENABLE_FCM: + case NOTIFICATION_ACTION_ENABLE_WNS: + case NOTIFICATION_ACTION_ENABLE_APNS: + return true; + default: // fall through } return false; } |