Add generic SIM activation framework.
Change-Id: I8c1b1b1f8124398655021b7028c1f728a40bf67b
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index d3e8829..6c658d3 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -66,6 +66,7 @@
import com.android.phone.common.CallLogAsync;
import com.android.phone.settings.SettingsConstants;
import com.android.server.sip.SipService;
+import com.android.services.telephony.activation.SimActivationManager;
import java.util.ArrayList;
import java.util.List;
@@ -145,6 +146,7 @@
CallerInfoCache callerInfoCache;
NotificationMgr notificationMgr;
public PhoneInterfaceManager phoneMgr;
+ public SimActivationManager simActivationManager;
private BluetoothManager bluetoothManager;
private CallGatewayManager callGatewayManager;
@@ -441,6 +443,8 @@
cdmaOtaScreenState = new OtaUtils.CdmaOtaScreenState();
cdmaOtaInCallScreenUiState = new OtaUtils.CdmaOtaInCallScreenUiState();
+ simActivationManager = new SimActivationManager();
+
// XXX pre-load the SimProvider so that it's ready
resolver.getType(Uri.parse("content://icc/adn"));
diff --git a/src/com/android/services/telephony/activation/Activator.java b/src/com/android/services/telephony/activation/Activator.java
new file mode 100644
index 0000000..7dee5b3
--- /dev/null
+++ b/src/com/android/services/telephony/activation/Activator.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2015 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 com.android.services.telephony.activation;
+
+/**
+ * SIM Activation implementation generic interface.
+ */
+public interface Activator {
+ void onActivate();
+}
diff --git a/src/com/android/services/telephony/activation/OtaspActivator.java b/src/com/android/services/telephony/activation/OtaspActivator.java
new file mode 100644
index 0000000..11ba726
--- /dev/null
+++ b/src/com/android/services/telephony/activation/OtaspActivator.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2015 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 com.android.services.telephony.activation;
+
+/**
+ * Over-The-Air SIM Provisioning (OTASP) activation implementation.
+ *
+ * Handles OTASP activation requests and returns status updates as activation progresses.
+ */
+public class OtaspActivator implements Activator {
+ @Override
+ public void onActivate() {
+ // TODO: handle otasp activation
+ }
+}
diff --git a/src/com/android/services/telephony/activation/SimActivationActivity.java b/src/com/android/services/telephony/activation/SimActivationActivity.java
index 3833706..ae11a3f 100644
--- a/src/com/android/services/telephony/activation/SimActivationActivity.java
+++ b/src/com/android/services/telephony/activation/SimActivationActivity.java
@@ -23,6 +23,7 @@
import android.os.Bundle;
import android.telephony.TelephonyManager;
+import com.android.phone.PhoneGlobals;
import com.android.services.telephony.Log;
/**
@@ -45,19 +46,28 @@
}
private void runActivation(Intent intent) {
- PendingIntent response = intent.getParcelableExtra(Intent.EXTRA_SIM_ACTIVATION_RESPONSE);
+ final PendingIntent response =
+ intent.getParcelableExtra(Intent.EXTRA_SIM_ACTIVATION_RESPONSE);
Log.i(this, "Running activation w/ response " + response);
- // TODO: Actually do activation
+ PhoneGlobals app = PhoneGlobals.getInstance();
+ app.simActivationManager.runActivation(SimActivationManager.Triggers.EXPLICIT_REQUEST,
+ new SimActivationManager.Response() {
+ @Override
+ public void onResponse(int status) {
+ if (response != null) {
+ try {
+ response.send();
+ } catch (CanceledException e) {
+ Log.w(this, "Could not respond to SIM Activation.");
+ }
+ }
+ }
+ });
+
+ // TODO: Set this status to the return value of runActivation
// Return the response as an activity result and the pending intent.
- setResult(TelephonyManager.SIM_ACTIVATION_RESULT_COMPLETE);
- if (response != null) {
- try {
- response.send();
- } catch (CanceledException e) {
- Log.w(this, "Could not respond to SIM Activation.");
- }
- }
+ setResult(TelephonyManager.SIM_ACTIVATION_RESULT_IN_PROGRESS);
}
}
diff --git a/src/com/android/services/telephony/activation/SimActivationManager.java b/src/com/android/services/telephony/activation/SimActivationManager.java
new file mode 100644
index 0000000..ce9e508
--- /dev/null
+++ b/src/com/android/services/telephony/activation/SimActivationManager.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2015 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 com.android.services.telephony.activation;
+
+import android.app.PendingIntent;
+import android.telephony.TelephonyManager;
+
+/**
+ * Handles SIM activation requests and runs the appropriate activation process until it completes
+ * or fails. When done, sends back a response if needed.
+ */
+public class SimActivationManager {
+ public static final class Triggers {
+ public static final int SYSTEM_START = 1;
+ public static final int EXPLICIT_REQUEST = 2;
+ }
+
+ public interface Response {
+ /**
+ * @param status See {@link android.telephony.TelephonyManager} for SIM_ACTIVATION_RESULT_*
+ * constants.
+ */
+ void onResponse(int status);
+ }
+
+ public void runActivation(int trigger, Response response) {
+ Activator activator = selectActivator(trigger);
+
+ activator.onActivate();
+
+ // TODO: Specify some way to determine if activation is even necessary.
+
+ // TODO: specify some way to return the result.
+
+ if (response != null) {
+ response.onResponse(TelephonyManager.SIM_ACTIVATION_RESULT_COMPLETE);
+ }
+ }
+
+ private Activator selectActivator(int trigger) {
+ // TODO: Select among all activator types
+
+ // For now, pick a do-nothing activator
+ return new Activator() {
+
+ /** ${inheritDoc} */
+ @Override
+ public void onActivate() {
+ // do something
+ }
+ };
+ }
+}