Merge "remove activation button from preferred NW setting"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f611706..de5e979 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -133,6 +133,7 @@
<uses-permission android:name="android.permission.DUMP" />
<uses-permission android:name="android.permission.REGISTER_CALL_PROVIDER" />
<uses-permission android:name="android.permission.REGISTER_SIM_SUBSCRIPTION" />
+ <uses-permission android:name="android.permission.BIND_IMS_SERVICE" />
<uses-permission android:name="android.permission.BIND_CARRIER_SERVICES" />
<!-- BIND_CARRIER_MESSAGING_SERVICE has been deprecated in favor of BIND_CARRIER_SERVICES. -->
<uses-permission android:name="android.permission.BIND_CARRIER_MESSAGING_SERVICE" />
@@ -156,6 +157,7 @@
start requests, even if they happen immediately after the user
presses home. -->
<uses-permission android:name="android.permission.STOP_APP_SWITCHES" />
+ <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
<application android:name="PhoneApp"
android:persistent="true"
@@ -326,18 +328,6 @@
</intent-filter>
</activity>
- <!-- Trampoline activity that handles the SIM_ACTIVATION_REQUEST intent. -->
- <activity android:name="com.android.services.telephony.activation.SimActivationActivity"
- android:permission="android.permission.PERFORM_SIM_ACTIVATION"
- android:label="@string/phoneIconLabel"
- android:theme="@android:style/Theme.NoDisplay"
- android:excludeFromRecents="true">
- <intent-filter>
- <action android:name="android.intent.action.SIM_ACTIVATION_REQUEST" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
<!-- "Mobile network settings" screen, used on both
non-voice-capable tablets and regular phone devices. -->
<activity android:name="MobileNetworkSettings"
@@ -469,6 +459,20 @@
</intent-filter>
</receiver>
+ <!-- Activation service that trigger OTASP sim provisioning -->
+ <service android:name=".otasp.OtaspActivationService" android:launchMode="singleInstance"
+ androidprv:systemUserOnly="true">
+ <intent-filter>
+ <action android:name="android.service.simActivation.SimActivationService" />
+ </intent-filter>
+ </service>
+
+ <receiver android:name=".otasp.OtaspSimStateReceiver" android:exported ="false">
+ <intent-filter>
+ <action android:name="android.telephony.action.CARRIER_CONFIG_CHANGED" />
+ </intent-filter>
+ </receiver>
+
<!-- "Accessibility" settings UI. Referenced by Dialer application. -->
<activity android:name="com.android.phone.settings.AccessibilitySettingsActivity"
android:label="@string/accessibility_settings_activity_title"
diff --git a/res/values-mcc208-mnc09-fr/strings.xml b/res/values-mcc208-mnc09-fr/strings.xml
new file mode 100644
index 0000000..ac5ef59
--- /dev/null
+++ b/res/values-mcc208-mnc09-fr/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="enhanced_4g_lte_mode_summary">Utiliser la fonction Voix 4G (HD) lorsqu\'elle est disponible</string>
+ <string name="enhanced_4g_lte_mode_title">Activer Voix 4G (HD)</string>
+</resources>
diff --git a/res/values-mcc208-mnc10-fr/strings.xml b/res/values-mcc208-mnc10-fr/strings.xml
new file mode 100644
index 0000000..ac5ef59
--- /dev/null
+++ b/res/values-mcc208-mnc10-fr/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="enhanced_4g_lte_mode_summary">Utiliser la fonction Voix 4G (HD) lorsqu\'elle est disponible</string>
+ <string name="enhanced_4g_lte_mode_title">Activer Voix 4G (HD)</string>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 72a7fc7..ec7d761 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -805,6 +805,8 @@
<string name="menu_edit">Edit contact</string>
<!-- FDN list screen: menu item label -->
<string name="menu_delete">Delete contact</string>
+ <!-- FDN list screen: menu item label -->
+ <string name="menu_dial">Dial contact</string>
<!-- FDN related strings -->
<!-- Label for PIN2 entry screen -->
@@ -997,8 +999,6 @@
<string name="incall_error_call_failed">Call failed.</string>
<!-- In-call screen: call failure message displayed in an error dialog -->
<string name="incall_error_cannot_add_call">Call cannot be added at this time.</string>
- <!-- In-call screen: status message displayed in a dialog when starting an MMI -->
- <string name="incall_status_dialed_mmi">Starting MMI sequence\u2026</string>
<!-- In-call screen: message displayed in an error dialog -->
<string name="incall_error_supp_service_unknown">Service not supported</string>
<!-- In-call screen: message displayed in an error dialog -->
@@ -1366,6 +1366,12 @@
Unable to connect, please insert a valid SIM card.
</string>
+ <!-- Call failure reason displayed when an in-progress WIFI call fails due to a loss of WIFI
+ connectivity, or the WIFI signal has degraded to the point the call cannot continue. -->
+ <string name="callFailed_wifi_lost">
+ Wi-Fi connection lost. Call ended.
+ </string>
+
<!-- The title for the change voicemail PIN activity -->
<string name="change_pin_title">Change Voicemail PIN</string>
<!-- The label for the continue button in change voicemail PIN activity -->
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 5a40322..47bb064 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -58,6 +58,7 @@
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.util.FastXmlSerializer;
+import com.android.internal.util.IndentingPrintWriter;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -71,6 +72,9 @@
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
/**
@@ -712,9 +716,41 @@
}
pw.println("CarrierConfigLoader: " + this);
for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
- pw.println(" Phone Id=" + i);
- pw.println(" mConfigFromDefaultApp=" + mConfigFromDefaultApp[i]);
- pw.println(" mConfigFromCarrierApp=" + mConfigFromCarrierApp[i]);
+ pw.println("Phone Id = " + i);
+ // display default values in CarrierConfigManager
+ printConfig(CarrierConfigManager.getDefaultConfig(), pw,
+ "Default Values from CarrierConfigManager");
+ pw.println("");
+ // display ConfigFromDefaultApp
+ printConfig(mConfigFromDefaultApp[i], pw, "mConfigFromDefaultApp");
+ pw.println("");
+ // display ConfigFromCarrierApp
+ printConfig(mConfigFromCarrierApp[i], pw, "mConfigFromCarrierApp");
+ }
+ }
+
+ private void printConfig(PersistableBundle configApp, PrintWriter pw, String name) {
+ IndentingPrintWriter indentPW = new IndentingPrintWriter(pw, " ");
+ if (configApp == null) {
+ indentPW.increaseIndent();
+ indentPW.println(name + " : null ");
+ return;
+ }
+ indentPW.increaseIndent();
+ indentPW.println(name + " : ");
+ List<String> sortedKeys = new ArrayList<String>(configApp.keySet());
+ Collections.sort(sortedKeys);
+ indentPW.increaseIndent();
+ indentPW.increaseIndent();
+ for (String key : sortedKeys) {
+ if (configApp.get(key) != null && configApp.get(key) instanceof Object[]) {
+ indentPW.println(key + " = " +
+ Arrays.toString((Object[]) configApp.get(key)));
+ } else if (configApp.get(key) != null && configApp.get(key) instanceof int[]) {
+ indentPW.println(key + " = " + Arrays.toString((int[]) configApp.get(key)));
+ } else {
+ indentPW.println(key + " = " + configApp.get(key));
+ }
}
}
diff --git a/src/com/android/phone/MMIDialogActivity.java b/src/com/android/phone/MMIDialogActivity.java
index 10ec6a3..5ac6b85 100644
--- a/src/com/android/phone/MMIDialogActivity.java
+++ b/src/com/android/phone/MMIDialogActivity.java
@@ -63,9 +63,6 @@
}
};
mCM.registerForMmiComplete(mHandler, PhoneGlobals.MMI_COMPLETE, null);
- if (mCM.getState() == PhoneConstants.State.OFFHOOK) {
- Toast.makeText(this, R.string.incall_status_dialed_mmi, Toast.LENGTH_SHORT).show();
- }
showMMIDialog();
}
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index f45fb94..cec5a76 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -57,7 +57,6 @@
import com.android.internal.telephony.TelephonyIntents;
import com.android.phone.common.CallLogAsync;
import com.android.phone.settings.SettingsConstants;
-import com.android.services.telephony.activation.SimActivationManager;
import com.android.services.telephony.sip.SipUtil;
/**
@@ -129,7 +128,6 @@
CallerInfoCache callerInfoCache;
NotificationMgr notificationMgr;
public PhoneInterfaceManager phoneMgr;
- public SimActivationManager simActivationManager;
CarrierConfigLoader configLoader;
private CallGatewayManager callGatewayManager;
@@ -373,8 +371,6 @@
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/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 38e40d7..75c6d87 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -38,6 +38,7 @@
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
+import android.os.WorkSource;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.service.carrier.CarrierIdentifier;
@@ -46,6 +47,7 @@
import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.telephony.CellInfo;
+import android.telephony.ClientRequestStats;
import android.telephony.IccOpenLogicalChannelResponse;
import android.telephony.ModemActivityInfo;
import android.telephony.NeighboringCellInfo;
@@ -62,6 +64,8 @@
import android.util.Pair;
import android.util.Slog;
import com.android.ims.ImsManager;
+import com.android.ims.internal.IImsServiceController;
+import com.android.ims.internal.IImsServiceFeatureListener;
import com.android.internal.telephony.CallManager;
import com.android.internal.telephony.CellNetworkScanResult;
import com.android.internal.telephony.CommandException;
@@ -273,7 +277,7 @@
request = (MainThreadRequest) msg.obj;
onCompleted = obtainMessage(EVENT_NEIGHBORING_CELL_DONE,
request);
- mPhone.getNeighboringCids(onCompleted);
+ mPhone.getNeighboringCids(onCompleted, (WorkSource)request.argument);
break;
case EVENT_NEIGHBORING_CELL_DONE:
@@ -1524,7 +1528,9 @@
if (phone == null) {
return null;
}
- phone.getCellLocation().fillInNotifierBundle(data);
+
+ WorkSource workSource = getWorkSource(null, Binder.getCallingUid());
+ phone.getCellLocation(workSource).fillInNotifierBundle(data);
return data;
} else {
log("getCellLocation: suppress non-active user");
@@ -1598,9 +1604,10 @@
ArrayList<NeighboringCellInfo> cells = null;
+ WorkSource workSource = getWorkSource(null, Binder.getCallingUid());
try {
cells = (ArrayList<NeighboringCellInfo>) sendRequest(
- CMD_HANDLE_NEIGHBORING_CELL, null,
+ CMD_HANDLE_NEIGHBORING_CELL, workSource,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
} catch (RuntimeException e) {
Log.e(LOG_TAG, "getNeighboringCellInfo " + e);
@@ -1626,10 +1633,11 @@
if (checkIfCallerIsSelfOrForegroundUser() ||
checkCallerInteractAcrossUsersFull()) {
if (DBG_LOC) log("getAllCellInfo: is active user");
+ WorkSource workSource = getWorkSource(null, Binder.getCallingUid());
List<CellInfo> cellInfos = new ArrayList<CellInfo>();
for (Phone phone : PhoneFactory.getPhones()) {
- final List<CellInfo> info = phone.getAllCellInfo();
- if (info != null) cellInfos.addAll(phone.getAllCellInfo());
+ final List<CellInfo> info = phone.getAllCellInfo(workSource);
+ if (info != null) cellInfos.addAll(info);
}
return cellInfos;
} else {
@@ -1640,7 +1648,8 @@
@Override
public void setCellInfoListRate(int rateInMillis) {
- mPhone.setCellInfoListRate(rateInMillis);
+ WorkSource workSource = getWorkSource(null, Binder.getCallingUid());
+ mPhone.setCellInfoListRate(rateInMillis, workSource);
}
@Override
@@ -1958,6 +1967,66 @@
.getVisualVoicemailSmsFilterSettings(mPhone.getContext(), packageName, subId);
}
/**
+ * Sets the voice activation state of a given subId.
+ */
+ @Override
+ public void setVoiceActivationState(int subId, int activationState) {
+ enforceModifyPermissionOrCarrierPrivilege(subId);
+ final Phone phone = getPhone(subId);
+ if (phone != null) {
+ phone.setVoiceActivationState(activationState);
+ } else {
+ loge("setVoiceActivationState fails with invalid subId: " + subId);
+ }
+ }
+
+ /**
+ * Sets the data activation state of a given subId.
+ */
+ @Override
+ public void setDataActivationState(int subId, int activationState) {
+ enforceModifyPermissionOrCarrierPrivilege(subId);
+ final Phone phone = getPhone(subId);
+ if (phone != null) {
+ phone.setDataActivationState(activationState);
+ } else {
+ loge("setVoiceActivationState fails with invalid subId: " + subId);
+ }
+ }
+
+ /**
+ * Returns the voice activation state of a given subId.
+ */
+ @Override
+ public int getVoiceActivationState(int subId, String callingPackage) {
+ if (!canReadPhoneState(callingPackage, "getVoiceActivationStateForSubscriber")) {
+ return TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN;
+ }
+ final Phone phone = getPhone(subId);
+ if (phone != null) {
+ return phone.getVoiceActivationState();
+ } else {
+ return TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN;
+ }
+ }
+
+ /**
+ * Returns the data activation state of a given subId.
+ */
+ @Override
+ public int getDataActivationState(int subId, String callingPackage) {
+ if (!canReadPhoneState(callingPackage, "getDataActivationStateForSubscriber")) {
+ return TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN;
+ }
+ final Phone phone = getPhone(subId);
+ if (phone != null) {
+ return phone.getDataActivationState();
+ } else {
+ return TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN;
+ }
+ }
+
+ /**
* Returns the unread count of voicemails
*/
public int getVoiceMessageCount() {
@@ -2353,6 +2422,19 @@
return mPhone.getPcscfAddress(apnType);
}
+ /**
+ * Returns the {@link IImsServiceController} that corresponds to the given slot Id and IMS
+ * feature or {@link null} if the service is not available. If an ImsServiceController is
+ * available, the {@link IImsServiceFeatureListener} callback is registered as a listener for
+ * feature updates.
+ */
+ public IImsServiceController getImsServiceControllerAndListen(int slotId, int feature,
+ IImsServiceFeatureListener callback) {
+ enforceModifyPermission();
+ return PhoneFactory.getImsResolver().getImsServiceControllerAndListen(slotId, feature,
+ callback);
+ }
+
public void setImsRegistrationState(boolean registered) {
enforceModifyPermission();
mPhone.setImsRegistrationState(registered);
@@ -3393,4 +3475,33 @@
phone.setPolicyDataEnabled(enabled);
}
}
+
+ /**
+ * Get Client request stats
+ * @return List of Client Request Stats
+ * @hide
+ */
+ @Override
+ public List<ClientRequestStats> getClientRequestStats(String callingPackage, int subId) {
+ if (!canReadPhoneState(callingPackage, "getClientRequestStats")) {
+ return null;
+ }
+
+ Phone phone = getPhone(subId);
+ if (phone != null) {
+ return phone.getClientRequestStats();
+ }
+
+ return null;
+ }
+
+ private WorkSource getWorkSource(WorkSource workSource, int uid) {
+ if (workSource != null) {
+ return workSource;
+ }
+
+ String packageName = mPhone.getContext().getPackageManager().getNameForUid(uid);
+ workSource = new WorkSource(uid, packageName);
+ return workSource;
+ }
}
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 9f70349..6fdff14 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -86,9 +86,9 @@
static final String ADD_CALL_MODE_KEY = "add_call_mode";
// Return codes from placeCall()
- static final int CALL_STATUS_DIALED = 0; // The number was successfully dialed
- static final int CALL_STATUS_DIALED_MMI = 1; // The specified number was an MMI code
- static final int CALL_STATUS_FAILED = 2; // The call failed
+ public static final int CALL_STATUS_DIALED = 0; // The number was successfully dialed
+ public static final int CALL_STATUS_DIALED_MMI = 1; // The specified number was an MMI code
+ public static final int CALL_STATUS_FAILED = 2; // The call failed
// State of the Phone's audio modes
// Each state can move to the other states, but within the state only certain
diff --git a/src/com/android/phone/otasp/OtaspActivationService.java b/src/com/android/phone/otasp/OtaspActivationService.java
new file mode 100644
index 0000000..158925a
--- /dev/null
+++ b/src/com/android/phone/otasp/OtaspActivationService.java
@@ -0,0 +1,225 @@
+/*
+ * 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 com.android.phone.otasp;
+
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncResult;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.telephony.ServiceState;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+
+import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
+import com.android.phone.PhoneGlobals;
+import com.android.phone.PhoneUtils;
+
+import static com.android.phone.PhoneGlobals.getPhone;
+
+/**
+ * otasp activation service handles all logic related with OTASP call.
+ * OTASP is a CDMA-specific feature: OTA or OTASP == Over The Air service provisioning
+ * In practice, in a normal successful OTASP call, events come in as follows:
+ * - SPL_UNLOCKED within a couple of seconds after the call starts
+ * - PRL_DOWNLOADED and MDN_DOWNLOADED and COMMITTED within a span of 2 seconds
+ * - poll cdma subscription from RIL after COMMITTED
+ * - SIM reloading with provisioned MDN and MIN
+ */
+public class OtaspActivationService extends Service {
+ private static final String TAG = OtaspActivationService.class.getSimpleName();
+ private static final boolean DBG = true;
+ /* non-interactive otasp number */
+ private static final String OTASP_NUMBER = "*22899";
+
+ /**
+ * Otasp call follows with SIM reloading which might triggers a retry loop on activation
+ * failure. A max retry limit could help prevent retry loop.
+ */
+ private static final int OTASP_CALL_RETRIES_MAX = 3;
+ private static final int OTASP_CALL_RETRY_PERIOD_IN_MS = 3000;
+ private static int sOtaspCallRetries = 0;
+
+ /* events */
+ private static final int EVENT_CALL_STATE_CHANGED = 0;
+ private static final int EVENT_CDMA_OTASP_CALL_RETRY = 1;
+ private static final int EVENT_CDMA_PROVISION_STATUS_UPDATE = 2;
+ private static final int EVENT_SERVICE_STATE_CHANGED = 3;
+ private static final int EVENT_START_OTASP_CALL = 4;
+
+ /* use iccid to detect hot sim swap */
+ private static String sIccId = null;
+
+ private Phone mPhone;
+ /* committed flag indicates Otasp call succeed */
+ private boolean mIsOtaspCallCommitted = false;
+
+ @Override
+ public void onCreate() {
+ logd("otasp service onCreate");
+ mPhone = PhoneGlobals.getPhone();
+ if ((sIccId == null) || !sIccId.equals(mPhone.getIccSerialNumber())) {
+ // reset to allow activation retry on new sim
+ sIccId = mPhone.getIccSerialNumber();
+ sOtaspCallRetries = 0;
+ }
+ sOtaspCallRetries++;
+ logd("OTASP call tried " + sOtaspCallRetries + " times");
+ if (sOtaspCallRetries > OTASP_CALL_RETRIES_MAX) {
+ logd("OTASP call exceeds max retries => activation failed");
+ updateActivationState(this, false);
+ onComplete();
+ return;
+ }
+ mHandler.sendEmptyMessage(EVENT_START_OTASP_CALL);
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ return START_REDELIVER_INTENT;
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ private Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case EVENT_SERVICE_STATE_CHANGED:
+ logd("EVENT_SERVICE_STATE_CHANGED");
+ onStartOtaspCall();
+ break;
+ case EVENT_START_OTASP_CALL:
+ logd("EVENT_START_OTASP_CALL");
+ onStartOtaspCall();
+ break;
+ case EVENT_CALL_STATE_CHANGED:
+ logd("OTASP_CALL_STATE_CHANGED");
+ onOtaspCallStateChanged();
+ break;
+ case EVENT_CDMA_PROVISION_STATUS_UPDATE:
+ logd("OTASP_ACTIVATION_STATUS_UPDATE_EVENT");
+ onCdmaProvisionStatusUpdate((AsyncResult) msg.obj);
+ break;
+ case EVENT_CDMA_OTASP_CALL_RETRY:
+ logd("EVENT_CDMA_OTASP_CALL_RETRY");
+ onStartOtaspCall();
+ break;
+ default:
+ loge("invalid msg: " + msg.what + " not handled.");
+ }
+ }
+ };
+
+ /**
+ * Starts the OTASP call without any UI.
+ * platform only support background non-interactive otasp call, but users could still dial
+ * interactive OTASP number through dialer if carrier allows (some carrier will
+ * explicitly block any outgoing *288XX number).
+ */
+ private void onStartOtaspCall() {
+ unregisterAll();
+ if (mPhone.getServiceState().getState() != ServiceState.STATE_IN_SERVICE) {
+ loge("OTASP call failure, wait for network available.");
+ mPhone.registerForServiceStateChanged(mHandler, EVENT_SERVICE_STATE_CHANGED, null);
+ return;
+ }
+ // otasp call follows with CDMA OTA PROVISION STATUS update which signals activation result
+ mPhone.registerForCdmaOtaStatusChange(mHandler, EVENT_CDMA_PROVISION_STATUS_UPDATE, null);
+ mPhone.registerForPreciseCallStateChanged(mHandler, EVENT_CALL_STATE_CHANGED, null);
+ logd("startNonInteractiveOtasp: placing call to '" + OTASP_NUMBER + "'...");
+ int callStatus = PhoneUtils.placeCall(this,
+ getPhone(),
+ OTASP_NUMBER,
+ null, // contactRef
+ false); // isEmergencyCall
+ if (callStatus == PhoneUtils.CALL_STATUS_DIALED) {
+ if (DBG) logd(" ==> success return from placeCall(): callStatus = " + callStatus);
+ } else {
+ loge(" ==> failure return from placeCall(): callStatus = " + callStatus);
+ mHandler.sendEmptyMessageDelayed(EVENT_CDMA_OTASP_CALL_RETRY,
+ OTASP_CALL_RETRY_PERIOD_IN_MS);
+ }
+ }
+
+ /**
+ * register for cdma ota provision status
+ * see RIL_CDMA_OTA_ProvisionStatus in include/telephony/ril.h
+ */
+ private void onCdmaProvisionStatusUpdate(AsyncResult r) {
+ int[] otaStatus = (int[]) r.result;
+ logd("onCdmaProvisionStatusUpdate: " + otaStatus[0]);
+ if (Phone.CDMA_OTA_PROVISION_STATUS_COMMITTED == otaStatus[0]) {
+ mIsOtaspCallCommitted = true;
+ }
+ }
+
+ /**
+ * update activation state upon call disconnected.
+ * check the mIsOtaspCallCommitted bit, and if that's true it means that activation
+ * was successful.
+ */
+ private void onOtaspCallStateChanged() {
+ logd("onOtaspCallStateChanged: " + mPhone.getState());
+ if (mPhone.getState().equals(PhoneConstants.State.IDLE)) {
+ if (mIsOtaspCallCommitted) {
+ logd("Otasp activation succeed");
+ updateActivationState(this, true);
+ } else {
+ logd("Otasp activation failed");
+ updateActivationState(this, false);
+ }
+ onComplete();
+ }
+ }
+
+ private void onComplete() {
+ logd("otasp service onComplete");
+ unregisterAll();
+ stopSelf();
+ }
+
+ private void unregisterAll() {
+ mPhone.unregisterForCdmaOtaStatusChange(mHandler);
+ mPhone.unregisterForSubscriptionInfoReady(mHandler);
+ mPhone.unregisterForServiceStateChanged(mHandler);
+ mPhone.unregisterForPreciseCallStateChanged(mHandler);
+ mHandler.removeCallbacksAndMessages(null);
+ }
+
+ public static void updateActivationState(Context context, boolean success) {
+ final TelephonyManager mTelephonyMgr = TelephonyManager.from(context);
+ int state = (success) ? TelephonyManager.SIM_ACTIVATION_STATE_ACTIVATED :
+ TelephonyManager.SIM_ACTIVATION_STATE_DEACTIVATED;
+ int subId = SubscriptionManager.getDefaultSubscriptionId();
+ mTelephonyMgr.setVoiceActivationState(subId, state);
+ mTelephonyMgr.setDataActivationState(subId, state);
+ }
+
+ private static void logd(String s) {
+ android.util.Log.d(TAG, s);
+ }
+
+ private static void loge(String s) {
+ android.util.Log.e(TAG, s);
+ }
+}
diff --git a/src/com/android/phone/otasp/OtaspSimStateReceiver.java b/src/com/android/phone/otasp/OtaspSimStateReceiver.java
new file mode 100644
index 0000000..c0409ba
--- /dev/null
+++ b/src/com/android/phone/otasp/OtaspSimStateReceiver.java
@@ -0,0 +1,88 @@
+/*
+ * 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 com.android.phone.otasp;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.PersistableBundle;
+import android.telephony.CarrierConfigManager;
+import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.ServiceStateTracker;
+import com.android.phone.PhoneGlobals;
+
+public class OtaspSimStateReceiver extends BroadcastReceiver {
+ private static final String TAG = OtaspSimStateReceiver.class.getSimpleName();
+ private static final boolean DBG = true;
+ private Context mContext;
+
+ private PhoneStateListener mPhoneStateListener = new PhoneStateListener(){
+ @Override
+ public void onOtaspChanged(int otaspMode) {
+ logd("onOtaspChanged: otaspMode=" + otaspMode);
+ if (otaspMode == ServiceStateTracker.OTASP_NEEDED) {
+ logd("otasp activation required, start otaspActivationService");
+ mContext.startService(new Intent(mContext, OtaspActivationService.class));
+ } else if (otaspMode == ServiceStateTracker.OTASP_NOT_NEEDED) {
+ OtaspActivationService.updateActivationState(mContext, true);
+ }
+ }
+ };
+
+ /**
+ * check if OTA service provisioning activation is supported by the current carrier
+ * @return true if otasp activation is needed, false otherwise
+ */
+ private static boolean isCarrierSupported() {
+ final Phone phone = PhoneGlobals.getPhone();
+ final Context context = phone.getContext();
+ if (context != null) {
+ PersistableBundle b = null;
+ final CarrierConfigManager configManager = (CarrierConfigManager) context
+ .getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ if (configManager != null) {
+ b = configManager.getConfig();
+ }
+ if (b != null && b.getBoolean(
+ CarrierConfigManager.KEY_USE_OTASP_FOR_PROVISIONING_BOOL)) {
+ return true;
+ }
+ }
+ logd("otasp activation not needed: no supported carrier");
+ return false;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mContext = context;
+ if(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED.equals(intent.getAction())) {
+ if (DBG) logd("Received intent: " + intent.getAction());
+ if (PhoneGlobals.getPhone().getIccRecordsLoaded() && isCarrierSupported()) {
+ final TelephonyManager telephonyManager = TelephonyManager.from(context);
+ telephonyManager.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_OTASP_CHANGED);
+ }
+ }
+ }
+
+ private static void logd(String s) {
+ Log.d(TAG, s);
+ }
+}
+
diff --git a/src/com/android/phone/settings/fdn/FdnList.java b/src/com/android/phone/settings/fdn/FdnList.java
index 0174a82..61a8299 100644
--- a/src/com/android/phone/settings/fdn/FdnList.java
+++ b/src/com/android/phone/settings/fdn/FdnList.java
@@ -17,16 +17,26 @@
package com.android.phone.settings.fdn;
import android.app.ActionBar;
+import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
+import android.os.PersistableBundle;
+import android.telecom.PhoneAccount;
+import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionManager;
+import android.text.TextUtils;
+import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
+import android.widget.PopupMenu;
+import android.widget.PopupMenu.OnMenuItemClickListener;
import com.android.phone.ADNList;
+import com.android.phone.PhoneGlobals;
import com.android.phone.R;
import com.android.phone.SubscriptionInfoHelper;
@@ -35,9 +45,44 @@
* that allows a user to specify a limited set of phone numbers that the SIM can dial.
*/
public class FdnList extends ADNList {
+ private class SelectionPopupMenu extends PopupMenu {
+ private OnMenuItemClickListener mMenuItemListener = new OnMenuItemClickListener() {
+
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ if (item.getItemId() == MENU_EDIT) {
+ editSelected(position);
+ } else if (item.getItemId() == MENU_DELETE) {
+ deleteSelected(position);
+ } else if (item.getItemId() == MENU_DIAL) {
+ dialSelected(position);
+ }
+ return true;
+ }
+ };
+
+ private final int position;
+
+ public SelectionPopupMenu(Context context, View anchor, int position) {
+ super(context, anchor, Gravity.RIGHT);
+ this.position = position;
+ }
+
+ public void showPopUp() {
+ getMenu().add(0, MENU_EDIT, 0, getString(R.string.menu_edit));
+ getMenu().add(0, MENU_DELETE, 0, getString(R.string.menu_delete));
+ if (mFdnDialDirectlySupported) {
+ getMenu().add(0, MENU_DIAL, 0, getString(R.string.menu_dial));
+ }
+ setOnMenuItemClickListener(mMenuItemListener);
+ show();
+ }
+ }
+
private static final int MENU_ADD = 1;
private static final int MENU_EDIT = 2;
private static final int MENU_DELETE = 3;
+ private static final int MENU_DIAL = 4;
private static final String INTENT_EXTRA_NAME = "name";
private static final String INTENT_EXTRA_NUMBER = "number";
@@ -47,6 +92,9 @@
private SubscriptionInfoHelper mSubscriptionInfoHelper;
+ private boolean mFdnDialDirectlySupported = false;
+ private SelectionPopupMenu mPopup;
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -63,6 +111,20 @@
}
@Override
+ protected void onResume() {
+ super.onResume();
+ mFdnDialDirectlySupported = getFdnDialDirectlySupported();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ if (mPopup != null) {
+ mPopup.dismiss();
+ }
+ }
+
+ @Override
protected Uri resolveIntent() {
Intent intent = getIntent();
intent.setData(getContentUri(mSubscriptionInfoHelper));
@@ -82,6 +144,7 @@
.setIcon(android.R.drawable.ic_menu_edit);
menu.add(0, MENU_DELETE, 0, r.getString(R.string.menu_delete))
.setIcon(android.R.drawable.ic_menu_delete);
+ menu.add(0, MENU_DIAL, 0, r.getString(R.string.menu_dial));
return true;
}
@@ -93,6 +156,7 @@
menu.findItem(MENU_ADD).setVisible(true);
menu.findItem(MENU_EDIT).setVisible(hasSelection);
menu.findItem(MENU_DELETE).setVisible(hasSelection);
+ menu.findItem(MENU_DIAL).setVisible(hasSelection && mFdnDialDirectlySupported);
return true;
}
@@ -119,6 +183,10 @@
case MENU_DELETE:
deleteSelected();
return true;
+
+ case MENU_DIAL:
+ dialSelected();
+ return true;
}
return super.onOptionsItemSelected(item);
@@ -126,8 +194,8 @@
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
- // TODO: is this what we really want?
- editSelected(position);
+ mPopup = new SelectionPopupMenu(this, v, position);
+ mPopup.showPopUp();
}
private void addContact() {
@@ -162,7 +230,11 @@
}
private void deleteSelected() {
- if (mCursor.moveToPosition(getSelectedItemPosition())) {
+ deleteSelected(getSelectedItemPosition());
+ }
+
+ private void deleteSelected(int position) {
+ if (mCursor.moveToPosition(position)) {
String name = mCursor.getString(NAME_COLUMN);
String number = mCursor.getString(NUMBER_COLUMN);
@@ -173,6 +245,21 @@
}
}
+ private void dialSelected() {
+ dialSelected(getSelectedItemPosition());
+ }
+
+ private void dialSelected(int position) {
+ if (mCursor.moveToPosition(position)) {
+ String number = mCursor.getString(NUMBER_COLUMN);
+ if (!TextUtils.isEmpty(number)) {
+ Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
+ final Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, uri);
+ startActivity(intent);
+ }
+ }
+ }
+
/**
* Returns the uri for updating the ICC FDN entry, taking into account the subscription id.
*/
@@ -182,4 +269,18 @@
: FDN_CONTENT_URI;
}
+ /*
+ * Get the config of whether dialing FDN number from FDN list directly is supported
+ * from carrier config manager.
+ *
+ * @return boolean value of the config
+ */
+ private boolean getFdnDialDirectlySupported() {
+ int subId = mSubscriptionInfoHelper.hasSubId()
+ ? mSubscriptionInfoHelper.getSubId()
+ : SubscriptionManager.getDefaultSubscriptionId();
+ PersistableBundle carrierConfig =
+ PhoneGlobals.getInstance().getCarrierConfigForSubId(subId);
+ return carrierConfig.getBoolean(CarrierConfigManager.KEY_SUPPORT_DIRECT_FDN_DIALING_BOOL);
+ }
}
diff --git a/src/com/android/services/telephony/CdmaConnection.java b/src/com/android/services/telephony/CdmaConnection.java
index 8020996..29ccc6c 100644
--- a/src/com/android/services/telephony/CdmaConnection.java
+++ b/src/com/android/services/telephony/CdmaConnection.java
@@ -184,7 +184,7 @@
}
@Override
- public void performConference(TelephonyConnection otherConnection) {
+ public void performConference(android.telecom.Connection otherConnection) {
if (isImsConnection()) {
super.performConference(otherConnection);
} else {
diff --git a/src/com/android/services/telephony/DisconnectCauseUtil.java b/src/com/android/services/telephony/DisconnectCauseUtil.java
index 534f510..c356899 100644
--- a/src/com/android/services/telephony/DisconnectCauseUtil.java
+++ b/src/com/android/services/telephony/DisconnectCauseUtil.java
@@ -130,6 +130,7 @@
case android.telephony.DisconnectCause.DATA_LIMIT_REACHED:
case android.telephony.DisconnectCause.DIALED_ON_WRONG_SLOT:
case android.telephony.DisconnectCause.IMEI_NOT_ACCEPTED:
+ case android.telephony.DisconnectCause.WIFI_LOST:
return DisconnectCause.ERROR;
case android.telephony.DisconnectCause.DIALED_MMI:
@@ -386,6 +387,10 @@
resourceId = R.string.callFailed_imei_not_accepted;
break;
+ case android.telephony.DisconnectCause.WIFI_LOST:
+ resourceId = R.string.callFailed_wifi_lost;
+ break;
+
default:
break;
}
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index e33c351..6c4fadc 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -330,6 +330,10 @@
Connection.CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO,
can(capabilities, Connection.CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO));
+ conferenceCapabilities = changeBitmask(conferenceCapabilities,
+ Connection.CAPABILITY_CAN_PAUSE_VIDEO,
+ mConferenceHost.getVideoPauseSupported() && isVideoCapable());
+
return conferenceCapabilities;
}
@@ -439,7 +443,7 @@
@Override
public void onMerge(android.telecom.Connection connection) {
try {
- Phone phone = ((TelephonyConnection) connection).getPhone();
+ Phone phone = mConferenceHost.getPhone();
if (phone != null) {
phone.conference();
}
@@ -940,6 +944,16 @@
}
}
+ /**
+ * Determines if the host of this conference is capable of video calling.
+ * @return {@code true} if video capable, {@code false} otherwise.
+ */
+ private boolean isVideoCapable() {
+ int capabilities = mConferenceHost.getConnectionCapabilities();
+ return can(capabilities, Connection.CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)
+ && can(capabilities, Connection.CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL);
+ }
+
private void updateStatusHints() {
if (mConferenceHost == null) {
setStatusHints(null);
diff --git a/src/com/android/services/telephony/ImsConferenceController.java b/src/com/android/services/telephony/ImsConferenceController.java
index 6669482..4df6444 100644
--- a/src/com/android/services/telephony/ImsConferenceController.java
+++ b/src/com/android/services/telephony/ImsConferenceController.java
@@ -187,6 +187,7 @@
Log.v(this, "recalculateConferenceable : %d", mTelephonyConnections.size());
HashSet<Conferenceable> conferenceableSet = new HashSet<>(mTelephonyConnections.size() +
mImsConferences.size());
+ HashSet<Conferenceable> conferenceParticipantsSet = new HashSet<>();
// Loop through and collect all calls which are active or holding
for (TelephonyConnection connection : mTelephonyConnections) {
@@ -240,6 +241,7 @@
case Connection.STATE_ACTIVE:
//fall through
case Connection.STATE_HOLDING:
+ conferenceParticipantsSet.addAll(conference.getConnections());
conferenceableSet.add(conference);
continue;
default:
@@ -256,6 +258,16 @@
.stream()
.filter(conferenceable -> c != conferenceable)
.collect(Collectors.toList());
+ // TODO: Remove this once RemoteConnection#setConferenceableConnections is fixed.
+ // Add all conference participant connections as conferenceable with a standalone
+ // Connection. We need to do this to ensure that RemoteConnections work properly.
+ // At the current time, a RemoteConnection will not be conferenceable with a
+ // Conference, so we need to add its children to ensure the user can merge the call
+ // into the conference.
+ // We should add support for RemoteConnection#setConferenceables, which accepts a
+ // list of remote conferences and connections in the future.
+ conferenceables.addAll(conferenceParticipantsSet);
+
((Connection) c).setConferenceables(conferenceables);
} else if (c instanceof Conference) {
// Remove all conferences from the set, since we can not conference a conference
@@ -331,6 +343,7 @@
// This is necessary since the Connection Service does not support removing a connection
// from Telecom. Instead we create a new instance and remove the old one from telecom.
TelephonyConnection conferenceHostConnection = connection.cloneConnection();
+ conferenceHostConnection.setVideoPauseSupported(connection.getVideoPauseSupported());
PhoneAccountHandle phoneAccountHandle = null;
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 061a41e..5ae1a26 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -683,7 +683,7 @@
}
}
- public void performConference(TelephonyConnection otherConnection) {
+ public void performConference(Connection otherConnection) {
Log.d(this, "performConference - %s", this);
if (getPhone() != null) {
try {
@@ -885,7 +885,7 @@
String[] filteredCnapNames = null;
if (carrierConfig != null) {
filteredCnapNames = carrierConfig.getStringArray(
- CarrierConfigManager.FILTERED_CNAP_NAMES_STRING_ARRAY);
+ CarrierConfigManager.KEY_FILTERED_CNAP_NAMES_STRING_ARRAY);
}
if (filteredCnapNames != null) {
long cnapNameMatches = Arrays.asList(filteredCnapNames)
@@ -1549,6 +1549,14 @@
}
/**
+ * @return {@code true} if this connection supports pausing the outgoing video using the
+ * {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState.
+ */
+ public boolean getVideoPauseSupported() {
+ return mIsVideoPauseSupported;
+ }
+
+ /**
* Sets whether this connection supports conference calling.
* @param isConferenceSupported {@code true} if conference calling is supported by this
* connection, {@code false} otherwise.
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 77a7cfb..279f087 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -617,14 +617,35 @@
}
}
+ /**
+ * Conferences two connections.
+ *
+ * Note: The {@link android.telecom.RemoteConnection#setConferenceableConnections(List)} API has
+ * a limitation in that it can only specify conferenceables which are instances of
+ * {@link android.telecom.RemoteConnection}. In the case of an {@link ImsConference}, the
+ * regular {@link Connection#setConferenceables(List)} API properly handles being able to merge
+ * a {@link Conference} and a {@link Connection}. As a result when, merging a
+ * {@link android.telecom.RemoteConnection} into a {@link android.telecom.RemoteConference}
+ * require merging a {@link ConferenceParticipantConnection} which is a child of the
+ * {@link Conference} with a {@link TelephonyConnection}. The
+ * {@link ConferenceParticipantConnection} class does not have the capability to initiate a
+ * conference merge, so we need to call
+ * {@link TelephonyConnection#performConference(Connection)} on either {@code connection1} or
+ * {@code connection2}, one of which is an instance of {@link TelephonyConnection}.
+ *
+ * @param connection1 A connection to merge into a conference call.
+ * @param connection2 A connection to merge into a conference call.
+ */
@Override
public void onConference(Connection connection1, Connection connection2) {
- if (connection1 instanceof TelephonyConnection &&
- connection2 instanceof TelephonyConnection) {
- ((TelephonyConnection) connection1).performConference(
- (TelephonyConnection) connection2);
+ if (connection1 instanceof TelephonyConnection) {
+ ((TelephonyConnection) connection1).performConference(connection2);
+ } else if (connection2 instanceof TelephonyConnection) {
+ ((TelephonyConnection) connection2).performConference(connection1);
+ } else {
+ Log.w(this, "onConference - cannot merge connections " +
+ "Connection1: %s, Connection2: %2", connection1, connection2);
}
-
}
private boolean isRadioOn() {
diff --git a/src/com/android/services/telephony/activation/Activator.java b/src/com/android/services/telephony/activation/Activator.java
deleted file mode 100644
index 7dee5b3..0000000
--- a/src/com/android/services/telephony/activation/Activator.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 11ba726..0000000
--- a/src/com/android/services/telephony/activation/OtaspActivator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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
deleted file mode 100644
index ae11a3f..0000000
--- a/src/com/android/services/telephony/activation/SimActivationActivity.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.Activity;
-import android.app.PendingIntent;
-import android.app.PendingIntent.CanceledException;
-import android.content.Intent;
-import android.os.Bundle;
-import android.telephony.TelephonyManager;
-
-import com.android.phone.PhoneGlobals;
-import com.android.services.telephony.Log;
-
-/**
- * Invisible activity that handles the android.intent.action.SIM_ACTIVATION_REQUEST intent.
- * This activity is protected by the android.permission.PERFORM_SIM_ACTIVATION permission.
- */
-public class SimActivationActivity extends Activity {
- @Override
- protected void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- Log.i(this, "onCreate");
-
- Intent intent = getIntent();
- if (Intent.ACTION_SIM_ACTIVATION_REQUEST.equals(intent.getAction())) {
- Log.i(this, "Activation requested " + intent);
-
- runActivation(intent);
- }
- finish();
- }
-
- private void runActivation(Intent intent) {
- final PendingIntent response =
- intent.getParcelableExtra(Intent.EXTRA_SIM_ACTIVATION_RESPONSE);
-
- Log.i(this, "Running activation w/ response " + response);
-
- 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_IN_PROGRESS);
- }
-}
diff --git a/src/com/android/services/telephony/activation/SimActivationManager.java b/src/com/android/services/telephony/activation/SimActivationManager.java
deleted file mode 100644
index ce9e508..0000000
--- a/src/com/android/services/telephony/activation/SimActivationManager.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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
- }
- };
- }
-}
diff --git a/tests/Android.mk b/tests/Android.mk
index 59cba42..66df1a8 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -25,12 +25,13 @@
LOCAL_MODULE_TAGS := tests
-LOCAL_JAVA_LIBRARIES := telephony-common android-support-test
+LOCAL_JAVA_LIBRARIES := telephony-common
LOCAL_INSTRUMENTATION_FOR := TeleService
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-test \
- mockito-target
+ mockito-target \
+ legacy-android-test
include $(BUILD_PACKAGE)
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index cae4c1b..7962738 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -19,7 +19,6 @@
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.PERFORM_CDMA_PROVISIONING" />
- <uses-permission android:name="android.permission.PERFORM_SIM_ACTIVATION" />
<application android:label="@string/app_name">
<uses-library android:name="android.test.runner" />
diff --git a/tests/src/com/android/services/telephony/activation/ResponseReceiver.java b/tests/src/com/android/services/telephony/activation/ResponseReceiver.java
deleted file mode 100644
index 33e7f00..0000000
--- a/tests/src/com/android/services/telephony/activation/ResponseReceiver.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-
-import com.android.services.telephony.Log;
-
-public class ResponseReceiver extends BroadcastReceiver {
- volatile public static boolean responseReceived = false;
- public static final String ACTION_ACTIVATION_RESPONSE =
- "com.android.services.telephony.ACTIVATION_RESPONSE";
-
- private final Object mLock;
- private Context mContext;
-
- ResponseReceiver(Object lock) {
- mLock = lock;
- }
-
- /** ${inheritDoc} */
- @Override
- public void onReceive(Context context, Intent intent) {
- if (!ACTION_ACTIVATION_RESPONSE.equals(intent.getAction())) {
- Log.e(this, null, "Unexpected intent: " + intent.getAction());
- return;
- }
-
- responseReceived = true;
- Log.i(this, "received intent");
-
- if (mLock != null) {
- synchronized(mLock) {
- Log.i(this, "notifying");
- mLock.notify();
- }
- }
- }
-
- void register(Context context) {
- context.registerReceiver(this, new IntentFilter(ACTION_ACTIVATION_RESPONSE));
- mContext = context;
- }
-
- void unregister() {
- mContext.unregisterReceiver(this);
- }
-}
diff --git a/tests/src/com/android/services/telephony/activation/SimActivationTest.java b/tests/src/com/android/services/telephony/activation/SimActivationTest.java
deleted file mode 100644
index f6060dc..0000000
--- a/tests/src/com/android/services/telephony/activation/SimActivationTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.content.Context;
-import android.content.Intent;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import com.android.services.telephony.Log;
-
-public class SimActivationTest extends AndroidTestCase {
-
- private static Object mActivationLock = new Object();
- private ResponseReceiver mResponseReceiver;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- mResponseReceiver = new ResponseReceiver(mActivationLock);
- mResponseReceiver.register(context());
- }
-
- /** ${inheritDoc} */
- @Override
- protected void tearDown() throws Exception {
- mResponseReceiver.unregister();
- super.tearDown();
- }
-
- @SmallTest
- public void testSimActivationResponse() throws Exception {
- Log.i(this, "Running activation test");
-
- Intent responseIntent = new Intent(ResponseReceiver.ACTION_ACTIVATION_RESPONSE);
- responseIntent.setPackage(context().getPackageName());
- PendingIntent pendingResponse = PendingIntent.getBroadcast(
- context(), 0, responseIntent, 0);
-
- Intent intent = new Intent(Intent.ACTION_SIM_ACTIVATION_REQUEST);
- intent.putExtra(Intent.EXTRA_SIM_ACTIVATION_RESPONSE, pendingResponse);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- Log.i(this, "sent intent");
- context().startActivity(intent);
- synchronized (mActivationLock) {
- Log.i(this, "waiting ");
- mActivationLock.wait(5000);
- Log.i(this, "unwaiting");
- }
- assertTrue(ResponseReceiver.responseReceived);
- }
-
- private Context context() {
- return getContext();
- }
-}