aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Ebinger <breadley@google.com>2019-01-23 15:02:48 -0800
committerBrad Ebinger <breadley@google.com>2019-03-14 23:05:59 +0000
commitaa43f57812772a8daa97611591c64116158b8ad0 (patch)
tree67aee07af7613807239786961bf74e12d8ba5956
parentf143b1a2d67669fd2f85a8820e8c3e21d34b3869 (diff)
downloadims-aa43f57812772a8daa97611591c64116158b8ad0.tar.gz
Only allow ImsManager to work with FEATURE_TELEPHONY_IMS
Only allow ImsManager to set up resources when FEATURE_TELEPHONY_IMS is defined. Otherwise, do not spend resouces connecting or retrying infinitely, since IMS is not available. Bug: 118823723 Test: atest FrameworksTelephonyTests Merged-In: Idebf0add06314f4fe1aaf730688a327eecc2a36d Change-Id: Idebf0add06314f4fe1aaf730688a327eecc2a36d
-rw-r--r--src/java/com/android/ims/ImsManager.java16
-rw-r--r--src/java/com/android/ims/MmTelFeatureConnection.java24
2 files changed, 30 insertions, 10 deletions
diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java
index 3e8a32e2..cad82836 100644
--- a/src/java/com/android/ims/ImsManager.java
+++ b/src/java/com/android/ims/ImsManager.java
@@ -19,6 +19,7 @@ package com.android.ims;
import android.annotation.Nullable;
import android.app.PendingIntent;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerExecutor;
@@ -308,8 +309,14 @@ public class ImsManager {
* Start the creation of a connection to the underlying ImsService implementation. When the
* service is connected, {@link Listener#connectionReady(ImsManager)} will be called with
* an active ImsManager instance.
+ *
+ * If this device does not support an ImsStack (i.e. doesn't support
+ * {@link PackageManager#FEATURE_TELEPHONY_IMS} feature), this method will do nothing.
*/
public void connect() {
+ if (!ImsManager.isImsSupportedOnDevice(mContext)) {
+ return;
+ }
mRetryCount = 0;
// Send a message to connect to the Ims Service and open a connection through
// getImsService().
@@ -448,6 +455,10 @@ public class ImsManager {
}
}
+ public static boolean isImsSupportedOnDevice(Context context) {
+ return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS);
+ }
+
/**
* Returns the user configuration of Enhanced 4G LTE Mode setting.
*
@@ -2369,6 +2380,10 @@ public class ImsManager {
*/
private void checkAndThrowExceptionIfServiceUnavailable()
throws ImsException {
+ if (!isImsSupportedOnDevice(mContext)) {
+ throw new ImsException("IMS not supported on device.",
+ ImsReasonInfo.CODE_LOCAL_IMS_NOT_SUPPORTED_ON_DEVICE);
+ }
if (mMmTelFeatureConnection == null || !mMmTelFeatureConnection.isBinderAlive()) {
createImsService();
@@ -2758,6 +2773,7 @@ public class ImsManager {
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("ImsManager:");
+ pw.println(" device supports IMS = " + isImsSupportedOnDevice(mContext));
pw.println(" mPhoneId = " + mPhoneId);
pw.println(" mConfigUpdated = " + mConfigUpdated);
pw.println(" mImsServiceProxy = " + mMmTelFeatureConnection);
diff --git a/src/java/com/android/ims/MmTelFeatureConnection.java b/src/java/com/android/ims/MmTelFeatureConnection.java
index 4e3bb55b..50dc91ed 100644
--- a/src/java/com/android/ims/MmTelFeatureConnection.java
+++ b/src/java/com/android/ims/MmTelFeatureConnection.java
@@ -16,6 +16,7 @@
package com.android.ims;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.os.Handler;
@@ -297,7 +298,7 @@ public class MmTelFeatureConnection {
IImsRegistration imsRegistration = getRegistration();
if (imsRegistration != null) {
try {
- getRegistration().addRegistrationCallback(localCallback);
+ imsRegistration.addRegistrationCallback(localCallback);
} catch (RemoteException e) {
throw new IllegalStateException("ImsRegistrationCallbackAdapter: MmTelFeature"
+ " binder is dead.");
@@ -314,7 +315,7 @@ public class MmTelFeatureConnection {
IImsRegistration imsRegistration = getRegistration();
if (imsRegistration != null) {
try {
- getRegistration().removeRegistrationCallback(localCallback);
+ imsRegistration.removeRegistrationCallback(localCallback);
} catch (RemoteException e) {
Log.w(TAG, "ImsRegistrationCallbackAdapter - unregisterCallback: couldn't"
+ " remove registration callback");
@@ -429,6 +430,7 @@ public class MmTelFeatureConnection {
private final Object mLock = new Object();
// Updated by IImsServiceFeatureCallback when FEATURE_EMERGENCY_MMTEL is sent.
private boolean mSupportsEmergencyCalling = false;
+ private static boolean sImsSupportedOnDevice = true;
// Cache the Registration and Config interfaces as long as the MmTel feature is connected. If
// it becomes disconnected, invalidate.
@@ -451,8 +453,13 @@ public class MmTelFeatureConnection {
private final CapabilityCallbackManager mCapabilityCallbackManager;
private final ProvisioningCallbackManager mProvisioningCallbackManager;
- public static MmTelFeatureConnection create(Context context , int slotId) {
+ public static @NonNull MmTelFeatureConnection create(Context context , int slotId) {
MmTelFeatureConnection serviceProxy = new MmTelFeatureConnection(context, slotId);
+ if (!ImsManager.isImsSupportedOnDevice(context)) {
+ // Return empty service proxy in the case that IMS is not supported.
+ sImsSupportedOnDevice = false;
+ return serviceProxy;
+ }
TelephonyManager tm = getTelephonyManager(context);
if (tm == null) {
@@ -946,7 +953,10 @@ public class MmTelFeatureConnection {
return mIsAvailable && mBinder != null && mBinder.isBinderAlive();
}
- protected void checkServiceIsReady() throws RemoteException {
+ private void checkServiceIsReady() throws RemoteException {
+ if (!sImsSupportedOnDevice) {
+ throw new RemoteException("IMS is not supported on this device.");
+ }
if (!isBinderReady()) {
throw new RemoteException("ImsServiceProxy is not ready to accept commands.");
}
@@ -955,10 +965,4 @@ public class MmTelFeatureConnection {
private IImsMmTelFeature getServiceInterface(IBinder b) {
return IImsMmTelFeature.Stub.asInterface(b);
}
-
- protected void checkBinderConnection() throws RemoteException {
- if (!isBinderAlive()) {
- throw new RemoteException("ImsServiceProxy is not available for that feature.");
- }
- }
}