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.NonNull; 20 21 import com.android.libraries.entitlement.EsimOdsaOperation; 22 import com.android.libraries.entitlement.EsimOdsaOperation.CompanionService; 23 import com.android.libraries.entitlement.EsimOdsaOperation.OdsaOperationType; 24 import com.android.libraries.entitlement.EsimOdsaOperation.OdsaServiceStatus; 25 import com.android.libraries.entitlement.utils.Ts43Constants; 26 import com.android.libraries.entitlement.utils.Ts43Constants.AppId; 27 28 import com.google.auto.value.AutoValue; 29 30 /** Manage service operation described in GSMA Service Entitlement Configuration section 6. */ 31 public final class ManageServiceOperation { 32 /** 33 * HTTP request parameters specific to on device service activation (ODSA) manage service 34 * request. See GSMA spec TS.43 section 6.2. 35 */ 36 @AutoValue 37 public abstract static class ManageServiceRequest { 38 /** 39 * Returns the application id. Can only be {@link Ts43Constants#APP_ODSA_COMPANION}, {@link 40 * Ts43Constants#APP_ODSA_PRIMARY}, or 41 * {@link Ts43Constants#APP_ODSA_SERVER_INITIATED_REQUESTS}. 42 */ 43 @AppId appId()44 public abstract String appId(); 45 46 /** 47 * Returns the detailed type of the eSIM ODSA operation. Used by HTTP parameter {@code 48 * operation_type}. 49 */ 50 @OdsaOperationType operationType()51 public abstract int operationType(); 52 53 /** 54 * Returns the unique identifier of the companion device, like IMEI. Used by HTTP parameter 55 * {@code companion_terminal_id}. 56 */ 57 @NonNull companionTerminalId()58 public abstract String companionTerminalId(); 59 60 /** 61 * Returns the OEM of the companion device. Used by HTTP parameter {@code 62 * companion_terminal_vendor}. 63 */ 64 @NonNull companionTerminalVendor()65 public abstract String companionTerminalVendor(); 66 67 /** 68 * Returns the model of the companion device. Used by HTTP parameter {@code 69 * companion_terminal_model}. 70 */ 71 @NonNull companionTerminalModel()72 public abstract String companionTerminalModel(); 73 74 /** 75 * Returns the software version of the companion device. Used by HTTP parameter {@code 76 * companion_terminal_sw_version}. 77 */ 78 @NonNull companionTerminalSoftwareVersion()79 public abstract String companionTerminalSoftwareVersion(); 80 81 /** 82 * Returns the user-friendly version of the companion device. Used by HTTP parameter {@code 83 * companion_terminal_friendly_name}. 84 */ 85 @NonNull companionTerminalFriendlyName()86 public abstract String companionTerminalFriendlyName(); 87 88 /** 89 * Returns the service type of the companion device, e.g. if the MSISDN is same as the 90 * primary device. Used by HTTP parameter {@code companion_terminal_service}. 91 */ 92 @NonNull 93 @CompanionService companionTerminalService()94 public abstract String companionTerminalService(); 95 96 /** 97 * Returns the ICCID of the companion device. Used by HTTP parameter {@code 98 * companion_terminal_iccid}. 99 */ 100 @NonNull companionTerminalIccid()101 public abstract String companionTerminalIccid(); 102 103 /** Returns a new {@link Builder} object. */ 104 @NonNull builder()105 public static Builder builder() { 106 return new AutoValue_ManageServiceOperation_ManageServiceRequest.Builder() 107 .setAppId(Ts43Constants.APP_UNKNOWN) 108 .setOperationType(EsimOdsaOperation.OPERATION_TYPE_NOT_SET) 109 .setCompanionTerminalId("") 110 .setCompanionTerminalVendor("") 111 .setCompanionTerminalModel("") 112 .setCompanionTerminalSoftwareVersion("") 113 .setCompanionTerminalFriendlyName("") 114 .setCompanionTerminalService(EsimOdsaOperation.COMPANION_SERVICE_UNKNOWN) 115 .setCompanionTerminalIccid(""); 116 } 117 118 /** Builder */ 119 @AutoValue.Builder 120 public abstract static class Builder { 121 /** 122 * Sets the application id. 123 * 124 * @param appId The application id. Can only be 125 * {@link Ts43Constants#APP_ODSA_COMPANION}, 126 * {@link Ts43Constants#APP_ODSA_PRIMARY}, or {@link 127 * Ts43Constants#APP_ODSA_SERVER_INITIATED_REQUESTS}. 128 * @return The builder. 129 */ 130 @NonNull setAppId(@onNull @ppId String appId)131 public abstract Builder setAppId(@NonNull @AppId String appId); 132 133 /** 134 * Sets the detailed type of the eSIM ODSA operation. 135 * 136 * @param operationType Operation type. Only {@link 137 * EsimOdsaOperation#OPERATION_TYPE_ACTIVATE_SERVICE} and {@link 138 * EsimOdsaOperation#OPERATION_TYPE_DEACTIVATE_SERVICE} are 139 * allowed. 140 * @return The builder. 141 */ 142 @NonNull setOperationType(@dsaOperationType int operationType)143 public abstract Builder setOperationType(@OdsaOperationType int operationType); 144 145 /** 146 * Sets the unique identifier of the companion device, like IMEI. Used by HTTP parameter 147 * {@code companion_terminal_id} if set. 148 * 149 * @param companionTerminalId The unique identifier of the companion device. 150 * @return The builder. 151 */ 152 @NonNull setCompanionTerminalId(String companionTerminalId)153 public abstract Builder setCompanionTerminalId(String companionTerminalId); 154 155 /** 156 * Sets the OEM of the companion device. Used by HTTP parameter {@code 157 * companion_terminal_vendor} if set. 158 * 159 * @param companionTerminalVendor The OEM of the companion device. 160 * @return The builder. 161 */ 162 @NonNull setCompanionTerminalVendor(String companionTerminalVendor)163 public abstract Builder setCompanionTerminalVendor(String companionTerminalVendor); 164 165 /** 166 * Sets the model of the companion device. Used by HTTP parameter {@code 167 * companion_terminal_model} if set. 168 * 169 * @param companionTerminalModel The model of the companion device. 170 * @return The builder. 171 */ 172 @NonNull setCompanionTerminalModel( @onNull String companionTerminalModel)173 public abstract Builder setCompanionTerminalModel( 174 @NonNull String companionTerminalModel); 175 176 /** 177 * Sets the software version of the companion device. Used by HTTP parameter {@code 178 * companion_terminal_sw_version} if set. 179 * 180 * @param companionTerminalSoftwareVersion The software version of the companion device. 181 * @return The builder. 182 */ 183 @NonNull setCompanionTerminalSoftwareVersion( @onNull String companionTerminalSoftwareVersion)184 public abstract Builder setCompanionTerminalSoftwareVersion( 185 @NonNull String companionTerminalSoftwareVersion); 186 187 /** 188 * Sets the user-friendly version of the companion device. Used by HTTP parameter {@code 189 * companion_terminal_friendly_name} if set. 190 * 191 * <p>Used by companion device ODSA operation. 192 * 193 * @param companionTerminalFriendlyName The user-friendly version of the companion 194 * device. 195 * @return The builder. 196 */ 197 @NonNull setCompanionTerminalFriendlyName( @onNull String companionTerminalFriendlyName)198 public abstract Builder setCompanionTerminalFriendlyName( 199 @NonNull String companionTerminalFriendlyName); 200 201 /** 202 * Sets the service type of the companion device, e.g. if the MSISDN is same as the 203 * primary device. Used by HTTP parameter {@code companion_terminal_service} if set. 204 * 205 * <p>Used by companion device ODSA operation. 206 * 207 * @param companionTerminalService The service type of the companion device. 208 * @return The builder. 209 */ 210 @NonNull setCompanionTerminalService( @onNull @ompanionService String companionTerminalService)211 public abstract Builder setCompanionTerminalService( 212 @NonNull @CompanionService String companionTerminalService); 213 214 /** 215 * Sets the ICCID of the companion device. Used by HTTP parameter {@code 216 * companion_terminal_iccid} if set. 217 * 218 * <p>Used by companion device ODSA operation. 219 * 220 * @param companionTerminalIccid The ICCID of the companion device. 221 * @return The builder. 222 */ 223 @NonNull setCompanionTerminalIccid( @onNull String companionTerminalIccid)224 public abstract Builder setCompanionTerminalIccid( 225 @NonNull String companionTerminalIccid); 226 227 /** Build the {@link ManageServiceRequest} object. */ 228 @NonNull build()229 public abstract ManageServiceRequest build(); 230 } 231 } 232 233 /** 234 * Manage service response described in GSMA Service Entitlement Configuration section 6.5.4 235 * table 39. 236 */ 237 @AutoValue 238 public abstract static class ManageServiceResponse extends OdsaResponse { 239 /** Service status. */ 240 @OdsaServiceStatus serviceStatus()241 public abstract int serviceStatus(); 242 243 /** Returns a new {@link ManageServiceResponse.Builder} object. */ 244 @NonNull builder()245 public static Builder builder() { 246 return new AutoValue_ManageServiceOperation_ManageServiceResponse.Builder() 247 .setServiceStatus(EsimOdsaOperation.SERVICE_STATUS_UNKNOWN); 248 } 249 250 /** Builder */ 251 @AutoValue.Builder 252 public abstract static class Builder extends OdsaResponse.Builder { 253 /** 254 * Set the service status. 255 * 256 * @param serviceStatus Service status 257 * @return The builder. 258 */ 259 @NonNull setServiceStatus(@dsaServiceStatus int serviceStatus)260 public abstract Builder setServiceStatus(@OdsaServiceStatus int serviceStatus); 261 262 /** Build the {@link ManageServiceResponse} object. */ 263 @NonNull build()264 public abstract ManageServiceResponse build(); 265 } 266 } 267 ManageServiceOperation()268 private ManageServiceOperation() { 269 } 270 } 271