Merge "Fail gracefully when IMS is not available" am: dee32b721c
am: c787160c91
Change-Id: I3440b2f2b43eb3d1327e5be5bd5108e23f166568
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 2f0b8e2..547879e 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -140,6 +140,7 @@
import com.android.internal.telephony.TelephonyPermissions;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.euicc.EuiccConnector;
+import com.android.internal.telephony.ims.ImsResolver;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.uicc.IccIoResult;
import com.android.internal.telephony.uicc.IccUtils;
@@ -4029,7 +4030,12 @@
final long identity = Binder.clearCallingIdentity();
try {
- PhoneFactory.getImsResolver().enableIms(slotId);
+ ImsResolver resolver = PhoneFactory.getImsResolver();
+ if (resolver == null) {
+ // may happen if the device does not support IMS.
+ return;
+ }
+ resolver.enableIms(slotId);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -4044,7 +4050,12 @@
final long identity = Binder.clearCallingIdentity();
try {
- PhoneFactory.getImsResolver().disableIms(slotId);
+ ImsResolver resolver = PhoneFactory.getImsResolver();
+ if (resolver == null) {
+ // may happen if the device does not support IMS.
+ return;
+ }
+ resolver.disableIms(slotId);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -4061,7 +4072,12 @@
final long identity = Binder.clearCallingIdentity();
try {
- return PhoneFactory.getImsResolver().getMmTelFeatureAndListen(slotId, callback);
+ ImsResolver resolver = PhoneFactory.getImsResolver();
+ if (resolver == null) {
+ // may happen if the device does not support IMS.
+ return null;
+ }
+ return resolver.getMmTelFeatureAndListen(slotId, callback);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -4078,7 +4094,12 @@
final long identity = Binder.clearCallingIdentity();
try {
- return PhoneFactory.getImsResolver().getRcsFeatureAndListen(slotId, callback);
+ ImsResolver resolver = PhoneFactory.getImsResolver();
+ if (resolver == null) {
+ // may happen if the device does not support IMS.
+ return null;
+ }
+ return resolver.getRcsFeatureAndListen(slotId, callback);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -4086,14 +4107,19 @@
/**
* Returns the {@link IImsRegistration} structure associated with the slotId and feature
- * specified.
+ * specified or null if IMS is not supported on the slot specified.
*/
public IImsRegistration getImsRegistration(int slotId, int feature) throws RemoteException {
enforceModifyPermission();
final long identity = Binder.clearCallingIdentity();
try {
- return PhoneFactory.getImsResolver().getImsRegistration(slotId, feature);
+ ImsResolver resolver = PhoneFactory.getImsResolver();
+ if (resolver == null) {
+ // may happen if the device does not support IMS.
+ return null;
+ }
+ return resolver.getImsRegistration(slotId, feature);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -4101,14 +4127,19 @@
/**
* Returns the {@link IImsConfig} structure associated with the slotId and feature
- * specified.
+ * specified or null if IMS is not supported on the slot specified.
*/
public IImsConfig getImsConfig(int slotId, int feature) throws RemoteException {
enforceModifyPermission();
final long identity = Binder.clearCallingIdentity();
try {
- return PhoneFactory.getImsResolver().getImsConfig(slotId, feature);
+ ImsResolver resolver = PhoneFactory.getImsResolver();
+ if (resolver == null) {
+ // may happen if the device does not support IMS.
+ return null;
+ }
+ return resolver.getImsConfig(slotId, feature);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -4133,8 +4164,13 @@
final long identity = Binder.clearCallingIdentity();
try {
- return PhoneFactory.getImsResolver().overrideImsServiceConfiguration(slotId,
- isCarrierImsService, packageName);
+ ImsResolver resolver = PhoneFactory.getImsResolver();
+ if (resolver == null) {
+ // may happen if the device does not support IMS.
+ return false;
+ }
+ return resolver.overrideImsServiceConfiguration(slotId, isCarrierImsService,
+ packageName);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -4156,8 +4192,12 @@
final long identity = Binder.clearCallingIdentity();
try {
- return PhoneFactory.getImsResolver().getImsServiceConfiguration(slotId,
- isCarrierImsService);
+ ImsResolver resolver = PhoneFactory.getImsResolver();
+ if (resolver == null) {
+ // may happen if the device does not support IMS.
+ return "";
+ }
+ return resolver.getImsServiceConfiguration(slotId, isCarrierImsService);
} finally {
Binder.restoreCallingIdentity(identity);
}
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index fce4dfe..d6c1da6 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -21,6 +21,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.graphics.Bitmap;
@@ -115,7 +116,10 @@
}
try {
- mMmTelManager = ImsMmTelManager.createForSubscriptionId(getSubId());
+ if (mPhone.getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_TELEPHONY_IMS)) {
+ mMmTelManager = ImsMmTelManager.createForSubscriptionId(getSubId());
+ }
} catch (IllegalArgumentException e) {
Log.i(this, "Not registering MmTel capabilities listener because the subid '"
+ getSubId() + "' is invalid: " + e.getMessage());