blob: be8580074f73b6c396df5fb4bb58f7dfc6cacb3b [file] [log] [blame]
Jeff Davidson35cda392017-02-27 09:46:00 -08001/*
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 */
16package android.service.euicc;
17
18import android.annotation.CallSuper;
Jeff Davidson91c3d072017-04-12 12:17:11 -070019import android.annotation.Nullable;
Jeff Davidson35cda392017-02-27 09:46:00 -080020import android.app.Service;
21import android.content.Intent;
22import android.os.IBinder;
23import android.os.RemoteException;
24import android.telephony.euicc.DownloadableSubscription;
Jeff Davidson91c3d072017-04-12 12:17:11 -070025import android.telephony.euicc.EuiccInfo;
Qingxi Li54058362017-12-13 15:13:02 -080026import android.telephony.euicc.EuiccManager.OtaStatus;
Jeff Davidsoncfa70fa2017-04-06 16:02:36 -070027import android.util.ArraySet;
Jeff Davidson35cda392017-02-27 09:46:00 -080028
Jeff Davidson707c3722017-06-12 11:40:52 -070029import java.util.concurrent.LinkedBlockingQueue;
30import java.util.concurrent.ThreadFactory;
31import java.util.concurrent.ThreadPoolExecutor;
32import java.util.concurrent.TimeUnit;
33import java.util.concurrent.atomic.AtomicInteger;
34
Jeff Davidson35cda392017-02-27 09:46:00 -080035/**
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 Sund3bb4ae2018-02-08 16:38:26 +000044 * 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 Davidson35cda392017-02-27 09:46:00 -080046 *
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 Sund3bb4ae2018-02-08 16:38:26 +000068 * TODO(b/35851809): Make this a SystemApi.
Jeff Davidson35cda392017-02-27 09:46:00 -080069 * @hide
70 */
71public 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 Sund3bb4ae2018-02-08 16:38:26 +000080 /** @see android.telephony.euicc.EuiccManager#ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS */
Jeff Davidson35cda392017-02-27 09:46:00 -080081 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 Davidsoncfa70fa2017-04-06 16:02:36 -070087 // 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 Sund3bb4ae2018-02-08 16:38:26 +000091 /** Alert the user that this action will result in an active SIM being deactivated. */
Jeff Davidsoncfa70fa2017-04-06 16:02:36 -070092 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 Davidson83f8bc82017-05-15 10:22:20 -0700100
Holly Jiuyu Sun6a2877e2017-10-13 19:06:34 -0700101 /** 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 Sund3bb4ae2018-02-08 16:38:26 +0000105 /** Intent extra set for resolution requests containing the package name of the calling app. */
Jeff Davidsonb4c67ec2017-06-13 15:28:57 -0700106 public static final String EXTRA_RESOLUTION_CALLING_PACKAGE =
107 "android.service.euicc.extra.RESOLUTION_CALLING_PACKAGE";
108
Holly Jiuyu Sun26008be2017-11-09 19:28:49 -0800109 /**
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 Davidson83f8bc82017-05-15 10:22:20 -0700116 /** 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 Sun6a2877e2017-10-13 19:06:34 -0700120 /** Result code indicating that the user must input a carrier confirmation code. */
121 public static final int RESULT_NEED_CONFIRMATION_CODE = -2;
Jeff Davidson83f8bc82017-05-15 10:22:20 -0700122 // 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 Davidsoncfa70fa2017-04-06 16:02:36 -0700127 /**
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 Sun6a2877e2017-10-13 19:06:34 -0700136 RESOLUTION_ACTIONS.add(EuiccService.ACTION_RESOLVE_CONFIRMATION_CODE);
Jeff Davidsoncfa70fa2017-04-06 16:02:36 -0700137 }
138
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +0000139 /** 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 Davidsoncfa70fa2017-04-06 16:02:36 -0700143
Jeff Davidson35cda392017-02-27 09:46:00 -0800144 private final IEuiccService.Stub mStubWrapper;
145
Jeff Davidson707c3722017-06-12 11:40:52 -0700146 private ThreadPoolExecutor mExecutor;
147
Jeff Davidson35cda392017-02-27 09:46:00 -0800148 public EuiccService() {
149 mStubWrapper = new IEuiccServiceWrapper();
150 }
151
Jeff Davidson707c3722017-06-12 11:40:52 -0700152 @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 Davidson35cda392017-02-27 09:46:00 -0800185 /**
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 Li6019f9c2017-12-14 15:36:06 -0800196 * 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 Sund3bb4ae2018-02-08 16:38:26 +0000202 public interface OtaStatusChangedCallback {
Qingxi Li6019f9c2017-12-14 15:36:06 -0800203 /** Called when OTA status is changed. */
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +0000204 void onOtaStatusChanged(int status);
Qingxi Li6019f9c2017-12-14 15:36:06 -0800205 }
206
207 /**
Jeff Davidson35cda392017-02-27 09:46:00 -0800208 * 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 Li54058362017-12-13 15:13:02 -0800219 * 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 Li6019f9c2017-12-14 15:36:06 -0800229 * 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 Davidson35cda392017-02-27 09:46:00 -0800239 * Populate {@link DownloadableSubscription} metadata for the given downloadable subscription.
240 *
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +0000241 * @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 Davidson35cda392017-02-27 09:46:00 -0800243 * @param subscription A subscription whose metadata needs to be populated.
Jeff Davidsoncfa70fa2017-04-06 16:02:36 -0700244 * @param forceDeactivateSim If true, and if an active SIM must be deactivated to access the
Jeff Davidson83f8bc82017-05-15 10:22:20 -0700245 * 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 Davidson35cda392017-02-27 09:46:00 -0800247 * @return The result of the operation.
248 * @see android.telephony.euicc.EuiccManager#getDownloadableSubscriptionMetadata
249 */
Jeff Davidson91c3d072017-04-12 12:17:11 -0700250 public abstract GetDownloadableSubscriptionMetadataResult onGetDownloadableSubscriptionMetadata(
Jeff Davidsoncfa70fa2017-04-06 16:02:36 -0700251 int slotId, DownloadableSubscription subscription, boolean forceDeactivateSim);
Jeff Davidson35cda392017-02-27 09:46:00 -0800252
253 /**
Jeff Davidson91c3d072017-04-12 12:17:11 -0700254 * 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 Davidson83f8bc82017-05-15 10:22:20 -0700259 * 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 Davidson91c3d072017-04-12 12:17:11 -0700261 * @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 Davidson35cda392017-02-27 09:46:00 -0800268 * Download the given subscription.
269 *
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +0000270 * @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 Davidson35cda392017-02-27 09:46:00 -0800272 * @param subscription The subscription to download.
273 * @param switchAfterDownload If true, the subscription should be enabled upon successful
274 * download.
Jeff Davidsoncfa70fa2017-04-06 16:02:36 -0700275 * @param forceDeactivateSim If true, and if an active SIM must be deactivated to access the
Jeff Davidson83f8bc82017-05-15 10:22:20 -0700276 * 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 Davidson35cda392017-02-27 09:46:00 -0800280 * @see android.telephony.euicc.EuiccManager#downloadSubscription
281 */
Jeff Davidson83f8bc82017-05-15 10:22:20 -0700282 public abstract int onDownloadSubscription(int slotId,
Jeff Davidsoncfa70fa2017-04-06 16:02:36 -0700283 DownloadableSubscription subscription, boolean switchAfterDownload,
284 boolean forceDeactivateSim);
Jeff Davidson35cda392017-02-27 09:46:00 -0800285
286 /**
Jeff Davidsond02731f2017-04-09 14:31:09 -0700287 * Return a list of all @link EuiccProfileInfo}s.
288 *
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +0000289 * @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 Davidsond02731f2017-04-09 14:31:09 -0700291 * @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 Davidson91c3d072017-04-12 12:17:11 -0700298 * Return info about the eUICC chip/device.
299 *
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +0000300 * @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 Davidson91c3d072017-04-12 12:17:11 -0700302 * @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 Sund3bb4ae2018-02-08 16:38:26 +0000313 * @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 Davidson91c3d072017-04-12 12:17:11 -0700315 * @param iccid the ICCID of the subscription to delete.
Jeff Davidson83f8bc82017-05-15 10:22:20 -0700316 * @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 Davidson91c3d072017-04-12 12:17:11 -0700318 * @see android.telephony.euicc.EuiccManager#deleteSubscription
319 */
Jeff Davidson83f8bc82017-05-15 10:22:20 -0700320 public abstract int onDeleteSubscription(int slotId, String iccid);
Jeff Davidson91c3d072017-04-12 12:17:11 -0700321
322 /**
323 * Switch to the given subscription.
324 *
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +0000325 * @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 Davidson91c3d072017-04-12 12:17:11 -0700327 * @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 Davidson83f8bc82017-05-15 10:22:20 -0700331 * 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 Davidson91c3d072017-04-12 12:17:11 -0700335 * @see android.telephony.euicc.EuiccManager#switchToSubscription
336 */
Jeff Davidson83f8bc82017-05-15 10:22:20 -0700337 public abstract int onSwitchToSubscription(int slotId, @Nullable String iccid,
Jeff Davidson91c3d072017-04-12 12:17:11 -0700338 boolean forceDeactivateSim);
339
340 /**
341 * Update the nickname of the given subscription.
342 *
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +0000343 * @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 Davidson91c3d072017-04-12 12:17:11 -0700345 * @param iccid the ICCID of the subscription to update.
346 * @param nickname the new nickname to apply.
Jeff Davidson83f8bc82017-05-15 10:22:20 -0700347 * @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 Davidson91c3d072017-04-12 12:17:11 -0700349 * @see android.telephony.euicc.EuiccManager#updateSubscriptionNickname
350 */
Jeff Davidson83f8bc82017-05-15 10:22:20 -0700351 public abstract int onUpdateSubscriptionNickname(int slotId, String iccid,
Jeff Davidson91c3d072017-04-12 12:17:11 -0700352 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 Davidson83f8bc82017-05-15 10:22:20 -0700362 * @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 Davidson91c3d072017-04-12 12:17:11 -0700364 * @see android.telephony.euicc.EuiccManager#eraseSubscriptions
365 */
Jeff Davidson83f8bc82017-05-15 10:22:20 -0700366 public abstract int onEraseSubscriptions(int slotId);
Jeff Davidson91c3d072017-04-12 12:17:11 -0700367
368 /**
Jeff Davidson7b69a862017-06-16 15:20:34 -0700369 * 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 Davidson35cda392017-02-27 09:46:00 -0800384 * 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 Davidsoncfa70fa2017-04-06 16:02:36 -0700389 boolean switchAfterDownload, boolean forceDeactivateSim,
390 IDownloadSubscriptionCallback callback) {
Jeff Davidson707c3722017-06-12 11:40:52 -0700391 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 Davidson35cda392017-02-27 09:46:00 -0800403 }
404
405 @Override
406 public void getEid(int slotId, IGetEidCallback callback) {
Jeff Davidson707c3722017-06-12 11:40:52 -0700407 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 Davidson35cda392017-02-27 09:46:00 -0800418 }
419
420 @Override
Qingxi Li6019f9c2017-12-14 15:36:06 -0800421 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 Li54058362017-12-13 15:13:02 -0800441 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 Davidson35cda392017-02-27 09:46:00 -0800456 public void getDownloadableSubscriptionMetadata(int slotId,
457 DownloadableSubscription subscription,
Jeff Davidsoncfa70fa2017-04-06 16:02:36 -0700458 boolean forceDeactivateSim,
Jeff Davidson35cda392017-02-27 09:46:00 -0800459 IGetDownloadableSubscriptionMetadataCallback callback) {
Jeff Davidson707c3722017-06-12 11:40:52 -0700460 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 Davidson35cda392017-02-27 09:46:00 -0800473 }
Jeff Davidsond02731f2017-04-09 14:31:09 -0700474
475 @Override
Jeff Davidson91c3d072017-04-12 12:17:11 -0700476 public void getDefaultDownloadableSubscriptionList(int slotId, boolean forceDeactivateSim,
477 IGetDefaultDownloadableSubscriptionListCallback callback) {
Jeff Davidson707c3722017-06-12 11:40:52 -0700478 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 Davidson91c3d072017-04-12 12:17:11 -0700491 }
492
493 @Override
Jeff Davidsond02731f2017-04-09 14:31:09 -0700494 public void getEuiccProfileInfoList(int slotId, IGetEuiccProfileInfoListCallback callback) {
Jeff Davidson707c3722017-06-12 11:40:52 -0700495 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 Davidsond02731f2017-04-09 14:31:09 -0700507 }
Jeff Davidson91c3d072017-04-12 12:17:11 -0700508
509 @Override
510 public void getEuiccInfo(int slotId, IGetEuiccInfoCallback callback) {
Jeff Davidson707c3722017-06-12 11:40:52 -0700511 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 Davidson91c3d072017-04-12 12:17:11 -0700523 }
524
525 @Override
526 public void deleteSubscription(int slotId, String iccid,
527 IDeleteSubscriptionCallback callback) {
Jeff Davidson707c3722017-06-12 11:40:52 -0700528 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 Davidson91c3d072017-04-12 12:17:11 -0700539 }
540
541 @Override
542 public void switchToSubscription(int slotId, String iccid, boolean forceDeactivateSim,
543 ISwitchToSubscriptionCallback callback) {
Jeff Davidson707c3722017-06-12 11:40:52 -0700544 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 Davidson91c3d072017-04-12 12:17:11 -0700557 }
558
559 @Override
560 public void updateSubscriptionNickname(int slotId, String iccid, String nickname,
561 IUpdateSubscriptionNicknameCallback callback) {
Jeff Davidson707c3722017-06-12 11:40:52 -0700562 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 Davidson91c3d072017-04-12 12:17:11 -0700574 }
575
576 @Override
577 public void eraseSubscriptions(int slotId, IEraseSubscriptionsCallback callback) {
Jeff Davidson707c3722017-06-12 11:40:52 -0700578 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 Davidson91c3d072017-04-12 12:17:11 -0700589 }
Jeff Davidson7b69a862017-06-16 15:20:34 -0700590
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 Davidson35cda392017-02-27 09:46:00 -0800606 }
607}