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 | |
| 18 | import android.annotation.CallSuper; |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 20 | import android.app.Service; |
| 21 | import android.content.Intent; |
| 22 | import android.os.IBinder; |
| 23 | import android.os.RemoteException; |
| 24 | import android.telephony.euicc.DownloadableSubscription; |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 25 | import android.telephony.euicc.EuiccInfo; |
Qingxi Li | 5405836 | 2017-12-13 15:13:02 -0800 | [diff] [blame] | 26 | import android.telephony.euicc.EuiccManager.OtaStatus; |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 27 | import android.util.ArraySet; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 28 | |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 29 | import java.util.concurrent.LinkedBlockingQueue; |
| 30 | import java.util.concurrent.ThreadFactory; |
| 31 | import java.util.concurrent.ThreadPoolExecutor; |
| 32 | import java.util.concurrent.TimeUnit; |
| 33 | import java.util.concurrent.atomic.AtomicInteger; |
| 34 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 35 | /** |
| 36 | * Service interface linking the system with an eUICC local profile assistant (LPA) application. |
| 37 | * |
| 38 | * <p>An LPA consists of two separate components (which may both be implemented in the same APK): |
| 39 | * the LPA backend, and the LPA UI or LUI. |
| 40 | * |
| 41 | * <p>To implement the LPA backend, you must extend this class and declare this service in your |
| 42 | * manifest file. The service must require the |
| 43 | * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission and include an intent filter |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 44 | * with the {@link #EUICC_SERVICE_INTERFACE} action. The priority of the intent filter must be set |
| 45 | * to a non-zero value in case multiple implementations are present on the device. For example: |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 46 | * |
| 47 | * <pre>{@code |
| 48 | * <service android:name=".MyEuiccService" |
| 49 | * android:permission="android.permission.BIND_EUICC_SERVICE"> |
| 50 | * <intent-filter android:priority="100"> |
| 51 | * <action android:name="android.service.euicc.EuiccService" /> |
| 52 | * </intent-filter> |
| 53 | * </service> |
| 54 | * }</pre> |
| 55 | * |
| 56 | * <p>To implement the LUI, you must provide an activity for the following actions: |
| 57 | * |
| 58 | * <ul> |
| 59 | * <li>{@link #ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS} |
| 60 | * <li>{@link #ACTION_PROVISION_EMBEDDED_SUBSCRIPTION} |
| 61 | * </ul> |
| 62 | * |
| 63 | * <p>As with the service, each activity must require the |
| 64 | * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission. Each should have an intent |
| 65 | * filter with the appropriate action, the {@link #CATEGORY_EUICC_UI} category, and a non-zero |
| 66 | * priority. |
| 67 | * |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 68 | * TODO(b/35851809): Make this a SystemApi. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 69 | * @hide |
| 70 | */ |
| 71 | public abstract class EuiccService extends Service { |
| 72 | /** Action which must be included in this service's intent filter. */ |
| 73 | public static final String EUICC_SERVICE_INTERFACE = "android.service.euicc.EuiccService"; |
| 74 | |
| 75 | /** Category which must be defined to all UI actions, for efficient lookup. */ |
| 76 | public static final String CATEGORY_EUICC_UI = "android.service.euicc.category.EUICC_UI"; |
| 77 | |
| 78 | // LUI actions. These are passthroughs of the corresponding EuiccManager actions. |
| 79 | |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 80 | /** @see android.telephony.euicc.EuiccManager#ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS */ |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 81 | public static final String ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS = |
| 82 | "android.service.euicc.action.MANAGE_EMBEDDED_SUBSCRIPTIONS"; |
| 83 | /** @see android.telephony.euicc.EuiccManager#ACTION_PROVISION_EMBEDDED_SUBSCRIPTION */ |
| 84 | public static final String ACTION_PROVISION_EMBEDDED_SUBSCRIPTION = |
| 85 | "android.service.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION"; |
| 86 | |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 87 | // LUI resolution actions. These are called by the platform to resolve errors in situations that |
| 88 | // require user interaction. |
| 89 | // TODO(b/33075886): Define extras for any input parameters to these dialogs once they are |
| 90 | // more scoped out. |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 91 | /** Alert the user that this action will result in an active SIM being deactivated. */ |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 92 | public static final String ACTION_RESOLVE_DEACTIVATE_SIM = |
| 93 | "android.service.euicc.action.RESOLVE_DEACTIVATE_SIM"; |
| 94 | /** |
| 95 | * Alert the user about a download/switch being done for an app that doesn't currently have |
| 96 | * carrier privileges. |
| 97 | */ |
| 98 | public static final String ACTION_RESOLVE_NO_PRIVILEGES = |
| 99 | "android.service.euicc.action.RESOLVE_NO_PRIVILEGES"; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 100 | |
Holly Jiuyu Sun | 6a2877e | 2017-10-13 19:06:34 -0700 | [diff] [blame] | 101 | /** Ask the user to input carrier confirmation code. */ |
| 102 | public static final String ACTION_RESOLVE_CONFIRMATION_CODE = |
| 103 | "android.service.euicc.action.RESOLVE_CONFIRMATION_CODE"; |
| 104 | |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 105 | /** Intent extra set for resolution requests containing the package name of the calling app. */ |
Jeff Davidson | b4c67ec | 2017-06-13 15:28:57 -0700 | [diff] [blame] | 106 | public static final String EXTRA_RESOLUTION_CALLING_PACKAGE = |
| 107 | "android.service.euicc.extra.RESOLUTION_CALLING_PACKAGE"; |
| 108 | |
Holly Jiuyu Sun | 26008be | 2017-11-09 19:28:49 -0800 | [diff] [blame] | 109 | /** |
| 110 | * Intent extra set for resolution requests containing a boolean indicating whether to ask the |
| 111 | * user to retry another confirmation code. |
| 112 | */ |
| 113 | public static final String EXTRA_RESOLUTION_CONFIRMATION_CODE_RETRIED = |
| 114 | "android.service.euicc.extra.RESOLUTION_CONFIRMATION_CODE_RETRIED"; |
| 115 | |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 116 | /** Result code for a successful operation. */ |
| 117 | public static final int RESULT_OK = 0; |
| 118 | /** Result code indicating that an active SIM must be deactivated to perform the operation. */ |
| 119 | public static final int RESULT_MUST_DEACTIVATE_SIM = -1; |
Holly Jiuyu Sun | 6a2877e | 2017-10-13 19:06:34 -0700 | [diff] [blame] | 120 | /** Result code indicating that the user must input a carrier confirmation code. */ |
| 121 | public static final int RESULT_NEED_CONFIRMATION_CODE = -2; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 122 | // New predefined codes should have negative values. |
| 123 | |
| 124 | /** Start of implementation-specific error results. */ |
| 125 | public static final int RESULT_FIRST_USER = 1; |
| 126 | |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 127 | /** |
| 128 | * List of all valid resolution actions for validation purposes. |
| 129 | * @hide |
| 130 | */ |
| 131 | public static final ArraySet<String> RESOLUTION_ACTIONS; |
| 132 | static { |
| 133 | RESOLUTION_ACTIONS = new ArraySet<>(); |
| 134 | RESOLUTION_ACTIONS.add(EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM); |
| 135 | RESOLUTION_ACTIONS.add(EuiccService.ACTION_RESOLVE_NO_PRIVILEGES); |
Holly Jiuyu Sun | 6a2877e | 2017-10-13 19:06:34 -0700 | [diff] [blame] | 136 | RESOLUTION_ACTIONS.add(EuiccService.ACTION_RESOLVE_CONFIRMATION_CODE); |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 139 | /** Boolean extra for resolution actions indicating whether the user granted consent. */ |
| 140 | public static final String RESOLUTION_EXTRA_CONSENT = "consent"; |
| 141 | /** String extra for resolution actions indicating the carrier confirmation code. */ |
| 142 | public static final String RESOLUTION_EXTRA_CONFIRMATION_CODE = "confirmation_code"; |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 143 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 144 | private final IEuiccService.Stub mStubWrapper; |
| 145 | |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 146 | private ThreadPoolExecutor mExecutor; |
| 147 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 148 | public EuiccService() { |
| 149 | mStubWrapper = new IEuiccServiceWrapper(); |
| 150 | } |
| 151 | |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 152 | @Override |
| 153 | @CallSuper |
| 154 | public void onCreate() { |
| 155 | super.onCreate(); |
| 156 | // We use a oneway AIDL interface to avoid blocking phone process binder threads on IPCs to |
| 157 | // an external process, but doing so means the requests are serialized by binder, which is |
| 158 | // not desired. Spin up a background thread pool to allow requests to be parallelized. |
| 159 | // TODO(b/38206971): Consider removing this if basic card-level functions like listing |
| 160 | // profiles are moved to the platform. |
| 161 | mExecutor = new ThreadPoolExecutor( |
| 162 | 4 /* corePoolSize */, |
| 163 | 4 /* maxPoolSize */, |
| 164 | 30, TimeUnit.SECONDS, /* keepAliveTime */ |
| 165 | new LinkedBlockingQueue<>(), /* workQueue */ |
| 166 | new ThreadFactory() { |
| 167 | private final AtomicInteger mCount = new AtomicInteger(1); |
| 168 | |
| 169 | @Override |
| 170 | public Thread newThread(Runnable r) { |
| 171 | return new Thread(r, "EuiccService #" + mCount.getAndIncrement()); |
| 172 | } |
| 173 | } |
| 174 | ); |
| 175 | mExecutor.allowCoreThreadTimeOut(true); |
| 176 | } |
| 177 | |
| 178 | @Override |
| 179 | @CallSuper |
| 180 | public void onDestroy() { |
| 181 | mExecutor.shutdownNow(); |
| 182 | super.onDestroy(); |
| 183 | } |
| 184 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 185 | /** |
| 186 | * If overriding this method, call through to the super method for any unknown actions. |
| 187 | * {@inheritDoc} |
| 188 | */ |
| 189 | @Override |
| 190 | @CallSuper |
| 191 | public IBinder onBind(Intent intent) { |
| 192 | return mStubWrapper; |
| 193 | } |
| 194 | |
| 195 | /** |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 196 | * Callback class for {@link #onStartOtaIfNecessary(int, OtaStatusChangedCallback)} |
| 197 | * |
| 198 | * The status of OTA which can be {@code android.telephony.euicc.EuiccManager#EUICC_OTA_} |
| 199 | * |
| 200 | * @see IEuiccService#startOtaIfNecessary |
| 201 | */ |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 202 | public interface OtaStatusChangedCallback { |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 203 | /** Called when OTA status is changed. */ |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 204 | void onOtaStatusChanged(int status); |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | /** |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 208 | * Return the EID of the eUICC. |
| 209 | * |
| 210 | * @param slotId ID of the SIM slot being queried. This is currently not populated but is here |
| 211 | * to future-proof the APIs. |
| 212 | * @return the EID. |
| 213 | * @see android.telephony.euicc.EuiccManager#getEid |
| 214 | */ |
| 215 | // TODO(b/36260308): Update doc when we have multi-SIM support. |
| 216 | public abstract String onGetEid(int slotId); |
| 217 | |
| 218 | /** |
Qingxi Li | 5405836 | 2017-12-13 15:13:02 -0800 | [diff] [blame] | 219 | * Return the status of OTA update. |
| 220 | * |
| 221 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 222 | * but is here to future-proof the APIs. |
| 223 | * @return The status of Euicc OTA update. |
| 224 | * @see android.telephony.euicc.EuiccManager#getOtaStatus |
| 225 | */ |
| 226 | public abstract @OtaStatus int onGetOtaStatus(int slotId); |
| 227 | |
| 228 | /** |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 229 | * Perform OTA if current OS is not the latest one. |
| 230 | * |
| 231 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 232 | * but is here to future-proof the APIs. |
| 233 | * @param statusChangedCallback Function called when OTA status changed. |
| 234 | */ |
| 235 | public abstract void onStartOtaIfNecessary( |
| 236 | int slotId, OtaStatusChangedCallback statusChangedCallback); |
| 237 | |
| 238 | /** |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 239 | * Populate {@link DownloadableSubscription} metadata for the given downloadable subscription. |
| 240 | * |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 241 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 242 | * but is here to future-proof the APIs. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 243 | * @param subscription A subscription whose metadata needs to be populated. |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 244 | * @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] | 245 | * eUICC, perform this action automatically. Otherwise, {@link #RESULT_MUST_DEACTIVATE_SIM)} |
| 246 | * 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] | 247 | * @return The result of the operation. |
| 248 | * @see android.telephony.euicc.EuiccManager#getDownloadableSubscriptionMetadata |
| 249 | */ |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 250 | public abstract GetDownloadableSubscriptionMetadataResult onGetDownloadableSubscriptionMetadata( |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 251 | int slotId, DownloadableSubscription subscription, boolean forceDeactivateSim); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 252 | |
| 253 | /** |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 254 | * Return metadata for subscriptions which are available for download for this device. |
| 255 | * |
| 256 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 257 | * but is here to future-proof the APIs. |
| 258 | * @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] | 259 | * eUICC, perform this action automatically. Otherwise, {@link #RESULT_MUST_DEACTIVATE_SIM)} |
| 260 | * 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] | 261 | * @return The result of the list operation. |
| 262 | * @see android.telephony.euicc.EuiccManager#getDefaultDownloadableSubscriptionList |
| 263 | */ |
| 264 | public abstract GetDefaultDownloadableSubscriptionListResult |
| 265 | onGetDefaultDownloadableSubscriptionList(int slotId, boolean forceDeactivateSim); |
| 266 | |
| 267 | /** |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 268 | * Download the given subscription. |
| 269 | * |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 270 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 271 | * but is here to future-proof the APIs. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 272 | * @param subscription The subscription to download. |
| 273 | * @param switchAfterDownload If true, the subscription should be enabled upon successful |
| 274 | * download. |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 275 | * @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] | 276 | * eUICC, perform this action automatically. Otherwise, {@link #RESULT_MUST_DEACTIVATE_SIM} |
| 277 | * should be returned to allow the user to consent to this operation first. |
| 278 | * @return the result of the download operation. May be one of the predefined {@code RESULT_} |
| 279 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 280 | * @see android.telephony.euicc.EuiccManager#downloadSubscription |
| 281 | */ |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 282 | public abstract int onDownloadSubscription(int slotId, |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 283 | DownloadableSubscription subscription, boolean switchAfterDownload, |
| 284 | boolean forceDeactivateSim); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 285 | |
| 286 | /** |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 287 | * Return a list of all @link EuiccProfileInfo}s. |
| 288 | * |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 289 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 290 | * but is here to future-proof the APIs. |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 291 | * @return The result of the operation. |
| 292 | * @see android.telephony.SubscriptionManager#getAvailableSubscriptionInfoList |
| 293 | * @see android.telephony.SubscriptionManager#getAccessibleSubscriptionInfoList |
| 294 | */ |
| 295 | public abstract GetEuiccProfileInfoListResult onGetEuiccProfileInfoList(int slotId); |
| 296 | |
| 297 | /** |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 298 | * Return info about the eUICC chip/device. |
| 299 | * |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 300 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 301 | * but is here to future-proof the APIs. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 302 | * @return the {@link EuiccInfo} for the eUICC chip/device. |
| 303 | * @see android.telephony.euicc.EuiccManager#getEuiccInfo |
| 304 | */ |
| 305 | public abstract EuiccInfo onGetEuiccInfo(int slotId); |
| 306 | |
| 307 | /** |
| 308 | * Delete the given subscription. |
| 309 | * |
| 310 | * <p>If the subscription is currently active, it should be deactivated first (equivalent to a |
| 311 | * physical SIM being ejected). |
| 312 | * |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 313 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 314 | * but is here to future-proof the APIs. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 315 | * @param iccid the ICCID of the subscription to delete. |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 316 | * @return the result of the delete operation. May be one of the predefined {@code RESULT_} |
| 317 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 318 | * @see android.telephony.euicc.EuiccManager#deleteSubscription |
| 319 | */ |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 320 | public abstract int onDeleteSubscription(int slotId, String iccid); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 321 | |
| 322 | /** |
| 323 | * Switch to the given subscription. |
| 324 | * |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 325 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 326 | * but is here to future-proof the APIs. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 327 | * @param iccid the ICCID of the subscription to enable. May be null, in which case the current |
| 328 | * profile should be deactivated and no profile should be activated to replace it - this is |
| 329 | * equivalent to a physical SIM being ejected. |
| 330 | * @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] | 331 | * eUICC, perform this action automatically. Otherwise, {@link #RESULT_MUST_DEACTIVATE_SIM} |
| 332 | * should be returned to allow the user to consent to this operation first. |
| 333 | * @return the result of the switch operation. May be one of the predefined {@code RESULT_} |
| 334 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 335 | * @see android.telephony.euicc.EuiccManager#switchToSubscription |
| 336 | */ |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 337 | public abstract int onSwitchToSubscription(int slotId, @Nullable String iccid, |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 338 | boolean forceDeactivateSim); |
| 339 | |
| 340 | /** |
| 341 | * Update the nickname of the given subscription. |
| 342 | * |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 343 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 344 | * but is here to future-proof the APIs. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 345 | * @param iccid the ICCID of the subscription to update. |
| 346 | * @param nickname the new nickname to apply. |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 347 | * @return the result of the update operation. May be one of the predefined {@code RESULT_} |
| 348 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 349 | * @see android.telephony.euicc.EuiccManager#updateSubscriptionNickname |
| 350 | */ |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 351 | public abstract int onUpdateSubscriptionNickname(int slotId, String iccid, |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 352 | String nickname); |
| 353 | |
| 354 | /** |
| 355 | * Erase all of the subscriptions on the device. |
| 356 | * |
| 357 | * <p>This is intended to be used for device resets. As such, the reset should be performed even |
| 358 | * if an active SIM must be deactivated in order to access the eUICC. |
| 359 | * |
| 360 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 361 | * but is here to future-proof the APIs. |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 362 | * @return the result of the erase operation. May be one of the predefined {@code RESULT_} |
| 363 | * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 364 | * @see android.telephony.euicc.EuiccManager#eraseSubscriptions |
| 365 | */ |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 366 | public abstract int onEraseSubscriptions(int slotId); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 367 | |
| 368 | /** |
Jeff Davidson | 7b69a86 | 2017-06-16 15:20:34 -0700 | [diff] [blame] | 369 | * Ensure that subscriptions will be retained on the next factory reset. |
| 370 | * |
| 371 | * <p>Called directly before a factory reset. Assumes that a normal factory reset will lead to |
| 372 | * profiles being erased on first boot (to cover fastboot/recovery wipes), so the implementation |
| 373 | * should persist some bit that will remain accessible after the factory reset to bypass this |
| 374 | * flow when this method is called. |
| 375 | * |
| 376 | * @param slotId ID of the SIM slot to use for the operation. This is currently not populated |
| 377 | * but is here to future-proof the APIs. |
| 378 | * @return the result of the operation. May be one of the predefined {@code RESULT_} constants |
| 379 | * or any implementation-specific code starting with {@link #RESULT_FIRST_USER}. |
| 380 | */ |
| 381 | public abstract int onRetainSubscriptionsForFactoryReset(int slotId); |
| 382 | |
| 383 | /** |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 384 | * Wrapper around IEuiccService that forwards calls to implementations of {@link EuiccService}. |
| 385 | */ |
| 386 | private class IEuiccServiceWrapper extends IEuiccService.Stub { |
| 387 | @Override |
| 388 | public void downloadSubscription(int slotId, DownloadableSubscription subscription, |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 389 | boolean switchAfterDownload, boolean forceDeactivateSim, |
| 390 | IDownloadSubscriptionCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 391 | mExecutor.execute(new Runnable() { |
| 392 | @Override |
| 393 | public void run() { |
| 394 | int result = EuiccService.this.onDownloadSubscription( |
| 395 | slotId, subscription, switchAfterDownload, forceDeactivateSim); |
| 396 | try { |
| 397 | callback.onComplete(result); |
| 398 | } catch (RemoteException e) { |
| 399 | // Can't communicate with the phone process; ignore. |
| 400 | } |
| 401 | } |
| 402 | }); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | @Override |
| 406 | public void getEid(int slotId, IGetEidCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 407 | mExecutor.execute(new Runnable() { |
| 408 | @Override |
| 409 | public void run() { |
| 410 | String eid = EuiccService.this.onGetEid(slotId); |
| 411 | try { |
| 412 | callback.onSuccess(eid); |
| 413 | } catch (RemoteException e) { |
| 414 | // Can't communicate with the phone process; ignore. |
| 415 | } |
| 416 | } |
| 417 | }); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | @Override |
Qingxi Li | 6019f9c | 2017-12-14 15:36:06 -0800 | [diff] [blame] | 421 | public void startOtaIfNecessary( |
| 422 | int slotId, IOtaStatusChangedCallback statusChangedCallback) { |
| 423 | mExecutor.execute(new Runnable() { |
| 424 | @Override |
| 425 | public void run() { |
| 426 | EuiccService.this.onStartOtaIfNecessary(slotId, new OtaStatusChangedCallback() { |
| 427 | @Override |
| 428 | public void onOtaStatusChanged(int status) { |
| 429 | try { |
| 430 | statusChangedCallback.onOtaStatusChanged(status); |
| 431 | } catch (RemoteException e) { |
| 432 | // Can't communicate with the phone process; ignore. |
| 433 | } |
| 434 | } |
| 435 | }); |
| 436 | } |
| 437 | }); |
| 438 | } |
| 439 | |
| 440 | @Override |
Qingxi Li | 5405836 | 2017-12-13 15:13:02 -0800 | [diff] [blame] | 441 | public void getOtaStatus(int slotId, IGetOtaStatusCallback callback) { |
| 442 | mExecutor.execute(new Runnable() { |
| 443 | @Override |
| 444 | public void run() { |
| 445 | int status = EuiccService.this.onGetOtaStatus(slotId); |
| 446 | try { |
| 447 | callback.onSuccess(status); |
| 448 | } catch (RemoteException e) { |
| 449 | // Can't communicate with the phone process; ignore. |
| 450 | } |
| 451 | } |
| 452 | }); |
| 453 | } |
| 454 | |
| 455 | @Override |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 456 | public void getDownloadableSubscriptionMetadata(int slotId, |
| 457 | DownloadableSubscription subscription, |
Jeff Davidson | cfa70fa | 2017-04-06 16:02:36 -0700 | [diff] [blame] | 458 | boolean forceDeactivateSim, |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 459 | IGetDownloadableSubscriptionMetadataCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 460 | mExecutor.execute(new Runnable() { |
| 461 | @Override |
| 462 | public void run() { |
| 463 | GetDownloadableSubscriptionMetadataResult result = |
| 464 | EuiccService.this.onGetDownloadableSubscriptionMetadata( |
| 465 | slotId, subscription, forceDeactivateSim); |
| 466 | try { |
| 467 | callback.onComplete(result); |
| 468 | } catch (RemoteException e) { |
| 469 | // Can't communicate with the phone process; ignore. |
| 470 | } |
| 471 | } |
| 472 | }); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 473 | } |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 474 | |
| 475 | @Override |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 476 | public void getDefaultDownloadableSubscriptionList(int slotId, boolean forceDeactivateSim, |
| 477 | IGetDefaultDownloadableSubscriptionListCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 478 | mExecutor.execute(new Runnable() { |
| 479 | @Override |
| 480 | public void run() { |
| 481 | GetDefaultDownloadableSubscriptionListResult result = |
| 482 | EuiccService.this.onGetDefaultDownloadableSubscriptionList( |
| 483 | slotId, forceDeactivateSim); |
| 484 | try { |
| 485 | callback.onComplete(result); |
| 486 | } catch (RemoteException e) { |
| 487 | // Can't communicate with the phone process; ignore. |
| 488 | } |
| 489 | } |
| 490 | }); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | @Override |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 494 | public void getEuiccProfileInfoList(int slotId, IGetEuiccProfileInfoListCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 495 | mExecutor.execute(new Runnable() { |
| 496 | @Override |
| 497 | public void run() { |
| 498 | GetEuiccProfileInfoListResult result = |
| 499 | EuiccService.this.onGetEuiccProfileInfoList(slotId); |
| 500 | try { |
| 501 | callback.onComplete(result); |
| 502 | } catch (RemoteException e) { |
| 503 | // Can't communicate with the phone process; ignore. |
| 504 | } |
| 505 | } |
| 506 | }); |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 507 | } |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 508 | |
| 509 | @Override |
| 510 | public void getEuiccInfo(int slotId, IGetEuiccInfoCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 511 | mExecutor.execute(new Runnable() { |
| 512 | @Override |
| 513 | public void run() { |
| 514 | EuiccInfo euiccInfo = EuiccService.this.onGetEuiccInfo(slotId); |
| 515 | try { |
| 516 | callback.onSuccess(euiccInfo); |
| 517 | } catch (RemoteException e) { |
| 518 | // Can't communicate with the phone process; ignore. |
| 519 | } |
| 520 | } |
| 521 | }); |
| 522 | |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | @Override |
| 526 | public void deleteSubscription(int slotId, String iccid, |
| 527 | IDeleteSubscriptionCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 528 | mExecutor.execute(new Runnable() { |
| 529 | @Override |
| 530 | public void run() { |
| 531 | int result = EuiccService.this.onDeleteSubscription(slotId, iccid); |
| 532 | try { |
| 533 | callback.onComplete(result); |
| 534 | } catch (RemoteException e) { |
| 535 | // Can't communicate with the phone process; ignore. |
| 536 | } |
| 537 | } |
| 538 | }); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | @Override |
| 542 | public void switchToSubscription(int slotId, String iccid, boolean forceDeactivateSim, |
| 543 | ISwitchToSubscriptionCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 544 | mExecutor.execute(new Runnable() { |
| 545 | @Override |
| 546 | public void run() { |
| 547 | int result = |
| 548 | EuiccService.this.onSwitchToSubscription( |
| 549 | slotId, iccid, forceDeactivateSim); |
| 550 | try { |
| 551 | callback.onComplete(result); |
| 552 | } catch (RemoteException e) { |
| 553 | // Can't communicate with the phone process; ignore. |
| 554 | } |
| 555 | } |
| 556 | }); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | @Override |
| 560 | public void updateSubscriptionNickname(int slotId, String iccid, String nickname, |
| 561 | IUpdateSubscriptionNicknameCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 562 | mExecutor.execute(new Runnable() { |
| 563 | @Override |
| 564 | public void run() { |
| 565 | int result = |
| 566 | EuiccService.this.onUpdateSubscriptionNickname(slotId, iccid, nickname); |
| 567 | try { |
| 568 | callback.onComplete(result); |
| 569 | } catch (RemoteException e) { |
| 570 | // Can't communicate with the phone process; ignore. |
| 571 | } |
| 572 | } |
| 573 | }); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | @Override |
| 577 | public void eraseSubscriptions(int slotId, IEraseSubscriptionsCallback callback) { |
Jeff Davidson | 707c372 | 2017-06-12 11:40:52 -0700 | [diff] [blame] | 578 | mExecutor.execute(new Runnable() { |
| 579 | @Override |
| 580 | public void run() { |
| 581 | int result = EuiccService.this.onEraseSubscriptions(slotId); |
| 582 | try { |
| 583 | callback.onComplete(result); |
| 584 | } catch (RemoteException e) { |
| 585 | // Can't communicate with the phone process; ignore. |
| 586 | } |
| 587 | } |
| 588 | }); |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 589 | } |
Jeff Davidson | 7b69a86 | 2017-06-16 15:20:34 -0700 | [diff] [blame] | 590 | |
| 591 | @Override |
| 592 | public void retainSubscriptionsForFactoryReset(int slotId, |
| 593 | IRetainSubscriptionsForFactoryResetCallback callback) { |
| 594 | mExecutor.execute(new Runnable() { |
| 595 | @Override |
| 596 | public void run() { |
| 597 | int result = EuiccService.this.onRetainSubscriptionsForFactoryReset(slotId); |
| 598 | try { |
| 599 | callback.onComplete(result); |
| 600 | } catch (RemoteException e) { |
| 601 | // Can't communicate with the phone process; ignore. |
| 602 | } |
| 603 | } |
| 604 | }); |
| 605 | } |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 606 | } |
| 607 | } |