Add API EuiccController#startOtaUpdatingIfNecessary

This function requests calling app has WRITE_EMBEDDED_SUBSCRIPTIONS
permission. It will check whether the OTA update needed to be done
first. If current eUICC OS isn't latest one and OTA needed to be
performed, it will update eUICC OS. When the OS update is started or
finished, a broadcast will be sent.

Bug: 37279356
Test: E2E
Merged-In: Iea86add4bdc01c79a8714af4b3a89735ba78ee74
Change-Id: Iea86add4bdc01c79a8714af4b3a89735ba78ee74
This commit is contained in:
Qingxi Li
2017-12-14 15:36:06 -08:00
parent 8098078edf
commit 8314fa72f2
6 changed files with 84 additions and 0 deletions

View File

@@ -248,6 +248,7 @@ java_library {
"core/java/android/service/euicc/IGetEuiccInfoCallback.aidl",
"core/java/android/service/euicc/IGetEuiccProfileInfoListCallback.aidl",
"core/java/android/service/euicc/IGetOtaStatusCallback.aidl",
"core/java/android/service/euicc/IOtaStatusChangedCallback.aidl",
"core/java/android/service/euicc/IRetainSubscriptionsForFactoryResetCallback.aidl",
"core/java/android/service/euicc/ISwitchToSubscriptionCallback.aidl",
"core/java/android/service/euicc/IUpdateSubscriptionNicknameCallback.aidl",

View File

@@ -192,6 +192,18 @@ public abstract class EuiccService extends Service {
return mStubWrapper;
}
/**
* Callback class for {@link #onStartOtaIfNecessary(int, OtaStatusChangedCallback)}
*
* The status of OTA which can be {@code android.telephony.euicc.EuiccManager#EUICC_OTA_}
*
* @see IEuiccService#startOtaIfNecessary
*/
public interface OtaStatusChangedCallback {
/** Called when OTA status is changed. */
void onOtaStatusChanged(int status);
}
/**
* Return the EID of the eUICC.
*
@@ -213,6 +225,16 @@ public abstract class EuiccService extends Service {
*/
public abstract @OtaStatus int onGetOtaStatus(int slotId);
/**
* Perform OTA if current OS is not the latest one.
*
* @param slotId ID of the SIM slot to use for the operation. This is currently not populated
* but is here to future-proof the APIs.
* @param statusChangedCallback Function called when OTA status changed.
*/
public abstract void onStartOtaIfNecessary(
int slotId, OtaStatusChangedCallback statusChangedCallback);
/**
* Populate {@link DownloadableSubscription} metadata for the given downloadable subscription.
*
@@ -395,6 +417,26 @@ public abstract class EuiccService extends Service {
});
}
@Override
public void startOtaIfNecessary(
int slotId, IOtaStatusChangedCallback statusChangedCallback) {
mExecutor.execute(new Runnable() {
@Override
public void run() {
EuiccService.this.onStartOtaIfNecessary(slotId, new OtaStatusChangedCallback() {
@Override
public void onOtaStatusChanged(int status) {
try {
statusChangedCallback.onOtaStatusChanged(status);
} catch (RemoteException e) {
// Can't communicate with the phone process; ignore.
}
}
});
}
});
}
@Override
public void getOtaStatus(int slotId, IGetOtaStatusCallback callback) {
mExecutor.execute(new Runnable() {

View File

@@ -25,6 +25,7 @@ import android.service.euicc.IGetEidCallback;
import android.service.euicc.IGetEuiccInfoCallback;
import android.service.euicc.IGetEuiccProfileInfoListCallback;
import android.service.euicc.IGetOtaStatusCallback;
import android.service.euicc.IOtaStatusChangedCallback;
import android.service.euicc.IRetainSubscriptionsForFactoryResetCallback;
import android.service.euicc.ISwitchToSubscriptionCallback;
import android.service.euicc.IUpdateSubscriptionNicknameCallback;
@@ -39,6 +40,7 @@ oneway interface IEuiccService {
boolean forceDeactivateSim, in IGetDownloadableSubscriptionMetadataCallback callback);
void getEid(int slotId, in IGetEidCallback callback);
void getOtaStatus(int slotId, in IGetOtaStatusCallback callback);
void startOtaIfNecessary(int slotId, in IOtaStatusChangedCallback statusChangedCallback);
void getEuiccProfileInfoList(int slotId, in IGetEuiccProfileInfoListCallback callback);
void getDefaultDownloadableSubscriptionList(int slotId, boolean forceDeactivateSim,
in IGetDefaultDownloadableSubscriptionListCallback callback);

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.service.euicc;
/** @hide */
oneway interface IOtaStatusChangedCallback {
void onOtaStatusChanged(int status);
}

View File

@@ -563,6 +563,9 @@
<protected-broadcast android:name="android.media.tv.action.CHANNEL_BROWSABLE_REQUESTED" />
<protected-broadcast android:name="com.android.server.InputMethodManagerService.SHOW_INPUT_METHOD_PICKER" />
<!-- Added in P -->
<protected-broadcast android:name="android.telephony.euicc.action.OTA_STATUS_CHANGED" />
<!-- ====================================================================== -->
<!-- RUNTIME PERMISSIONS -->
<!-- ====================================================================== -->

View File

@@ -60,6 +60,20 @@ public class EuiccManager {
public static final String ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS =
"android.telephony.euicc.action.MANAGE_EMBEDDED_SUBSCRIPTIONS";
/**
* Broadcast Action: The eUICC OTA status is changed.
* <p class="note">
* Requires the {@link android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission.
*
* <p class="note">This is a protected intent that can only be sent
* by the system.
* TODO(b/35851809): Make this a SystemApi.
*/
@SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_OTA_STATUS_CHANGED
= "android.telephony.euicc.action.OTA_STATUS_CHANGED";
/**
* Intent action to provision an embedded subscription.
*