1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.libraries.entitlement.odsa;
18 
19 import androidx.annotation.IntDef;
20 import androidx.annotation.NonNull;
21 import androidx.annotation.Nullable;
22 
23 import com.android.libraries.entitlement.EsimOdsaOperation;
24 import com.android.libraries.entitlement.EsimOdsaOperation.CompanionService;
25 import com.android.libraries.entitlement.EsimOdsaOperation.MessageButton;
26 import com.android.libraries.entitlement.EsimOdsaOperation.OdsaOperationType;
27 import com.android.libraries.entitlement.utils.HttpConstants;
28 import com.android.libraries.entitlement.utils.HttpConstants.ContentType;
29 import com.android.libraries.entitlement.utils.Ts43Constants;
30 import com.android.libraries.entitlement.utils.Ts43Constants.AppId;
31 import com.android.libraries.entitlement.utils.Ts43Constants.NotificationAction;
32 
33 import com.google.auto.value.AutoValue;
34 import com.google.common.collect.ImmutableList;
35 
36 import java.lang.annotation.Retention;
37 import java.lang.annotation.RetentionPolicy;
38 import java.net.URL;
39 
40 /**
41  * Manage subscription operation described in GSMA Service Entitlement Configuration section 6.5.3.
42  */
43 public final class ManageSubscriptionOperation {
44     /**
45      * HTTP request parameters specific to on device service activation (ODSA) manage subscription
46      * request. See GSMA spec TS.43 section 6.2.
47      */
48     @AutoValue
49     public abstract static class ManageSubscriptionRequest {
50         /**
51          * Returns the application id. Can only be {@link Ts43Constants#APP_ODSA_COMPANION},
52          * {@link Ts43Constants#APP_ODSA_PRIMARY}, or
53          * {@link Ts43Constants#APP_ODSA_SERVER_INITIATED_REQUESTS}.
54          */
55         @NonNull
56         @AppId
appId()57         public abstract String appId();
58 
59         /**
60          * Returns the detailed type of the eSIM ODSA operation. Used by HTTP parameter
61          * {@code operation_type}.
62          */
63         @OdsaOperationType
operationType()64         public abstract int operationType();
65 
66         /**
67          * Returns the unique identifier of the companion device, like IMEI. Used by HTTP parameter
68          * {@code companion_terminal_id}.
69          */
70         @NonNull
companionTerminalId()71         public abstract String companionTerminalId();
72 
73         /**
74          * Returns the OEM of the companion device. Used by HTTP parameter
75          * {@code companion_terminal_vendor}.
76          */
77         @NonNull
companionTerminalVendor()78         public abstract String companionTerminalVendor();
79 
80         /**
81          * Returns the model of the companion device. Used by HTTP parameter
82          * {@code companion_terminal_model}.
83          */
84         @NonNull
companionTerminalModel()85         public abstract String companionTerminalModel();
86 
87         /**
88          * Returns the software version of the companion device. Used by HTTP parameter
89          * {@code companion_terminal_sw_version}.
90          */
91         @NonNull
companionTerminalSoftwareVersion()92         public abstract String companionTerminalSoftwareVersion();
93 
94         /**
95          * Returns the user-friendly version of the companion device. Used by HTTP parameter
96          * {@code companion_terminal_friendly_name}.
97          */
98         @NonNull
companionTerminalFriendlyName()99         public abstract String companionTerminalFriendlyName();
100 
101         /**
102          * Returns the service type of the companion device, e.g. if the MSISDN is same as the
103          * primary device. Used by HTTP parameter {@code companion_terminal_service}.
104          */
105         @NonNull
106         @CompanionService
companionTerminalService()107         public abstract String companionTerminalService();
108 
109         /**
110          * Returns the ICCID of the companion device. Used by HTTP parameter
111          * {@code companion_terminal_iccid}.
112          */
113         @NonNull
companionTerminalIccid()114         public abstract String companionTerminalIccid();
115 
116         /**
117          * Returns the EID of the companion device. Used by HTTP parameter
118          * {@code companion_terminal_eid}.
119          */
120         @NonNull
companionTerminalEid()121         public abstract String companionTerminalEid();
122 
123         /**
124          * Returns the ICCID of the primary device eSIM. Used by HTTP parameter
125          * {@code terminal_iccid}.
126          */
127         @NonNull
terminalIccid()128         public abstract String terminalIccid();
129 
130         /**
131          * Returns the eUICC identifier (EID) of the primary device eSIM. Used by HTTP parameter
132          * {@code terminal_eid}.
133          */
134         @NonNull
terminalEid()135         public abstract String terminalEid();
136 
137         /**
138          * Returns the unique identifier of the primary device eSIM, like the IMEI associated with
139          * the eSIM. Used by HTTP parameter {@code target_terminal_id}.
140          */
141         @NonNull
targetTerminalId()142         public abstract String targetTerminalId();
143 
144         /**
145          * Returns the unique identifiers of the primary device eSIM if more than one, like the
146          * IMEIs on dual-SIM devices. Used by HTTP parameter {@code target_terminal_imeis}.
147          *
148          * <p>This is a non-standard params required by some carriers.
149          */
150         @NonNull
targetTerminalIds()151         public abstract ImmutableList<String> targetTerminalIds();
152 
153         /**
154          * Returns the ICCID primary device eSIM. Used by HTTP parameter
155          * {@code target_terminal_iccid}.
156          */
157         @NonNull
targetTerminalIccid()158         public abstract String targetTerminalIccid();
159 
160         /**
161          * Returns the eUICC identifier (EID) of the primary device eSIM. Used by HTTP parameter
162          * {@code target_terminal_eid}.
163          */
164         @NonNull
targetTerminalEid()165         public abstract String targetTerminalEid();
166 
167         /**
168          * Returns the serial number of primary device. Used by HTTP parameter
169          * {@code target_terminal_sn}.
170          *
171          * <p>This is a non-standard params required by some carriers.
172          */
173         @NonNull
targetTerminalSerialNumber()174         public abstract String targetTerminalSerialNumber();
175 
176         /**
177          * Returns the model of primary device. Used by HTTP parameter
178          * {@code target_terminal_model}.
179          *
180          * <p>This is a non-standard params required by some carriers.
181          */
182         @NonNull
targetTerminalModel()183         public abstract String targetTerminalModel();
184 
185         /**
186          * Returns the unique identifier of the old device eSIM, like the IMEI associated with the
187          * eSIM. Used by HTTP parameter {@code old_terminal_id}.
188          */
189         @NonNull
oldTerminalId()190         public abstract String oldTerminalId();
191 
192         /**
193          * Returns the ICCID of old device eSIM. Used by HTTP parameter {@code old_terminal_iccid}.
194          */
195         @NonNull
oldTerminalIccid()196         public abstract String oldTerminalIccid();
197 
198         /**
199          * Returns the identifier of the specific plan offered by an MNO. Used by HTTP parameter
200          * {@code plan_id}.
201          */
202         @NonNull
planId()203         public abstract String planId();
204 
205         /**
206          * Returns the notification token used to register for entitlement configuration request
207          * from network. Used by HTTP parameter {@code notif_token}.
208          */
209         @NonNull
notificationToken()210         public abstract String notificationToken();
211 
212         /**
213          * Returns the action associated with the notification token. Used by HTTP parameter
214          * {@code notif_action}.
215          */
216         @NotificationAction
notificationAction()217         public abstract int notificationAction();
218 
219         /**
220          * Returns the user response to the MSG content.
221          * Used by HTTP parameter {@code MSG_response}.
222          */
223         @NonNull
messageResponse()224         public abstract String messageResponse();
225 
226         /**
227          * Returns whether the user has accepted or rejected the MSG content.
228          * Used by HTTP parameter {@code MSG_btn}.
229          */
230         @NonNull
231         @MessageButton
messageButton()232         public abstract String messageButton();
233 
234         /** Returns a new {@link Builder} object. */
235         @NonNull
builder()236         public static Builder builder() {
237             return new AutoValue_ManageSubscriptionOperation_ManageSubscriptionRequest.Builder()
238                     .setAppId(Ts43Constants.APP_UNKNOWN)
239                     .setOperationType(EsimOdsaOperation.OPERATION_TYPE_NOT_SET)
240                     .setCompanionTerminalId("")
241                     .setCompanionTerminalVendor("")
242                     .setCompanionTerminalModel("")
243                     .setCompanionTerminalSoftwareVersion("")
244                     .setCompanionTerminalFriendlyName("")
245                     .setCompanionTerminalService(EsimOdsaOperation.COMPANION_SERVICE_UNKNOWN)
246                     .setCompanionTerminalIccid("")
247                     .setCompanionTerminalEid("")
248                     .setTerminalIccid("")
249                     .setTerminalEid("")
250                     .setTargetTerminalId("")
251                     .setTargetTerminalIds(ImmutableList.of())
252                     .setTargetTerminalIccid("")
253                     .setTargetTerminalEid("")
254                     .setTargetTerminalSerialNumber("")
255                     .setTargetTerminalModel("")
256                     .setOldTerminalId("")
257                     .setOldTerminalIccid("")
258                     .setPlanId("")
259                     .setNotificationToken("")
260                     .setNotificationAction(Ts43Constants.NOTIFICATION_ACTION_ENABLE_FCM)
261                     .setMessageResponse("")
262                     .setMessageButton("");
263         }
264 
265         /** Builder */
266         @AutoValue.Builder
267         public abstract static class Builder {
268             /**
269              * Sets the application id.
270              *
271              * @param appId The application id. Can only be
272              *              {@link Ts43Constants#APP_ODSA_COMPANION},
273              *              {@link Ts43Constants#APP_ODSA_PRIMARY}, or {@link
274              *              Ts43Constants#APP_ODSA_SERVER_INITIATED_REQUESTS}.
275              * @return The builder.
276              */
277             @NonNull
setAppId(@onNull @ppId String appId)278             public abstract Builder setAppId(@NonNull @AppId String appId);
279 
280             /**
281              * Sets the detailed type of the eSIM ODSA operation. Used by HTTP parameter
282              * {@code operation_type} if set.
283              *
284              * @param operationType The detailed type of the eSIM ODSA operation.
285              * @return The builder.
286              */
287             @NonNull
setOperationType(@dsaOperationType int operationType)288             public abstract Builder setOperationType(@OdsaOperationType int operationType);
289 
290             /**
291              * Sets the unique identifier of the companion device, like IMEI. Used by HTTP parameter
292              * {@code companion_terminal_id} if set.
293              *
294              * <p>Used by companion device ODSA operation.
295              *
296              * @param companionTerminalId The unique identifier of the companion device.
297              * @return The builder.
298              */
299             @NonNull
setCompanionTerminalId(String companionTerminalId)300             public abstract Builder setCompanionTerminalId(String companionTerminalId);
301 
302             /**
303              * Sets the OEM of the companion device. Used by HTTP parameter
304              * {@code companion_terminal_vendor} if set.
305              *
306              * <p>Used by companion device ODSA operation.
307              *
308              * @param companionTerminalVendor The OEM of the companion device.
309              * @return The builder.
310              */
311             @NonNull
setCompanionTerminalVendor( @onNull String companionTerminalVendor)312             public abstract Builder setCompanionTerminalVendor(
313                     @NonNull String companionTerminalVendor);
314 
315             /**
316              * Sets the model of the companion device. Used by HTTP parameter
317              * {@code companion_terminal_model} if set.
318              *
319              * <p>Used by companion device ODSA operation.
320              *
321              * @param companionTerminalModel The model of the companion device.
322              * @return The builder.
323              */
324             @NonNull
setCompanionTerminalModel( @onNull String companionTerminalModel)325             public abstract Builder setCompanionTerminalModel(
326                     @NonNull String companionTerminalModel);
327 
328             /**
329              * Sets the software version of the companion device. Used by HTTP parameter
330              * {@code companion_terminal_sw_version} if set.
331              *
332              * <p>Used by companion device ODSA operation.
333              *
334              * @param companionTerminalSoftwareVersion The software version of the companion device.
335              * @return The builder.
336              */
337             @NonNull
setCompanionTerminalSoftwareVersion( @onNull String companionTerminalSoftwareVersion)338             public abstract Builder setCompanionTerminalSoftwareVersion(
339                     @NonNull String companionTerminalSoftwareVersion);
340 
341             /**
342              * Sets the user-friendly version of the companion device. Used by HTTP parameter
343              * {@code companion_terminal_friendly_name} if set.
344              *
345              * <p>Used by companion device ODSA operation.
346              *
347              * @param companionTerminalFriendlyName The user-friendly version of the companion
348              *                                      device.
349              * @return The builder.
350              */
351             @NonNull
setCompanionTerminalFriendlyName( @onNull String companionTerminalFriendlyName)352             public abstract Builder setCompanionTerminalFriendlyName(
353                     @NonNull String companionTerminalFriendlyName);
354 
355             /**
356              * Sets the service type of the companion device, e.g. if the MSISDN is same as the
357              * primary device. Used by HTTP parameter {@code companion_terminal_service} if set.
358              *
359              * <p>Used by companion device ODSA operation.
360              *
361              * @param companionTerminalService The service type of the companion device.
362              * @return The builder.
363              */
364             @NonNull
setCompanionTerminalService( @onNull @ompanionService String companionTerminalService)365             public abstract Builder setCompanionTerminalService(
366                     @NonNull @CompanionService String companionTerminalService);
367 
368             /**
369              * Sets the ICCID of the companion device. Used by HTTP parameter
370              * {@code companion_terminal_iccid} if set.
371              *
372              * <p>Used by companion device ODSA operation.
373              *
374              * @param companionTerminalIccid The ICCID of the companion device.
375              * @return The builder.
376              */
377             @NonNull
setCompanionTerminalIccid( @onNull String companionTerminalIccid)378             public abstract Builder setCompanionTerminalIccid(
379                     @NonNull String companionTerminalIccid);
380 
381             /**
382              * Sets the eUICC identifier (EID) of the companion device. Used by HTTP parameter
383              * {@code companion_terminal_eid} if set.
384              *
385              * <p>Used by companion device ODSA operation.
386              *
387              * @param companionTerminalEid The eUICC identifier (EID) of the companion device.
388              * @return The builder.
389              */
390             @NonNull
setCompanionTerminalEid(@onNull String companionTerminalEid)391             public abstract Builder setCompanionTerminalEid(@NonNull String companionTerminalEid);
392 
393             /**
394              * Sets the ICCID of the primary device eSIM in case of primary SIM not present. Used by
395              * HTTP parameter {@code terminal_eid} if set.
396              *
397              * <p>Used by primary device ODSA operation.
398              *
399              * @param terminalIccid The ICCID of the primary device eSIM in case of primary SIM not
400              *                      present.
401              * @return The builder.
402              */
403             @NonNull
setTerminalIccid(@onNull String terminalIccid)404             public abstract Builder setTerminalIccid(@NonNull String terminalIccid);
405 
406             /**
407              * Sets the eUICC identifier (EID) of the primary device eSIM in case of primary SIM not
408              * present. Used by HTTP parameter {@code terminal_eid} if set.
409              *
410              * <p>Used by primary device ODSA operation.
411              *
412              * @param terminalEid The eUICC identifier (EID) of the primary device eSIM in case of
413              *                    primary SIM not present.
414              * @return The builder.
415              */
416             @NonNull
setTerminalEid(@onNull String terminalEid)417             public abstract Builder setTerminalEid(@NonNull String terminalEid);
418 
419             /**
420              * Sets the unique identifiers of the primary device eSIM if more than one, like the
421              * IMEIs on dual-SIM devices. Used by HTTP parameter {@code target_terminal_imeis}
422              * if set.
423              *
424              * <p>This is a non-standard params required by some carriers.
425              *
426              * @param targetTerminalIds The unique identifiers of the primary device eSIM if more
427              *                          than one.
428              * @return The builder.
429              */
430             @NonNull
setTargetTerminalIds( @onNull ImmutableList<String> targetTerminalIds)431             public abstract Builder setTargetTerminalIds(
432                     @NonNull ImmutableList<String> targetTerminalIds);
433 
434             /**
435              * Sets the unique identifier of the primary device eSIM in case of multiple SIM, like
436              * the IMEI associated with the eSIM. Used by HTTP parameter {@code target_terminal_id}
437              * if set.
438              *
439              * <p>Used by primary device ODSA operation.
440              *
441              * @param targetTerminalId The unique identifier of the primary device eSIM in case of
442              *                         multiple SIM.
443              * @return The builder.
444              */
445             @NonNull
setTargetTerminalId(@onNull String targetTerminalId)446             public abstract Builder setTargetTerminalId(@NonNull String targetTerminalId);
447 
448             /**
449              * Sets the ICCID primary device eSIM in case of multiple SIM. Used by HTTP parameter
450              * {@code target_terminal_iccid} if set.
451              *
452              * <p>Used by primary device ODSA operation.
453              *
454              * @param targetTerminalIccid The ICCID primary device eSIM in case of multiple SIM.
455              * @return The builder.
456              */
457             @NonNull
setTargetTerminalIccid(@onNull String targetTerminalIccid)458             public abstract Builder setTargetTerminalIccid(@NonNull String targetTerminalIccid);
459 
460             /**
461              * Sets the eUICC identifier (EID) of the primary device eSIM in case of multiple SIM.
462              * Used by HTTP parameter {@code target_terminal_eid} if set.
463              *
464              * <p>Used by primary device ODSA operation.
465              *
466              * @param targetTerminalEid The eUICC identifier (EID) of the primary device eSIM in
467              *                          case of multiple SIM.
468              * @return The builder.
469              */
470             @NonNull
setTargetTerminalEid(@onNull String targetTerminalEid)471             public abstract Builder setTargetTerminalEid(@NonNull String targetTerminalEid);
472 
473             /**
474              * Sets the serial number of primary device. Used by HTTP parameter
475              * {@code target_terminal_sn} if set.
476              *
477              * <p>Used by primary device ODSA operation.
478              *
479              * @param targetTerminalSerialNumber The serial number of primary device. This is a
480              *                                   non-standard params required by some carriers.
481              * @return The builder.
482              */
483             @NonNull
setTargetTerminalSerialNumber( @onNull String targetTerminalSerialNumber)484             public abstract Builder setTargetTerminalSerialNumber(
485                     @NonNull String targetTerminalSerialNumber);
486 
487             /**
488              * Sets the model of primary device. Used by HTTP parameter
489              * {@code target_terminal_model} if set.
490              *
491              * <p>Used by primary device ODSA operation.
492              *
493              * @param targetTerminalModel The model of primary device. This is a non-standard params
494              *                            required by some carriers.
495              * @return The builder.
496              */
497             @NonNull
setTargetTerminalModel(@onNull String targetTerminalModel)498             public abstract Builder setTargetTerminalModel(@NonNull String targetTerminalModel);
499 
500             /**
501              * Sets the unique identifier of the old device eSIM, like the IMEI associated with the
502              * eSIM.Used by HTTP parameter {@code old_terminal_id} if set.
503              *
504              * <p>Used by primary device ODSA operation.
505              *
506              * @param oldTerminalId The unique identifier of the old device eSIM.
507              * @return The builder.
508              */
509             @NonNull
setOldTerminalId(@onNull String oldTerminalId)510             public abstract Builder setOldTerminalId(@NonNull String oldTerminalId);
511 
512             /**
513              * Sets the ICCID old device eSIM. Used by HTTP parameter {@code old_terminal_iccid}
514              * if set.
515              *
516              * <p>Used by primary device ODSA operation.
517              *
518              * @param oldTerminalIccid The ICCID old device eSIM.
519              * @return The builder.
520              */
521             @NonNull
setOldTerminalIccid(@onNull String oldTerminalIccid)522             public abstract Builder setOldTerminalIccid(@NonNull String oldTerminalIccid);
523 
524             /**
525              * Sets the identifier of the specific plan offered by an MNO. Used by HTTP parameter
526              * {@code plan_id} if set.
527              *
528              * <p>Used by primary device ODSA operation.
529              *
530              * @param planId The identifier of the specific plan offered by an MNO.
531              * @return The builder.
532              */
533             @NonNull
setPlanId(@onNull String planId)534             public abstract Builder setPlanId(@NonNull String planId);
535 
536             /**
537              * Sets the notification token used to register for entitlement configuration request
538              * from network. Used by HTTP parameter {@code notif_token} if set.
539              *
540              * <p>Used by primary device ODSA operation.
541              *
542              * @param notificationToken The notification token used to register for entitlement
543              *                          configuration request from network.
544              * @return The builder.
545              */
546             @NonNull
setNotificationToken(@onNull String notificationToken)547             public abstract Builder setNotificationToken(@NonNull String notificationToken);
548 
549             /**
550              * Sets the action associated with the notification token. Used by HTTP parameter
551              * {@code notif_action} if set.
552              *
553              * <p>Used by primary device ODSA operation.
554              *
555              * @param notificationAction The action associated with the notification token.
556              * @return The builder.
557              */
558             @NonNull
setNotificationAction( @otificationAction int notificationAction)559             public abstract Builder setNotificationAction(
560                     @NotificationAction int notificationAction);
561 
562             /**
563              * Sets the user response to the MSG content. Used by HTTP parameter
564              * {@code MSG_response} if set.
565              *
566              * <p>Used by primary device ODSA operation.
567              *
568              * @param messageResponse The response entered by the user on the device UI.
569              * @return The builder.
570              */
571             @NonNull
setMessageResponse(@onNull String messageResponse)572             public abstract Builder setMessageResponse(@NonNull String messageResponse);
573 
574             /**
575              * Sets whether the user has accepted or rejected the MSG content. Used by HTTP
576              * parameter {@code MSG_btn} if set.
577              *
578              * <p>Used by primary device ODSA operation.
579              *
580              * @param messageButton Whether the user has accepted or rejected the MSG content.
581              * @return The builder.
582              */
583             @NonNull
setMessageButton(@onNull String messageButton)584             public abstract Builder setMessageButton(@NonNull String messageButton);
585 
586             /** Returns the {@link ManageSubscriptionRequest} object. */
587             @NonNull
build()588             public abstract ManageSubscriptionRequest build();
589         }
590     }
591 
592     /**
593      * Manage subscription response described in GSMA Service Entitlement Configuration section
594      * 6.5.3 table 37.
595      */
596     @AutoValue
597     public abstract static class ManageSubscriptionResponse extends OdsaResponse {
598         /** Subscription result unknown. */
599         public static final int SUBSCRIPTION_RESULT_UNKNOWN = -1;
600 
601         /**
602          * Indicates that end-user must go through the subscription web view procedure, using
603          * information included below.
604          */
605         public static final int SUBSCRIPTION_RESULT_CONTINUE_TO_WEBSHEET = 1;
606 
607         /**
608          * Indicates that a eSIM profile must be downloaded by the device, with further information
609          * included in response.
610          */
611         public static final int SUBSCRIPTION_RESULT_DOWNLOAD_PROFILE = 2;
612 
613         /**
614          * Indicates that subscription flow has ended and the end-user has already downloaded the
615          * eSIM profile so there is no need to perform any other action.
616          */
617         public static final int SUBSCRIPTION_RESULT_DONE = 3;
618 
619         /**
620          * Indicates that an eSIM profile is not ready to be downloaded when a user requests to
621          * transfer subscription or to add the new subscription through native UX on the eSIM
622          * device.
623          */
624         public static final int SUBSCRIPTION_RESULT_DELAYED_DOWNLOAD = 4;
625 
626         /**
627          * Indicates that subscription flow has ended without completing the ODSA procedure. An eSIM
628          * profile is not available.
629          */
630         public static final int SUBSCRIPTION_RESULT_DISMISS = 5;
631 
632         /**
633          * Indicates that the profile in use needs to be deleted to complete the subscription
634          * transfer.
635          */
636         public static final int SUBSCRIPTION_RESULT_DELETE_PROFILE_IN_USE = 6;
637 
638         /**
639          * Indicates that implementing redownloadable profile is mandatory. If device is not able to
640          * support this, it should end the process.
641          * This parameter only applies when peration_type is
642          * {@link EsimOdsaOperation#OPERATION_TYPE_TRANSFER_SUBSCRIPTION}.
643          */
644         public static final int SUBSCRIPTION_RESULT_REDOWNLOADABLE_PROFILE_IS_MANDATORY = 7;
645 
646         /**
647          * Indicates that user input without a webview is required in order to complete the
648          * operation_type requested with the information submitted to the ECS.
649          */
650         public static final int SUBSCRIPTION_RESULT_REQUIRES_USER_INPUT = 8;
651 
652         @Retention(RetentionPolicy.SOURCE)
653         @IntDef({
654                 SUBSCRIPTION_RESULT_UNKNOWN,
655                 SUBSCRIPTION_RESULT_CONTINUE_TO_WEBSHEET,
656                 SUBSCRIPTION_RESULT_DOWNLOAD_PROFILE,
657                 SUBSCRIPTION_RESULT_DONE,
658                 SUBSCRIPTION_RESULT_DELAYED_DOWNLOAD,
659                 SUBSCRIPTION_RESULT_DISMISS,
660                 SUBSCRIPTION_RESULT_DELETE_PROFILE_IN_USE,
661                 SUBSCRIPTION_RESULT_REDOWNLOADABLE_PROFILE_IS_MANDATORY,
662                 SUBSCRIPTION_RESULT_REQUIRES_USER_INPUT
663         })
664         public @interface SubscriptionResult {
665         }
666 
667         /** The subscription result. */
668         @SubscriptionResult
subscriptionResult()669         public abstract int subscriptionResult();
670 
671         /**
672          * URL refers to web views responsible for a certain action on the eSIM device subscription.
673          * The
674          * Service Provider can provide different URL based on the operation_type input parameter
675          * ({@link EsimOdsaOperation#OPERATION_TYPE_SUBSCRIBE}, {@link
676          * EsimOdsaOperation#OPERATION_TYPE_UNSUBSCRIBE}, {@link
677          * EsimOdsaOperation#OPERATION_TYPE_CHANGE_SUBSCRIPTION}).
678          *
679          * <p>{@code null} if {@link #subscriptionResult()} is not {@link
680          * #SUBSCRIPTION_RESULT_CONTINUE_TO_WEBSHEET}.
681          */
682         @Nullable
subscriptionServiceUrl()683         public abstract URL subscriptionServiceUrl();
684 
685         /**
686          * User data sent to the Service Provider when requesting the
687          * {@link #subscriptionServiceUrl()}
688          * web view. It should contain user-specific attributes to improve user experience.
689          *
690          * <p>{@code null} if {@link #subscriptionResult()} is not {@link
691          * #SUBSCRIPTION_RESULT_CONTINUE_TO_WEBSHEET}.
692          */
693         @Nullable
subscriptionServiceUserData()694         public abstract String subscriptionServiceUserData();
695 
696         /**
697          * Specifies content and HTTP method to use when reaching out to the web server specified by
698          * {@link #subscriptionServiceUrl()}.
699          */
700         @ContentType
subscriptionServiceContentsType()701         public abstract int subscriptionServiceContentsType();
702 
703         /**
704          * Specifies how and where to download the eSIM profile associated with the companion or
705          * primary device.
706          *
707          * <p>{@code null} if {@link #subscriptionResult()} is not {@link
708          * #SUBSCRIPTION_RESULT_DOWNLOAD_PROFILE}.
709          */
710         @Nullable
downloadInfo()711         public abstract DownloadInfo downloadInfo();
712 
713         /** Returns the builder. */
714         @NonNull
builder()715         public static Builder builder() {
716             return new AutoValue_ManageSubscriptionOperation_ManageSubscriptionResponse.Builder()
717                     .setSubscriptionResult(SUBSCRIPTION_RESULT_UNKNOWN)
718                     .setSubscriptionServiceContentsType(HttpConstants.UNKNOWN);
719         }
720 
721         /** Builder */
722         @AutoValue.Builder
723         public abstract static class Builder extends OdsaResponse.Builder {
724             /**
725              * Set subscription result.
726              *
727              * @param subscriptionResult The subscription result.
728              * @return The builder.
729              */
730             @NonNull
setSubscriptionResult( @ubscriptionResult int subscriptionResult)731             public abstract Builder setSubscriptionResult(
732                     @SubscriptionResult int subscriptionResult);
733 
734             /**
735              * Set the URL refers to web views responsible for a certain action on the eSIM device
736              * subscription.
737              *
738              * @param url URL refers to web views responsible for a certain action on the eSIM
739              *            device subscription. The Service Provider can provide different URL based
740              *            on the operation_type input parameter (
741              *            {@link EsimOdsaOperation#OPERATION_TYPE_SUBSCRIBE}, {@link
742              *            EsimOdsaOperation#OPERATION_TYPE_UNSUBSCRIBE}, {@link
743              *            EsimOdsaOperation#OPERATION_TYPE_CHANGE_SUBSCRIPTION}).
744              * @return The builder.
745              */
746             @NonNull
setSubscriptionServiceUrl(@onNull URL url)747             public abstract Builder setSubscriptionServiceUrl(@NonNull URL url);
748 
749             /**
750              * Set user data sent to the Service Provider.
751              *
752              * @param userData User data sent to the Service Provider when requesting the {@link
753              *                 #subscriptionServiceUrl()} web view. It should contain user-specific
754              *                 attributes to improve user experience.
755              * @return The builder.
756              */
757             @NonNull
setSubscriptionServiceUserData(@onNull String userData)758             public abstract Builder setSubscriptionServiceUserData(@NonNull String userData);
759 
760             /**
761              * Set the content type.
762              *
763              * @param contentType Specifies content and HTTP method to use when reaching out to the
764              *                    web server specified by {@link #subscriptionServiceUrl()}.
765              * @return The builder.
766              */
767             @NonNull
setSubscriptionServiceContentsType( @ontentType int contentType)768             public abstract Builder setSubscriptionServiceContentsType(
769                     @ContentType int contentType);
770 
771             /**
772              * Set download information of eSIM profile associated with the companion or primary
773              * device.
774              *
775              * @param downloadInfo Specifies how and where to download the eSIM profile associated
776              *                     with the companion or primary device.
777              * @return The builder.
778              */
779             @NonNull
setDownloadInfo(@onNull DownloadInfo downloadInfo)780             public abstract Builder setDownloadInfo(@NonNull DownloadInfo downloadInfo);
781 
782             /** Returns the {@link ManageSubscriptionResponse} object. */
783             @NonNull
build()784             public abstract ManageSubscriptionResponse build();
785         }
786     }
787 
ManageSubscriptionOperation()788     private ManageSubscriptionOperation() {
789     }
790 }
791