Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | package android.service.euicc; |
| 17 | |
Peter Wang | 2ab852d | 2019-09-09 13:57:41 -0700 | [diff] [blame] | 18 | import static android.telephony.euicc.EuiccCardManager.ResetOption; |
| 19 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 20 | import android.annotation.CallSuper; |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 21 | import android.annotation.IntDef; |
| 22 | import android.annotation.NonNull; |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 23 | import android.annotation.Nullable; |
Jiashen Wang | 216ae8d | 2019-10-18 11:00:11 -0700 | [diff] [blame] | 24 | import android.annotation.SdkConstant; |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 25 | import android.annotation.SystemApi; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 26 | import android.app.Service; |
| 27 | import android.content.Intent; |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 28 | import android.os.Bundle; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 29 | import android.os.IBinder; |
| 30 | import android.os.RemoteException; |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 31 | import android.telephony.TelephonyManager; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 32 | import android.telephony.euicc.DownloadableSubscription; |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 33 | import android.telephony.euicc.EuiccInfo; |
Qingxi Li | 5405836 | 2017-12-13 15:13:02 -0800 | [diff] [blame] | 34 | import android.telephony.euicc.EuiccManager.OtaStatus; |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 35 | import android.util.Log; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 36 | |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 37 | import java.lang.annotation.Retention; |
| 38 | import java.lang.annotation.RetentionPolicy; |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 39 | import java.util.concurrent.LinkedBlockingQueue; |
| 40 | import java.util.concurrent.ThreadFactory; |
| 41 | import java.util.concurrent.ThreadPoolExecutor; |
| 42 | import java.util.concurrent.TimeUnit; |
| 43 | import java.util.concurrent.atomic.AtomicInteger; |
| 44 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 45 | /** |
| 46 | * Service interface linking the system with an eUICC local profile assistant (LPA) application. |
| 47 | * |
| 48 | * <p>An LPA consists of two separate components (which may both be implemented in the same APK): |
| 49 | * the LPA backend, and the LPA UI or LUI. |
| 50 | * |
| 51 | * <p>To implement the LPA backend, you must extend this class and declare this service in your |
| 52 | * manifest file. The service must require the |
| 53 | * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission and include an intent filter |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 54 | * with the {@link #EUICC_SERVICE_INTERFACE} action. It's suggested that the priority of the intent |
| 55 | * filter to be set to a non-zero value in case multiple implementations are present on the device. |
| 56 | * See the below example. Note that there will be problem if two LPAs are present and they have the |
| 57 | * same priority. |
| 58 | * Example: |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 59 | * |
| 60 | * <pre>{@code |
| 61 | * <service android:name=".MyEuiccService" |
| 62 | * android:permission="android.permission.BIND_EUICC_SERVICE"> |
| 63 | * <intent-filter android:priority="100"> |
| 64 | * <action android:name="android.service.euicc.EuiccService" /> |
| 65 | * </intent-filter> |
| 66 | * </service> |
| 67 | * }</pre> |
| 68 | * |
| 69 | * <p>To implement the LUI, you must provide an activity for the following actions: |
| 70 | * |
| 71 | * <ul> |
| 72 | * <li>{@link #ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS} |
| 73 | * <li>{@link #ACTION_PROVISION_EMBEDDED_SUBSCRIPTION} |
| 74 | * </ul> |
| 75 | * |
| 76 | * <p>As with the service, each activity must require the |
| 77 | * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission. Each should have an intent |
| 78 | * filter with the appropriate action, the {@link #CATEGORY_EUICC_UI} category, and a non-zero |
| 79 | * priority. |
| 80 | * |
Jordan Liu | cb47d1d | 2019-02-01 14:15:05 -0800 | [diff] [blame] | 81 | * <p>Old implementations of EuiccService may support passing in slot IDs equal to |
| 82 | * {@link android.telephony.SubscriptionManager#INVALID_SIM_SLOT_INDEX}, which allows the LPA to |
| 83 | * decide which eUICC to target when there are multiple eUICCs. This behavior is not supported in |
| 84 | * Android Q or later. |
| 85 | * |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 86 | * @hide |
| 87 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 88 | @SystemApi |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 89 | public abstract class EuiccService extends Service { |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 90 | private static final String TAG = "EuiccService"; |
| 91 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 92 | /** Action which must be included in this service's intent filter. */ |
| 93 | public static final String EUICC_SERVICE_INTERFACE = "android.service.euicc.EuiccService"; |
| 94 | |
| 95 | /** Category which must be defined to all UI actions, for efficient lookup. */ |
| 96 | public static final String CATEGORY_EUICC_UI = "android.service.euicc.category.EUICC_UI"; |
| 97 | |
| 98 | // LUI actions. These are passthroughs of the corresponding EuiccManager actions. |
| 99 | |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 100 | /** |
Qingxi Li | cfb6e7b | 2018-11-12 18:00:20 -0800 | [diff] [blame] | 101 | * Action used to bind the carrier app and get the activation code from the carrier app. This |
| 102 | * activation code will be used to download the eSIM profile during eSIM activation flow. |
| 103 | */ |
| 104 | public static final String ACTION_BIND_CARRIER_PROVISIONING_SERVICE = |
| 105 | "android.service.euicc.action.BIND_CARRIER_PROVISIONING_SERVICE"; |
| 106 | |
| 107 | /** |
Jiashen Wang | 216ae8d | 2019-10-18 11:00:11 -0700 | [diff] [blame] | 108 | * Intent action sent by the LPA to launch a carrier app Activity for eSIM activation, e.g. a |
| 109 | * carrier login screen. Carrier apps wishing to support this activation method must implement |
| 110 | * an Activity that responds to this intent action. Upon completion, the Activity must return |
| 111 | * one of the following results to the LPA: |
| 112 | * |
| 113 | * <p>{@code Activity.RESULT_CANCELED}: The LPA should treat this as an back button and abort |
| 114 | * the activation flow. |
| 115 | * <p>{@code Activity.RESULT_OK}: The LPA should try to get an activation code from the carrier |
| 116 | * app by binding to the carrier app service implementing |
| 117 | * {@link #ACTION_BIND_CARRIER_PROVISIONING_SERVICE}. |
| 118 | * <p>{@code Activity.RESULT_OK} with |
| 119 | * {@link android.telephony.euicc.EuiccManager#EXTRA_USE_QR_SCANNER} set to true: The LPA should |
| 120 | * start a QR scanner for the user to scan an eSIM profile QR code. |
| 121 | * <p>For other results: The LPA should treat this as an error. |
| 122 | **/ |
| 123 | @SdkConstant(SdkConstant.SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 124 | public static final String ACTION_START_CARRIER_ACTIVATION = |
| 125 | "android.service.euicc.action.START_CARRIER_ACTIVATION"; |
| 126 | |
| 127 | /** |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 128 | * @see android.telephony.euicc.EuiccManager#ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS |
| 129 | * The difference is this one is used by system to bring up the LUI. |
| 130 | */ |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 131 | public static final String ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS = |
| 132 | "android.service.euicc.action.MANAGE_EMBEDDED_SUBSCRIPTIONS"; |
Patrick Huang | f43a0cc | 2019-01-14 17:47:56 -0800 | [diff] [blame] | 133 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 134 | /** @see android.telephony.euicc.EuiccManager#ACTION_PROVISION_EMBEDDED_SUBSCRIPTION */ |
| 135 | public static final String ACTION_PROVISION_EMBEDDED_SUBSCRIPTION = |
| 136 | "android.service.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION"; |
| 137 | |
Patrick Huang | 8002fe4 | 2019-03-14 19:25:47 -0700 | [diff] [blame] | 138 | /** |
| 139 | * @see android.telephony.euicc.EuiccManager#ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED. This is |
| 140 | * a protected intent that can only be sent by the system, and requires the |
| 141 | * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission. |
| 142 | */ |
Patrick Huang | f43a0cc | 2019-01-14 17:47:56 -0800 | [diff] [blame] | 143 | public static final String ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED = |
| 144 | "android.service.euicc.action.TOGGLE_SUBSCRIPTION_PRIVILEGED"; |
| 145 | |
Patrick Huang | 8002fe4 | 2019-03-14 19:25:47 -0700 | [diff] [blame] | 146 | /** |
| 147 | * @see android.telephony.euicc.EuiccManager#ACTION_DELETE_SUBSCRIPTION_PRIVILEGED. This is |
| 148 | * a protected intent that can only be sent by the system, and requires the |
| 149 | * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission. |
| 150 | */ |
Patrick Huang | f43a0cc | 2019-01-14 17:47:56 -0800 | [diff] [blame] | 151 | public static final String ACTION_DELETE_SUBSCRIPTION_PRIVILEGED = |
| 152 | "android.service.euicc.action.DELETE_SUBSCRIPTION_PRIVILEGED"; |
| 153 | |
Patrick Huang | 8002fe4 | 2019-03-14 19:25:47 -0700 | [diff] [blame] | 154 | /** |
| 155 | * @see android.telephony.euicc.EuiccManager#ACTION_RENAME_SUBSCRIPTION_PRIVILEGED. This is |
| 156 | * a protected intent that can only be sent by the system, and requires the |
| 157 | * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission. |
| 158 | */ |
Patrick Huang | f43a0cc | 2019-01-14 17:47:56 -0800 | [diff] [blame] | 159 | public static final String ACTION_RENAME_SUBSCRIPTION_PRIVILEGED = |
| 160 | "android.service.euicc.action.RENAME_SUBSCRIPTION_PRIVILEGED"; |
| 161 | |
Jiashen Wang | 216ae8d | 2019-10-18 11:00:11 -0700 | [diff] [blame] | 162 | /** |
| 163 | * @see android.telephony.euicc.EuiccManager#ACTION_START_EUICC_ACTIVATION. This is |
| 164 | * a protected intent that can only be sent by the system, and requires the |
| 165 | * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission. |
| 166 | */ |
| 167 | @SdkConstant(SdkConstant.SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 168 | public static final String ACTION_START_EUICC_ACTIVATION = |
| 169 | "android.service.euicc.action.START_EUICC_ACTIVATION"; |
| 170 | |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 171 | // LUI resolution actions. These are called by the platform to resolve errors in situations that |
| 172 | // require user interaction. |
| 173 | // TODO(b/33075886): Define extras for any input parameters to these dialogs once they are |
| 174 | // more scoped out. |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 175 | /** |
| 176 | * Alert the user that this action will result in an active SIM being deactivated. |
| 177 | * To implement the LUI triggered by the system, you need to define this in AndroidManifest.xml. |
| 178 | */ |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 179 | public static final String ACTION_RESOLVE_DEACTIVATE_SIM = |
| 180 | "android.service.euicc.action.RESOLVE_DEACTIVATE_SIM"; |
| 181 | /** |
| 182 | * Alert the user about a download/switch being done for an app that doesn't currently have |
| 183 | * carrier privileges. |
| 184 | */ |
| 185 | public static final String ACTION_RESOLVE_NO_PRIVILEGES = |
| 186 | "android.service.euicc.action.RESOLVE_NO_PRIVILEGES"; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 187 | |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 188 | /** |
| 189 | * Ask the user to input carrier confirmation code. |
| 190 | * |
| 191 | * @deprecated From Q, the resolvable errors happened in the download step are presented as |
| 192 | * bit map in {@link #EXTRA_RESOLVABLE_ERRORS}. The corresponding action would be |
| 193 | * {@link #ACTION_RESOLVE_RESOLVABLE_ERRORS}. |
| 194 | */ |
| 195 | @Deprecated |
Holly Jiuyu Sun | 6a2877e | 2017-10-13 19:06:34 -0700 | [diff] [blame] | 196 | public static final String ACTION_RESOLVE_CONFIRMATION_CODE = |
| 197 | "android.service.euicc.action.RESOLVE_CONFIRMATION_CODE"; |
| 198 | |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 199 | /** Ask the user to resolve all the resolvable errors. */ |
| 200 | public static final String ACTION_RESOLVE_RESOLVABLE_ERRORS = |
| 201 | "android.service.euicc.action.RESOLVE_RESOLVABLE_ERRORS"; |
| 202 | |
| 203 | /** @hide */ |
| 204 | @Retention(RetentionPolicy.SOURCE) |
| 205 | @IntDef(flag = true, prefix = { "RESOLVABLE_ERROR_" }, value = { |
| 206 | RESOLVABLE_ERROR_CONFIRMATION_CODE, |
| 207 | RESOLVABLE_ERROR_POLICY_RULES, |
| 208 | }) |
| 209 | public @interface ResolvableError {} |
| 210 | |
| 211 | /** |
| 212 | * Possible value for the bit map of resolvable errors indicating the download process needs |
| 213 | * the user to input confirmation code. |
| 214 | */ |
| 215 | public static final int RESOLVABLE_ERROR_CONFIRMATION_CODE = 1 << 0; |
| 216 | /** |
| 217 | * Possible value for the bit map of resolvable errors indicating the download process needs |
| 218 | * the user's consent to allow profile policy rules. |
| 219 | */ |
| 220 | public static final int RESOLVABLE_ERROR_POLICY_RULES = 1 << 1; |
| 221 | |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 222 | /** |
| 223 | * Intent extra set for resolution requests containing the package name of the calling app. |
| 224 | * This is used by the above actions including ACTION_RESOLVE_DEACTIVATE_SIM, |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 225 | * ACTION_RESOLVE_NO_PRIVILEGES and ACTION_RESOLVE_RESOLVABLE_ERRORS. |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 226 | */ |
Jeff Davidson | b4c67ec | 2017-06-13 15:28:57 -0700 | [diff] [blame] | 227 | public static final String EXTRA_RESOLUTION_CALLING_PACKAGE = |
| 228 | "android.service.euicc.extra.RESOLUTION_CALLING_PACKAGE"; |
| 229 | |
Holly Jiuyu Sun | 26008be | 2017-11-09 19:28:49 -0800 | [diff] [blame] | 230 | /** |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 231 | * Intent extra set for resolution requests containing the list of resolvable errors to be |
| 232 | * resolved. Each resolvable error is an integer. Its possible values include: |
| 233 | * <UL> |
| 234 | * <LI>{@link #RESOLVABLE_ERROR_CONFIRMATION_CODE} |
| 235 | * <LI>{@link #RESOLVABLE_ERROR_POLICY_RULES} |
| 236 | * </UL> |
| 237 | */ |
| 238 | public static final String EXTRA_RESOLVABLE_ERRORS = |
| 239 | "android.service.euicc.extra.RESOLVABLE_ERRORS"; |
| 240 | |
| 241 | /** |
Holly Jiuyu Sun | 26008be | 2017-11-09 19:28:49 -0800 | [diff] [blame] | 242 | * Intent extra set for resolution requests containing a boolean indicating whether to ask the |
| 243 | * user to retry another confirmation code. |
| 244 | */ |
| 245 | public static final String EXTRA_RESOLUTION_CONFIRMATION_CODE_RETRIED = |
| 246 | "android.service.euicc.extra.RESOLUTION_CONFIRMATION_CODE_RETRIED"; |
| 247 | |
Holly Jiuyu Sun | da56f08 | 2019-01-17 17:09:09 -0800 | [diff] [blame] | 248 | /** |
| 249 | * Intent extra set for resolution requests containing an int indicating the current card Id. |
| 250 | */ |
| 251 | public static final String EXTRA_RESOLUTION_CARD_ID = |
| 252 | "android.service.euicc.extra.RESOLUTION_CARD_ID"; |
| 253 | |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 254 | /** @hide */ |
| 255 | @Retention(RetentionPolicy.SOURCE) |
| 256 | @IntDef(prefix = { "RESULT_" }, value = { |
| 257 | RESULT_OK, |
| 258 | RESULT_MUST_DEACTIVATE_SIM, |
| 259 | RESULT_RESOLVABLE_ERRORS, |
| 260 | RESULT_NEED_CONFIRMATION_CODE, |
| 261 | RESULT_FIRST_USER, |
| 262 | }) |
| 263 | public @interface Result {} |
| 264 | |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 265 | /** Result code for a successful operation. */ |
| 266 | public static final int RESULT_OK = 0; |
| 267 | /** Result code indicating that an active SIM must be deactivated to perform the operation. */ |
| 268 | public static final int RESULT_MUST_DEACTIVATE_SIM = -1; |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 269 | /** Result code indicating that the user must resolve resolvable errors. */ |
| 270 | public static final int RESULT_RESOLVABLE_ERRORS = -2; |
| 271 | /** |
| 272 | * Result code indicating that the user must input a carrier confirmation code. |
| 273 | * |
| 274 | * @deprecated From Q, the resolvable errors happened in the download step are presented as |
| 275 | * bit map in {@link #EXTRA_RESOLVABLE_ERRORS}. The corresponding result would be |
| 276 | * {@link #RESULT_RESOLVABLE_ERRORS}. |
| 277 | */ |
| 278 | @Deprecated |
Holly Jiuyu Sun | 6a2877e | 2017-10-13 19:06:34 -0700 | [diff] [blame] | 279 | public static final int RESULT_NEED_CONFIRMATION_CODE = -2; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 280 | // New predefined codes should have negative values. |
| 281 | |
| 282 | /** Start of implementation-specific error results. */ |
| 283 | public static final int RESULT_FIRST_USER = 1; |
| 284 | |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 285 | /** |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 286 | * Boolean extra for resolution actions indicating whether the user granted consent. |
| 287 | * This is used and set by the implementation and used in {@code EuiccOperation}. |
| 288 | */ |
| 289 | public static final String EXTRA_RESOLUTION_CONSENT = |
| 290 | "android.service.euicc.extra.RESOLUTION_CONSENT"; |
| 291 | /** |
| 292 | * String extra for resolution actions indicating the carrier confirmation code. |
| 293 | * This is used and set by the implementation and used in {@code EuiccOperation}. |
| 294 | */ |
| 295 | public static final String EXTRA_RESOLUTION_CONFIRMATION_CODE = |
| 296 | "android.service.euicc.extra.RESOLUTION_CONFIRMATION_CODE"; |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 297 | /** |
| 298 | * String extra for resolution actions indicating whether the user allows policy rules. |
| 299 | * This is used and set by the implementation and used in {@code EuiccOperation}. |
| 300 | */ |
| 301 | public static final String EXTRA_RESOLUTION_ALLOW_POLICY_RULES = |
| 302 | "android.service.euicc.extra.RESOLUTION_ALLOW_POLICY_RULES"; |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 303 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 304 | private final IEuiccService.Stub mStubWrapper; |
| 305 | |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 306 | private ThreadPoolExecutor mExecutor; |
| 307 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 308 | public EuiccService() { |
| 309 | mStubWrapper = new IEuiccServiceWrapper(); |
| 310 | } |
| 311 | |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 312 | @Override |
| 313 | @CallSuper |
| 314 | public void onCreate() { |
| 315 | super.onCreate(); |
| 316 | // We use a oneway AIDL interface to avoid blocking phone process binder threads on IPCs to |
| 317 | // an external process, but doing so means the requests are serialized by binder, which is |
| 318 | // not desired. Spin up a background thread pool to allow requests to be parallelized. |
| 319 | // TODO(b/38206971): Consider removing this if basic card-level functions like listing |
| 320 | // profiles are moved to the platform. |
| 321 | mExecutor = new ThreadPoolExecutor( |
| 322 | 4 /* corePoolSize */, |
| 323 | 4 /* maxPoolSize */, |
| 324 | 30, TimeUnit.SECONDS, /* keepAliveTime */ |
| 325 | new LinkedBlockingQueue<>(), /* workQueue */ |
| 326 | new ThreadFactory() { |
| 327 | private final AtomicInteger mCount = new AtomicInteger(1); |
| 328 | |
| 329 | @Override |
| 330 | public Thread newThread(Runnable r) { |
| 331 | return new Thread(r, "EuiccService #" + mCount.getAndIncrement()); |
| 332 | } |
| 333 | } |
| 334 | ); |
| 335 | mExecutor.allowCoreThreadTimeOut(true); |
| 336 | } |
| 337 | |
| 338 | @Override |
| 339 | @CallSuper |
| 340 | public void onDestroy() { |
| 341 | mExecutor.shutdownNow(); |
| 342 | super.onDestroy(); |
| 343 | } |
| 344 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 345 | /** |
| 346 | * If overriding this method, call through to the super method for any unknown actions. |
| 347 | * {@inheritDoc} |
| 348 | */ |
| 349 | @Override |
| 350 | @CallSuper |
| 351 | public IBinder onBind(Intent intent) { |
| 352 | return mStubWrapper; |
| 353 | } |
| 354 | |
| 355 | /** |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 356 | * Callback class for {@link #onStartOtaIfNecessary(int, OtaStatusChangedCallback)} |
| 357 | * |
| 358 | * The status of OTA which can be {@code android.telephony.euicc.EuiccManager#EUICC_OTA_} |
| 359 | * |
| 360 | * @see IEuiccService#startOtaIfNecessary |
| 361 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 362 | public abstract static class OtaStatusChangedCallback { |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 363 | /** Called when OTA status is changed. */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 364 | public abstract void onOtaStatusChanged(int status); |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | /** |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 368 | * Return the EID of the eUICC. |
| 369 | * |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 370 | * @param slotId ID of the SIM slot being queried. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 371 | * @return the EID. |
| 372 | * @see android.telephony.euicc.EuiccManager#getEid |
| 373 | */ |
| 374 | // TODO(b/36260308): Update doc when we have multi-SIM support. |
| 375 | public abstract String onGetEid(int slotId); |
| 376 | |
| 377 | /** |
Qingxi Li | 5405836 | 2017-12-13 15:13:02 -0800 | [diff] [blame] | 378 | * Return the status of OTA update. |
| 379 | * |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 380 | * @param slotId ID of the SIM slot to use for the operation. |
Qingxi Li | 5405836 | 2017-12-13 15:13:02 -0800 | [diff] [blame] | 381 | * @return The status of Euicc OTA update. |
| 382 | * @see android.telephony.euicc.EuiccManager#getOtaStatus |
| 383 | */ |
| 384 | public abstract @OtaStatus int onGetOtaStatus(int slotId); |
| 385 | |
| 386 | /** |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 387 | * Perform OTA if current OS is not the latest one. |
| 388 | * |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 389 | * @param slotId ID of the SIM slot to use for the operation. |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 390 | * @param statusChangedCallback Function called when OTA status changed. |
| 391 | */ |
| 392 | public abstract void onStartOtaIfNecessary( |
| 393 | int slotId, OtaStatusChangedCallback statusChangedCallback); |
| 394 | |
| 395 | /** |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 396 | * Populate {@link DownloadableSubscription} metadata for the given downloadable subscription. |
| 397 | * |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 398 | * @param slotId ID of the SIM slot to use for the operation. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 399 | * @param subscription A subscription whose metadata needs to be populated. |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 400 | * @param forceDeactivateSim If true, and if an active SIM must be deactivated to access the |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 401 | * eUICC, perform this action automatically. Otherwise, {@link #RESULT_MUST_DEACTIVATE_SIM)} |
| 402 | * should be returned to allow the user to consent to this operation first. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 403 | * @return The result of the operation. |
| 404 | * @see android.telephony.euicc.EuiccManager#getDownloadableSubscriptionMetadata |
| 405 | */ |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 406 | public abstract GetDownloadableSubscriptionMetadataResult onGetDownloadableSubscriptionMetadata( |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 407 | int slotId, DownloadableSubscription subscription, boolean forceDeactivateSim); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 408 | |
| 409 | /** |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 410 | * Return metadata for subscriptions which are available for download for this device. |
| 411 | * |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 412 | * @param slotId ID of the SIM slot to use for the operation. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 413 | * @param forceDeactivateSim If true, and if an active SIM must be deactivated to access the |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 414 | * eUICC, perform this action automatically. Otherwise, {@link #RESULT_MUST_DEACTIVATE_SIM)} |
| 415 | * should be returned to allow the user to consent to this operation first. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 416 | * @return The result of the list operation. |
| 417 | * @see android.telephony.euicc.EuiccManager#getDefaultDownloadableSubscriptionList |
| 418 | */ |
| 419 | public abstract GetDefaultDownloadableSubscriptionListResult |
| 420 | onGetDefaultDownloadableSubscriptionList(int slotId, boolean forceDeactivateSim); |
| 421 | |
| 422 | /** |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 423 | * Download the given subscription. |
| 424 | * |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 425 | * @param slotId ID of the SIM slot to use for the operation. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 426 | * @param subscription The subscription to download. |
| 427 | * @param switchAfterDownload If true, the subscription should be enabled upon successful |
| 428 | * download. |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 429 | * @param forceDeactivateSim If true, and if an active SIM must be deactivated to access the |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 430 | * eUICC, perform this action automatically. Otherwise, {@link #RESULT_MUST_DEACTIVATE_SIM} |
| 431 | * should be returned to allow the user to consent to this operation first. |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 432 | * @param resolvedBundle The bundle containing information on resolved errors. It can contain |
| 433 | * a string of confirmation code for the key {@link #EXTRA_RESOLUTION_CONFIRMATION_CODE}, |
| 434 | * and a boolean for key {@link #EXTRA_RESOLUTION_ALLOW_POLICY_RULES} indicating whether |
| 435 | * the user allows profile policy rules or not. |
| 436 | * @return a DownloadSubscriptionResult instance including a result code, a resolvable errors |
| 437 | * bit map, and original the card Id. The result code may be one of the predefined |
| 438 | * {@code RESULT_} constants or any implementation-specific code starting with |
| 439 | * {@link #RESULT_FIRST_USER}. The resolvable error bit map can be either 0 or values |
Holly Jiuyu Sun | c67c86c | 2019-04-10 14:34:07 -0700 | [diff] [blame] | 440 | * defined in {@code RESOLVABLE_ERROR_}. A subclass should override this method. Otherwise, |
| 441 | * this method does nothing and returns null by default. |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 442 | * @see android.telephony.euicc.EuiccManager#downloadSubscription |
| 443 | */ |
Holly Jiuyu Sun | c67c86c | 2019-04-10 14:34:07 -0700 | [diff] [blame] | 444 | public DownloadSubscriptionResult onDownloadSubscription(int slotId, |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 445 | @NonNull DownloadableSubscription subscription, boolean switchAfterDownload, |
Holly Jiuyu Sun | c67c86c | 2019-04-10 14:34:07 -0700 | [diff] [blame] | 446 | boolean forceDeactivateSim, @Nullable Bundle resolvedBundle) { |
| 447 | return null; |
| 448 | } |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 449 | |
| 450 | /** |
| 451 | * Download the given subscription. |
| 452 | * |
| 453 | * @param slotId ID of the SIM slot to use for the operation. |
| 454 | * @param subscription The subscription to download. |
| 455 | * @param switchAfterDownload If true, the subscription should be enabled upon successful |
| 456 | * download. |
| 457 | * @param forceDeactivateSim If true, and if an active SIM must be deactivated to access the |
| 458 | * eUICC, perform this action automatically. Otherwise, {@link #RESULT_MUST_DEACTIVATE_SIM} |
| 459 | * should be returned to allow the user to consent to this operation first. |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 460 | * @return the result of the download operation. May be one of the predefined {@code RESULT_} |
| 461 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 462 | * @see android.telephony.euicc.EuiccManager#downloadSubscription |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 463 | * |
Holly Jiuyu Sun | c67c86c | 2019-04-10 14:34:07 -0700 | [diff] [blame] | 464 | * @deprecated From Q, a subclass should use and override the above |
| 465 | * {@link #onDownloadSubscription(int, DownloadableSubscription, boolean, boolean, Bundle)}. The |
| 466 | * default return value for this one is Integer.MIN_VALUE. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 467 | */ |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 468 | @Deprecated public @Result int onDownloadSubscription(int slotId, |
| 469 | @NonNull DownloadableSubscription subscription, boolean switchAfterDownload, |
| 470 | boolean forceDeactivateSim) { |
Holly Jiuyu Sun | c67c86c | 2019-04-10 14:34:07 -0700 | [diff] [blame] | 471 | return Integer.MIN_VALUE; |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 472 | } |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 473 | |
| 474 | /** |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 475 | * Return a list of all @link EuiccProfileInfo}s. |
| 476 | * |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 477 | * @param slotId ID of the SIM slot to use for the operation. |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 478 | * @return The result of the operation. |
| 479 | * @see android.telephony.SubscriptionManager#getAvailableSubscriptionInfoList |
| 480 | * @see android.telephony.SubscriptionManager#getAccessibleSubscriptionInfoList |
| 481 | */ |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 482 | public abstract @NonNull GetEuiccProfileInfoListResult onGetEuiccProfileInfoList(int slotId); |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 483 | |
| 484 | /** |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 485 | * Return info about the eUICC chip/device. |
| 486 | * |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 487 | * @param slotId ID of the SIM slot to use for the operation. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 488 | * @return the {@link EuiccInfo} for the eUICC chip/device. |
| 489 | * @see android.telephony.euicc.EuiccManager#getEuiccInfo |
| 490 | */ |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 491 | public abstract @NonNull EuiccInfo onGetEuiccInfo(int slotId); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 492 | |
| 493 | /** |
| 494 | * Delete the given subscription. |
| 495 | * |
| 496 | * <p>If the subscription is currently active, it should be deactivated first (equivalent to a |
| 497 | * physical SIM being ejected). |
| 498 | * |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 499 | * @param slotId ID of the SIM slot to use for the operation. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 500 | * @param iccid the ICCID of the subscription to delete. |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 501 | * @return the result of the delete operation. May be one of the predefined {@code RESULT_} |
| 502 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 503 | * @see android.telephony.euicc.EuiccManager#deleteSubscription |
| 504 | */ |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 505 | public abstract @Result int onDeleteSubscription(int slotId, String iccid); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 506 | |
| 507 | /** |
| 508 | * Switch to the given subscription. |
| 509 | * |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 510 | * @param slotId ID of the SIM slot to use for the operation. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 511 | * @param iccid the ICCID of the subscription to enable. May be null, in which case the current |
| 512 | * profile should be deactivated and no profile should be activated to replace it - this is |
| 513 | * equivalent to a physical SIM being ejected. |
| 514 | * @param forceDeactivateSim If true, and if an active SIM must be deactivated to access the |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 515 | * eUICC, perform this action automatically. Otherwise, {@link #RESULT_MUST_DEACTIVATE_SIM} |
| 516 | * should be returned to allow the user to consent to this operation first. |
| 517 | * @return the result of the switch operation. May be one of the predefined {@code RESULT_} |
| 518 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 519 | * @see android.telephony.euicc.EuiccManager#switchToSubscription |
| 520 | */ |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 521 | public abstract @Result int onSwitchToSubscription(int slotId, @Nullable String iccid, |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 522 | boolean forceDeactivateSim); |
| 523 | |
| 524 | /** |
| 525 | * Update the nickname of the given subscription. |
| 526 | * |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 527 | * @param slotId ID of the SIM slot to use for the operation. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 528 | * @param iccid the ICCID of the subscription to update. |
| 529 | * @param nickname the new nickname to apply. |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 530 | * @return the result of the update operation. May be one of the predefined {@code RESULT_} |
| 531 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 532 | * @see android.telephony.euicc.EuiccManager#updateSubscriptionNickname |
| 533 | */ |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 534 | public abstract int onUpdateSubscriptionNickname(int slotId, String iccid, |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 535 | String nickname); |
| 536 | |
| 537 | /** |
Peter Wang | 2ab852d | 2019-09-09 13:57:41 -0700 | [diff] [blame] | 538 | * Erase all operational subscriptions on the device. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 539 | * |
| 540 | * <p>This is intended to be used for device resets. As such, the reset should be performed even |
| 541 | * if an active SIM must be deactivated in order to access the eUICC. |
| 542 | * |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 543 | * @param slotId ID of the SIM slot to use for the operation. |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 544 | * @return the result of the erase operation. May be one of the predefined {@code RESULT_} |
| 545 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 546 | * @see android.telephony.euicc.EuiccManager#eraseSubscriptions |
Peter Wang | 2ab852d | 2019-09-09 13:57:41 -0700 | [diff] [blame] | 547 | * |
| 548 | * @deprecated From R, callers should specify a flag for specific set of subscriptions to erase |
Peter Wang | 7e16b39 | 2019-11-12 15:44:58 -0800 | [diff] [blame] | 549 | * and use {@link #onEraseSubscriptions(int, int)} instead |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 550 | */ |
Peter Wang | 2ab852d | 2019-09-09 13:57:41 -0700 | [diff] [blame] | 551 | @Deprecated |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 552 | public abstract int onEraseSubscriptions(int slotId); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 553 | |
| 554 | /** |
Peter Wang | 2ab852d | 2019-09-09 13:57:41 -0700 | [diff] [blame] | 555 | * Erase specific subscriptions on the device. |
| 556 | * |
| 557 | * <p>This is intended to be used for device resets. As such, the reset should be performed even |
| 558 | * if an active SIM must be deactivated in order to access the eUICC. |
| 559 | * |
| 560 | * @param slotIndex index of the SIM slot to use for the operation. |
| 561 | * @param options flag for specific group of subscriptions to erase |
| 562 | * @return the result of the erase operation. May be one of the predefined {@code RESULT_} |
| 563 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
| 564 | * @see android.telephony.euicc.EuiccManager#eraseSubscriptionsWithOptions |
| 565 | */ |
Peter Wang | 7e16b39 | 2019-11-12 15:44:58 -0800 | [diff] [blame] | 566 | public int onEraseSubscriptions(int slotIndex, @ResetOption int options) { |
Peter Wang | 2ab852d | 2019-09-09 13:57:41 -0700 | [diff] [blame] | 567 | throw new UnsupportedOperationException( |
| 568 | "This method must be overridden to enable the ResetOption parameter"); |
| 569 | } |
| 570 | |
| 571 | /** |
Jeff Davidson | 7b69a86 | 2017-06-16 15:20:34 -0700 | [diff] [blame] | 572 | * Ensure that subscriptions will be retained on the next factory reset. |
| 573 | * |
| 574 | * <p>Called directly before a factory reset. Assumes that a normal factory reset will lead to |
| 575 | * profiles being erased on first boot (to cover fastboot/recovery wipes), so the implementation |
| 576 | * should persist some bit that will remain accessible after the factory reset to bypass this |
| 577 | * flow when this method is called. |
| 578 | * |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 579 | * @param slotId ID of the SIM slot to use for the operation. |
Jeff Davidson | 7b69a86 | 2017-06-16 15:20:34 -0700 | [diff] [blame] | 580 | * @return the result of the operation. May be one of the predefined {@code RESULT_} constants |
| 581 | * or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
| 582 | */ |
| 583 | public abstract int onRetainSubscriptionsForFactoryReset(int slotId); |
| 584 | |
| 585 | /** |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 586 | * Wrapper around IEuiccService that forwards calls to implementations of {@link EuiccService}. |
| 587 | */ |
| 588 | private class IEuiccServiceWrapper extends IEuiccService.Stub { |
| 589 | @Override |
| 590 | public void downloadSubscription(int slotId, DownloadableSubscription subscription, |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 591 | boolean switchAfterDownload, boolean forceDeactivateSim, Bundle resolvedBundle, |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 592 | IDownloadSubscriptionCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 593 | mExecutor.execute(new Runnable() { |
| 594 | @Override |
| 595 | public void run() { |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 596 | DownloadSubscriptionResult result; |
| 597 | try { |
| 598 | result = |
| 599 | EuiccService.this.onDownloadSubscription( |
| 600 | slotId, subscription, switchAfterDownload, forceDeactivateSim, |
| 601 | resolvedBundle); |
| 602 | } catch (AbstractMethodError e) { |
| 603 | Log.w(TAG, "The new onDownloadSubscription(int, " |
| 604 | + "DownloadableSubscription, boolean, boolean, Bundle) is not " |
| 605 | + "implemented. Fall back to the old one.", e); |
| 606 | int resultCode = EuiccService.this.onDownloadSubscription( |
| 607 | slotId, subscription, switchAfterDownload, forceDeactivateSim); |
| 608 | result = new DownloadSubscriptionResult(resultCode, |
Jordan Liu | cb47d1d | 2019-02-01 14:15:05 -0800 | [diff] [blame] | 609 | 0 /* resolvableErrors */, TelephonyManager.UNSUPPORTED_CARD_ID); |
Holly Jiuyu Sun | 881fe4c | 2018-10-24 20:16:04 -0700 | [diff] [blame] | 610 | } |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 611 | try { |
| 612 | callback.onComplete(result); |
| 613 | } catch (RemoteException e) { |
| 614 | // Can't communicate with the phone process; ignore. |
| 615 | } |
| 616 | } |
| 617 | }); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | @Override |
| 621 | public void getEid(int slotId, IGetEidCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 622 | mExecutor.execute(new Runnable() { |
| 623 | @Override |
| 624 | public void run() { |
| 625 | String eid = EuiccService.this.onGetEid(slotId); |
| 626 | try { |
| 627 | callback.onSuccess(eid); |
| 628 | } catch (RemoteException e) { |
| 629 | // Can't communicate with the phone process; ignore. |
| 630 | } |
| 631 | } |
| 632 | }); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | @Override |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 636 | public void startOtaIfNecessary( |
| 637 | int slotId, IOtaStatusChangedCallback statusChangedCallback) { |
| 638 | mExecutor.execute(new Runnable() { |
| 639 | @Override |
| 640 | public void run() { |
| 641 | EuiccService.this.onStartOtaIfNecessary(slotId, new OtaStatusChangedCallback() { |
| 642 | @Override |
| 643 | public void onOtaStatusChanged(int status) { |
| 644 | try { |
| 645 | statusChangedCallback.onOtaStatusChanged(status); |
| 646 | } catch (RemoteException e) { |
| 647 | // Can't communicate with the phone process; ignore. |
| 648 | } |
| 649 | } |
| 650 | }); |
| 651 | } |
| 652 | }); |
| 653 | } |
| 654 | |
| 655 | @Override |
Qingxi Li | 5405836 | 2017-12-13 15:13:02 -0800 | [diff] [blame] | 656 | public void getOtaStatus(int slotId, IGetOtaStatusCallback callback) { |
| 657 | mExecutor.execute(new Runnable() { |
| 658 | @Override |
| 659 | public void run() { |
| 660 | int status = EuiccService.this.onGetOtaStatus(slotId); |
| 661 | try { |
| 662 | callback.onSuccess(status); |
| 663 | } catch (RemoteException e) { |
| 664 | // Can't communicate with the phone process; ignore. |
| 665 | } |
| 666 | } |
| 667 | }); |
| 668 | } |
| 669 | |
| 670 | @Override |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 671 | public void getDownloadableSubscriptionMetadata(int slotId, |
| 672 | DownloadableSubscription subscription, |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 673 | boolean forceDeactivateSim, |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 674 | IGetDownloadableSubscriptionMetadataCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 675 | mExecutor.execute(new Runnable() { |
| 676 | @Override |
| 677 | public void run() { |
| 678 | GetDownloadableSubscriptionMetadataResult result = |
| 679 | EuiccService.this.onGetDownloadableSubscriptionMetadata( |
| 680 | slotId, subscription, forceDeactivateSim); |
| 681 | try { |
| 682 | callback.onComplete(result); |
| 683 | } catch (RemoteException e) { |
| 684 | // Can't communicate with the phone process; ignore. |
| 685 | } |
| 686 | } |
| 687 | }); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 688 | } |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 689 | |
| 690 | @Override |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 691 | public void getDefaultDownloadableSubscriptionList(int slotId, boolean forceDeactivateSim, |
| 692 | IGetDefaultDownloadableSubscriptionListCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 693 | mExecutor.execute(new Runnable() { |
| 694 | @Override |
| 695 | public void run() { |
| 696 | GetDefaultDownloadableSubscriptionListResult result = |
| 697 | EuiccService.this.onGetDefaultDownloadableSubscriptionList( |
| 698 | slotId, forceDeactivateSim); |
| 699 | try { |
| 700 | callback.onComplete(result); |
| 701 | } catch (RemoteException e) { |
| 702 | // Can't communicate with the phone process; ignore. |
| 703 | } |
| 704 | } |
| 705 | }); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 706 | } |
| 707 | |
| 708 | @Override |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 709 | public void getEuiccProfileInfoList(int slotId, IGetEuiccProfileInfoListCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 710 | mExecutor.execute(new Runnable() { |
| 711 | @Override |
| 712 | public void run() { |
| 713 | GetEuiccProfileInfoListResult result = |
| 714 | EuiccService.this.onGetEuiccProfileInfoList(slotId); |
| 715 | try { |
| 716 | callback.onComplete(result); |
| 717 | } catch (RemoteException e) { |
| 718 | // Can't communicate with the phone process; ignore. |
| 719 | } |
| 720 | } |
| 721 | }); |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 722 | } |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 723 | |
| 724 | @Override |
| 725 | public void getEuiccInfo(int slotId, IGetEuiccInfoCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 726 | mExecutor.execute(new Runnable() { |
| 727 | @Override |
| 728 | public void run() { |
| 729 | EuiccInfo euiccInfo = EuiccService.this.onGetEuiccInfo(slotId); |
| 730 | try { |
| 731 | callback.onSuccess(euiccInfo); |
| 732 | } catch (RemoteException e) { |
| 733 | // Can't communicate with the phone process; ignore. |
| 734 | } |
| 735 | } |
| 736 | }); |
| 737 | |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | @Override |
| 741 | public void deleteSubscription(int slotId, String iccid, |
| 742 | IDeleteSubscriptionCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 743 | mExecutor.execute(new Runnable() { |
| 744 | @Override |
| 745 | public void run() { |
| 746 | int result = EuiccService.this.onDeleteSubscription(slotId, iccid); |
| 747 | try { |
| 748 | callback.onComplete(result); |
| 749 | } catch (RemoteException e) { |
| 750 | // Can't communicate with the phone process; ignore. |
| 751 | } |
| 752 | } |
| 753 | }); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | @Override |
| 757 | public void switchToSubscription(int slotId, String iccid, boolean forceDeactivateSim, |
| 758 | ISwitchToSubscriptionCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 759 | mExecutor.execute(new Runnable() { |
| 760 | @Override |
| 761 | public void run() { |
| 762 | int result = |
| 763 | EuiccService.this.onSwitchToSubscription( |
| 764 | slotId, iccid, forceDeactivateSim); |
| 765 | try { |
| 766 | callback.onComplete(result); |
| 767 | } catch (RemoteException e) { |
| 768 | // Can't communicate with the phone process; ignore. |
| 769 | } |
| 770 | } |
| 771 | }); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | @Override |
| 775 | public void updateSubscriptionNickname(int slotId, String iccid, String nickname, |
| 776 | IUpdateSubscriptionNicknameCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 777 | mExecutor.execute(new Runnable() { |
| 778 | @Override |
| 779 | public void run() { |
| 780 | int result = |
| 781 | EuiccService.this.onUpdateSubscriptionNickname(slotId, iccid, nickname); |
| 782 | try { |
| 783 | callback.onComplete(result); |
| 784 | } catch (RemoteException e) { |
| 785 | // Can't communicate with the phone process; ignore. |
| 786 | } |
| 787 | } |
| 788 | }); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | @Override |
| 792 | public void eraseSubscriptions(int slotId, IEraseSubscriptionsCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 793 | mExecutor.execute(new Runnable() { |
| 794 | @Override |
| 795 | public void run() { |
| 796 | int result = EuiccService.this.onEraseSubscriptions(slotId); |
| 797 | try { |
| 798 | callback.onComplete(result); |
| 799 | } catch (RemoteException e) { |
| 800 | // Can't communicate with the phone process; ignore. |
| 801 | } |
| 802 | } |
| 803 | }); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 804 | } |
Jeff Davidson | 7b69a86 | 2017-06-16 15:20:34 -0700 | [diff] [blame] | 805 | |
| 806 | @Override |
Peter Wang | 2ab852d | 2019-09-09 13:57:41 -0700 | [diff] [blame] | 807 | public void eraseSubscriptionsWithOptions( |
| 808 | int slotIndex, @ResetOption int options, IEraseSubscriptionsCallback callback) { |
| 809 | mExecutor.execute(new Runnable() { |
| 810 | @Override |
| 811 | public void run() { |
Peter Wang | 7e16b39 | 2019-11-12 15:44:58 -0800 | [diff] [blame] | 812 | int result = EuiccService.this.onEraseSubscriptions(slotIndex, options); |
Peter Wang | 2ab852d | 2019-09-09 13:57:41 -0700 | [diff] [blame] | 813 | try { |
| 814 | callback.onComplete(result); |
| 815 | } catch (RemoteException e) { |
| 816 | // Can't communicate with the phone process; ignore. |
| 817 | } |
| 818 | } |
| 819 | }); |
| 820 | } |
| 821 | |
| 822 | @Override |
Jeff Davidson | 7b69a86 | 2017-06-16 15:20:34 -0700 | [diff] [blame] | 823 | public void retainSubscriptionsForFactoryReset(int slotId, |
| 824 | IRetainSubscriptionsForFactoryResetCallback callback) { |
| 825 | mExecutor.execute(new Runnable() { |
| 826 | @Override |
| 827 | public void run() { |
| 828 | int result = EuiccService.this.onRetainSubscriptionsForFactoryReset(slotId); |
| 829 | try { |
| 830 | callback.onComplete(result); |
| 831 | } catch (RemoteException e) { |
| 832 | // Can't communicate with the phone process; ignore. |
| 833 | } |
| 834 | } |
| 835 | }); |
| 836 | } |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 837 | } |
| 838 | } |