Merge "Perform syncs with the voicemail server through data connection only." into mnc-dev
diff --git a/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java b/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java
index b9ee69d..0a08c61 100644
--- a/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java
+++ b/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java
@@ -113,7 +113,7 @@
}
void setup(Context context) {
- startSipProfilesAsync(context, (String) null);
+ startSipProfilesAsync(context, (String) null, false);
// TODO: remove orphaned SIP Accounts
}
@@ -124,9 +124,10 @@
*
* @param context The context.
* @param sipProfileName The name of the {@link SipProfile} to start, or {@code null} for all.
+ * @param enableProfile Sip account should be enabled
*/
- void startSipService(Context context, String sipProfileName) {
- startSipProfilesAsync(context, sipProfileName);
+ void startSipService(Context context, String sipProfileName, boolean enableProfile) {
+ startSipProfilesAsync(context, sipProfileName, enableProfile);
}
/**
@@ -175,7 +176,7 @@
* @param context The context.
*/
public void restartSipService(Context context) {
- startSipProfiles(context, null);
+ startSipProfiles(context, null, false);
}
/**
@@ -185,14 +186,16 @@
*
* @param context The context.
* @param sipProfileName Name of the SIP profile.
+ * @param enableProfile Sip account should be enabled.
*/
- private void startSipProfilesAsync(final Context context, final String sipProfileName) {
+ private void startSipProfilesAsync(
+ final Context context, final String sipProfileName, final boolean enableProfile) {
if (VERBOSE) log("startSipProfiles, start auto registration");
new Thread(new Runnable() {
@Override
public void run() {
- startSipProfiles(context, sipProfileName);
+ startSipProfiles(context, sipProfileName, enableProfile);
}}
).start();
}
@@ -204,8 +207,9 @@
*
* @param context The context.
* @param sipProfileName A specific SIP profile Name to start, or {@code null} to start all.
+ * @param enableProfile Sip account should be enabled.
*/
- private void startSipProfiles(Context context, String sipProfileName) {
+ private void startSipProfiles(Context context, String sipProfileName, boolean enableProfile) {
final SipSharedPreferences sipSharedPreferences = new SipSharedPreferences(context);
boolean isReceivingCalls = sipSharedPreferences.isReceivingCallsEnabled();
String primaryProfile = sipSharedPreferences.getPrimaryAccount();
@@ -220,6 +224,9 @@
if (sipProfileName == null || sipProfileName.equals(profile.getProfileName())) {
PhoneAccount phoneAccount = SipUtil.createPhoneAccount(context, profile);
telecomManager.registerPhoneAccount(phoneAccount);
+ if (enableProfile) {
+ telecomManager.enablePhoneAccount(phoneAccount.getAccountHandle(), true);
+ }
startSipServiceForProfile(profile, sipManager, context, isReceivingCalls);
}
}
diff --git a/sip/src/com/android/services/telephony/sip/SipEditor.java b/sip/src/com/android/services/telephony/sip/SipEditor.java
index d6f862a..6304220 100644
--- a/sip/src/com/android/services/telephony/sip/SipEditor.java
+++ b/sip/src/com/android/services/telephony/sip/SipEditor.java
@@ -244,12 +244,13 @@
* {@link android.telecom.PhoneAccount}.
*
* @param p The {@link SipProfile} to register.
+ * @param enableProfile {@code true} if profile should be enabled, too.
* @throws IOException Exception resulting from profile save.
*/
- private void saveAndRegisterProfile(SipProfile p) throws IOException {
+ private void saveAndRegisterProfile(SipProfile p, boolean enableProfile) throws IOException {
if (p == null) return;
mProfileDb.saveProfile(p);
- mSipAccountRegistry.startSipService(this, p.getProfileName());
+ mSipAccountRegistry.startSipService(this, p.getProfileName(), enableProfile);
}
/**
@@ -372,7 +373,8 @@
public void run() {
try {
deleteAndUnregisterProfile(oldProfile);
- saveAndRegisterProfile(newProfile);
+ boolean autoEnableNewProfile = oldProfile == null;
+ saveAndRegisterProfile(newProfile, autoEnableNewProfile);
finish();
} catch (Exception e) {
log("replaceProfile, can not save/register new SipProfile, exception: " + e);
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index d918f7d..0c34c5f 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -40,9 +40,9 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
-import android.service.carrier.CarrierConfigService;
import android.service.carrier.CarrierIdentifier;
-import android.service.carrier.ICarrierConfigService;
+import android.service.carrier.CarrierService;
+import android.service.carrier.ICarrierService;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -89,7 +89,7 @@
// Carrier configs from privileged carrier config app, indexed by phoneID.
private PersistableBundle[] mConfigFromCarrierApp;
// Service connection for binding to config app.
- private ConfigServiceConnection[] mServiceConnection;
+ private CarrierServiceConnection[] mServiceConnection;
// Broadcast receiver for SIM and pkg intents, register intent filter in constructor.
private final BroadcastReceiver mReceiver = new ConfigLoaderBroadcastReceiver();
@@ -133,7 +133,7 @@
int phoneId = msg.arg1;
log("mHandler: " + msg.what + " phoneId: " + phoneId);
CarrierIdentifier carrierId;
- ConfigServiceConnection conn;
+ CarrierServiceConnection conn;
PersistableBundle config;
switch (msg.what) {
case EVENT_CLEAR_CONFIG:
@@ -158,16 +158,16 @@
case EVENT_CONNECTED_TO_DEFAULT:
carrierId = getCarrierIdForPhoneId(phoneId);
- conn = (ConfigServiceConnection) msg.obj;
+ conn = (CarrierServiceConnection) msg.obj;
// If new service connection has been created, unbind.
if (mServiceConnection[phoneId] != conn || conn.service == null) {
mContext.unbindService(conn);
break;
}
try {
- ICarrierConfigService configService = ICarrierConfigService.Stub
+ ICarrierService carrierService = ICarrierService.Stub
.asInterface(conn.service);
- config = configService.getCarrierConfig(carrierId);
+ config = carrierService.getCarrierConfig(carrierId);
mConfigFromDefaultApp[phoneId] = config;
sendMessage(obtainMessage(EVENT_LOADED_FROM_DEFAULT, phoneId, -1));
} catch (RemoteException ex) {
@@ -183,7 +183,7 @@
}
List<String> carrierPackageNames = TelephonyManager.from(mContext)
.getCarrierPackageNamesForIntentAndPhone(
- new Intent(CarrierConfigService.SERVICE_INTERFACE), phoneId);
+ new Intent(CarrierService.CONFIG_SERVICE_INTERFACE), phoneId);
log("Found carrier config app: " + carrierPackageNames);
if (carrierPackageNames != null && carrierPackageNames.size() > 0) {
if (!bindToConfigPackage(carrierPackageNames.get(0),
@@ -197,7 +197,7 @@
case EVENT_CONNECTED_TO_CARRIER:
carrierId = getCarrierIdForPhoneId(phoneId);
- conn = (ConfigServiceConnection) msg.obj;
+ conn = (CarrierServiceConnection) msg.obj;
// If new service connection has been created, unbind.
if (mServiceConnection[phoneId] != conn ||
conn.service == null) {
@@ -205,9 +205,9 @@
break;
}
try {
- ICarrierConfigService configService = ICarrierConfigService.Stub
+ ICarrierService carrierService = ICarrierService.Stub
.asInterface(conn.service);
- config = configService.getCarrierConfig(carrierId);
+ config = carrierService.getCarrierConfig(carrierId);
mConfigFromCarrierApp[phoneId] = config;
sendMessage(obtainMessage(EVENT_LOADED_FROM_CARRIER, phoneId, -1));
} catch (RemoteException ex) {
@@ -244,7 +244,7 @@
int numPhones = TelephonyManager.from(context).getPhoneCount();
mConfigFromDefaultApp = new PersistableBundle[numPhones];
mConfigFromCarrierApp = new PersistableBundle[numPhones];
- mServiceConnection = new ConfigServiceConnection[numPhones];
+ mServiceConnection = new CarrierServiceConnection[numPhones];
// Make this service available through ServiceManager.
ServiceManager.addService(Context.CARRIER_CONFIG_SERVICE, this);
log("CarrierConfigLoader has started");
@@ -278,11 +278,11 @@
/** Binds to the default or carrier config app. */
private boolean bindToConfigPackage(String pkgName, int phoneId, int eventId) {
log("Binding to " + pkgName + " for phone " + phoneId);
- Intent carrierConfigService = new Intent(CarrierConfigService.SERVICE_INTERFACE);
- carrierConfigService.setPackage(pkgName);
- mServiceConnection[phoneId] = new ConfigServiceConnection(phoneId, eventId);
+ Intent carrierService = new Intent(CarrierService.CONFIG_SERVICE_INTERFACE);
+ carrierService.setPackage(pkgName);
+ mServiceConnection[phoneId] = new CarrierServiceConnection(phoneId, eventId);
try {
- return mContext.bindService(carrierConfigService, mServiceConnection[phoneId],
+ return mContext.bindService(carrierService, mServiceConnection[phoneId],
Context.BIND_AUTO_CREATE);
} catch (SecurityException ex) {
return false;
@@ -490,12 +490,12 @@
}
}
- private class ConfigServiceConnection implements ServiceConnection {
+ private class CarrierServiceConnection implements ServiceConnection {
int phoneId;
int eventId;
IBinder service;
- public ConfigServiceConnection(int phoneId, int eventId) {
+ public CarrierServiceConnection(int phoneId, int eventId) {
this.phoneId = phoneId;
this.eventId = eventId;
}