diff options
author | Brad Ebinger <breadley@google.com> | 2019-11-01 11:23:55 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-11-01 11:23:55 -0700 |
commit | 75835bbfe929379978e5434fcdb948df1609dcca (patch) | |
tree | 916c20af180bbe17cdd7cf35aa2c351b4e1bcb6e | |
parent | ec7acd9a974424f341348f7193849e0f92b34527 (diff) | |
parent | 9029b716679fd1284e57d7ad232161e251fe2330 (diff) | |
download | ims-75835bbfe929379978e5434fcdb948df1609dcca.tar.gz |
Remove dependencies on old ImsMmtelManager.RegistrationCallback
am: 9029b71667
Change-Id: Iba4305511ed099a7e5bc90d0661160ac72debf59
-rw-r--r-- | src/java/com/android/ims/FeatureConnection.java | 3 | ||||
-rw-r--r-- | src/java/com/android/ims/FeatureConnector.java | 31 | ||||
-rw-r--r-- | src/java/com/android/ims/ImsConnectionStateListener.java | 7 | ||||
-rw-r--r-- | src/java/com/android/ims/ImsManager.java | 133 | ||||
-rw-r--r-- | src/java/com/android/ims/MmTelFeatureConnection.java | 76 |
5 files changed, 141 insertions, 109 deletions
diff --git a/src/java/com/android/ims/FeatureConnection.java b/src/java/com/android/ims/FeatureConnection.java index a123fc93..5e7dcdda 100644 --- a/src/java/com/android/ims/FeatureConnection.java +++ b/src/java/com/android/ims/FeatureConnection.java @@ -262,7 +262,8 @@ public abstract class FeatureConnection { // Cache only non-null value for feature status. mFeatureStateCached = state; } - Log.i(TAG, "getFeatureState - returning " + ImsFeature.STATE_LOG_MAP.get(state)); + Log.i(TAG + " [" + mSlotId + "]", "getFeatureState - returning " + + ImsFeature.STATE_LOG_MAP.get(state)); return state; } diff --git a/src/java/com/android/ims/FeatureConnector.java b/src/java/com/android/ims/FeatureConnector.java index 380bda93..8000a350 100644 --- a/src/java/com/android/ims/FeatureConnector.java +++ b/src/java/com/android/ims/FeatureConnector.java @@ -17,6 +17,7 @@ package com.android.ims; import android.content.Context; +import android.content.pm.PackageManager; import android.os.Handler; import android.os.Looper; import android.telephony.ims.feature.ImsFeature; @@ -73,7 +74,7 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { protected final String mLogPrefix; @VisibleForTesting - public Listener mListener; + public Listener<T> mListener; // The IMS feature manager which interacts with ImsService @VisibleForTesting @@ -92,7 +93,7 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { } }; - public FeatureConnector(Context context, int phoneId, Listener listener) { + public FeatureConnector(Context context, int phoneId, Listener<T> listener) { mContext = context; mPhoneId = phoneId; mListener = listener; @@ -100,7 +101,7 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { mLogPrefix = "?"; } - public FeatureConnector(Context context, int phoneId, Listener listener, + public FeatureConnector(Context context, int phoneId, Listener<T> listener, String logPrefix) { mContext = context; mPhoneId = phoneId; @@ -110,7 +111,7 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { } @VisibleForTesting - public FeatureConnector(Context context, int phoneId, Listener listener, + public FeatureConnector(Context context, int phoneId, Listener<T> listener, Executor executor, String logPrefix) { mContext = context; mPhoneId = phoneId; @@ -120,7 +121,7 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { } @VisibleForTesting - public FeatureConnector(Context context, int phoneId, Listener listener, + public FeatureConnector(Context context, int phoneId, Listener<T> listener, Executor executor, Looper looper) { super(looper); mContext = context; @@ -132,16 +133,16 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { /** * Start the creation of a connection to the underlying ImsService implementation. When the - * service is connected, {@link FeatureConnector.Listener#connectionReady(T manager)} will be + * service is connected, {@link FeatureConnector.Listener#connectionReady(Object)} will be * called with an active 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() { - Log.i(TAG, "connect"); + Log.i(TAG, getLogMessage("connect")); if (!isSupported()) { - Log.i(TAG, "connect: NOT support!"); + Log.i(TAG, getLogMessage("connect: not supported.")); return; } mRetryCount = 0; @@ -160,7 +161,7 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { * {@link FeatureConnector.Listener#connectionUnavailable()} will be called one last time. */ public void disconnect() { - Log.i(TAG, "disconnect"); + Log.i(TAG, getLogMessage("disconnect")); removeCallbacks(mGetServiceRunnable); synchronized (mLock) { if (mManager != null) { @@ -181,8 +182,8 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { @VisibleForTesting public void createImsService() throws ImsException { synchronized (mLock) { - Log.d(TAG, "createImsService"); - mManager = (T) mListener.getFeatureManager(); + Log.d(TAG, getLogMessage("createImsService")); + mManager = mListener.getFeatureManager(); // Adding to set, will be safe adding multiple times. If the ImsService is not // active yet, this method will throw an ImsException. mManager.addNotifyStatusChangedCallbackIfAvailable(mNotifyStatusChangedCallback); @@ -238,7 +239,7 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { break; } default: { - Log.w(TAG, "Unexpected State!"); + Log.w(TAG, getLogMessage("Unexpected State!")); } } } catch (ImsException e) { @@ -264,7 +265,7 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { manager = mManager; } try { - Log.i(TAG, "notifyReady"); + Log.i(TAG, getLogMessage("notifyReady")); mListener.connectionReady(manager); } catch (ImsException e) { @@ -278,11 +279,11 @@ public class FeatureConnector<T extends IFeatureConnector> extends Handler { } protected void notifyNotReady() { - Log.i(TAG, "notifyNotReady"); + Log.i(TAG, getLogMessage("notifyNotReady")); mListener.connectionUnavailable(); } protected String getLogMessage(String message) { - return "Connector-[" + mLogPrefix + "] " + message; + return "Connector-[" + mLogPrefix + ", " + mPhoneId + "] " + message; } } diff --git a/src/java/com/android/ims/ImsConnectionStateListener.java b/src/java/com/android/ims/ImsConnectionStateListener.java index 6f6107cb..1594c805 100644 --- a/src/java/com/android/ims/ImsConnectionStateListener.java +++ b/src/java/com/android/ims/ImsConnectionStateListener.java @@ -17,9 +17,8 @@ package com.android.ims; import android.net.Uri; -import android.telephony.ims.ImsMmTelManager; +import android.telephony.ims.RegistrationManager; import android.telephony.ims.ImsReasonInfo; -import android.telephony.ims.feature.ImsFeature; import android.telephony.ims.feature.MmTelFeature; import android.telephony.ims.stub.ImsRegistrationImplBase; @@ -29,10 +28,10 @@ import java.util.Arrays; * Listener for receiving notifications about changes to the IMS connection. * It provides a state of IMS registration between UE and IMS network, the service * availability of the local device during IMS registered. - * @Deprecated Use {@link ImsMmTelManager.RegistrationCallback} instead. + * @Deprecated Use {@link RegistrationManager.RegistrationCallback} instead. * @hide */ -public class ImsConnectionStateListener extends ImsMmTelManager.RegistrationCallback { +public class ImsConnectionStateListener extends RegistrationManager.RegistrationCallback { @Override public final void onRegistered(@ImsRegistrationImplBase.ImsRegistrationTech int imsRadioTech) { diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java index 632bc900..0a8b7c2e 100644 --- a/src/java/com/android/ims/ImsManager.java +++ b/src/java/com/android/ims/ImsManager.java @@ -20,7 +20,6 @@ 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.HandlerThread; import android.os.Looper; @@ -34,6 +33,7 @@ import android.provider.Settings; import android.telecom.TelecomManager; import android.telephony.AccessNetworkConstants; import android.telephony.CarrierConfigManager; +import android.telephony.ims.RegistrationManager; import android.telephony.ims.ImsMmTelManager; import android.telephony.ims.ImsService; import android.telephony.ims.ProvisioningManager; @@ -53,7 +53,6 @@ import android.telephony.ims.aidl.IImsSmsListener; import android.telephony.ims.feature.CapabilityChangeRequest; import android.telephony.ims.feature.ImsFeature; import android.telephony.ims.feature.MmTelFeature; -import android.util.Log; import com.android.ims.internal.IImsCallSession; import com.android.ims.internal.IImsEcbm; @@ -294,7 +293,8 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isEnhanced4gLteModeSettingEnabledByUser(); } - loge("isEnhanced4gLteModeSettingEnabledByUser: ImsManager null, returning default value."); + Rlog.e(TAG, "isEnhanced4gLteModeSettingEnabledByUser: ImsManager null, returning default" + + " value."); return false; } @@ -338,7 +338,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { mgr.setEnhanced4gLteModeSetting(enabled); } - loge("setEnhanced4gLteModeSetting: ImsManager null, value not set."); + Rlog.e(TAG, "setEnhanced4gLteModeSetting: ImsManager null, value not set."); } /** @@ -398,7 +398,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isNonTtyOrTtyOnVolteEnabled(); } - loge("isNonTtyOrTtyOnVolteEnabled: ImsManager null, returning default value."); + Rlog.e(TAG, "isNonTtyOrTtyOnVolteEnabled: ImsManager null, returning default value."); return false; } @@ -413,7 +413,7 @@ public class ImsManager implements IFeatureConnector { TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); if (tm == null) { - Log.w(TAG, "isNonTtyOrTtyOnVolteEnabled: telecom not available"); + logw("isNonTtyOrTtyOnVolteEnabled: telecom not available"); return true; } return tm.getCurrentTtyMode() == TelecomManager.TTY_MODE_OFF; @@ -434,7 +434,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isVolteEnabledByPlatform(); } - loge("isVolteEnabledByPlatform: ImsManager null, returning default value."); + Rlog.e(TAG, "isVolteEnabledByPlatform: ImsManager null, returning default value."); return false; } @@ -524,7 +524,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isVolteProvisionedOnDevice(); } - loge("isVolteProvisionedOnDevice: ImsManager null, returning default value."); + Rlog.e(TAG, "isVolteProvisionedOnDevice: ImsManager null, returning default value."); return true; } @@ -555,7 +555,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isWfcProvisionedOnDevice(); } - loge("isWfcProvisionedOnDevice: ImsManager null, returning default value."); + Rlog.e(TAG, "isWfcProvisionedOnDevice: ImsManager null, returning default value."); return true; } @@ -593,7 +593,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isVtProvisionedOnDevice(); } - loge("isVtProvisionedOnDevice: ImsManager null, returning default value."); + Rlog.e(TAG, "isVtProvisionedOnDevice: ImsManager null, returning default value."); return true; } @@ -624,7 +624,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isVtEnabledByPlatform(); } - loge("isVtEnabledByPlatform: ImsManager null, returning default value."); + Rlog.e(TAG, "isVtEnabledByPlatform: ImsManager null, returning default value."); return false; } @@ -661,7 +661,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isVtEnabledByUser(); } - loge("isVtEnabledByUser: ImsManager null, returning default value."); + Rlog.e(TAG, "isVtEnabledByUser: ImsManager null, returning default value."); return false; } @@ -690,7 +690,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { mgr.setVtSetting(enabled); } - loge("setVtSetting: ImsManager null, can not set value."); + Rlog.e(TAG, "setVtSetting: ImsManager null, can not set value."); } /** @@ -745,7 +745,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isTurnOffImsAllowedByPlatform(); } - loge("isTurnOffImsAllowedByPlatform: ImsManager null, returning default value."); + Rlog.e(TAG, "isTurnOffImsAllowedByPlatform: ImsManager null, returning default value."); return true; } @@ -779,7 +779,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isWfcEnabledByUser(); } - loge("isWfcEnabledByUser: ImsManager null, returning default value."); + Rlog.e(TAG, "isWfcEnabledByUser: ImsManager null, returning default value."); return true; } @@ -812,7 +812,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { mgr.setWfcSetting(enabled); } - loge("setWfcSetting: ImsManager null, can not set value."); + Rlog.e(TAG, "setWfcSetting: ImsManager null, can not set value."); } /** @@ -887,7 +887,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.getWfcMode(); } - loge("getWfcMode: ImsManager null, returning default value."); + Rlog.e(TAG, "getWfcMode: ImsManager null, returning default value."); return ImsMmTelManager.WIFI_MODE_WIFI_ONLY; } @@ -910,7 +910,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { mgr.setWfcMode(wfcMode); } - loge("setWfcMode: ImsManager null, can not set value."); + Rlog.e(TAG, "setWfcMode: ImsManager null, can not set value."); } /** @@ -934,7 +934,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.getWfcMode(roaming); } - loge("getWfcMode: ImsManager null, returning default value."); + Rlog.e(TAG, "getWfcMode: ImsManager null, returning default value."); return ImsMmTelManager.WIFI_MODE_WIFI_ONLY; } @@ -1006,7 +1006,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { mgr.setWfcMode(wfcMode, roaming); } - loge("setWfcMode: ImsManager null, can not set value."); + Rlog.e(TAG, "setWfcMode: ImsManager null, can not set value."); } /** @@ -1074,7 +1074,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isWfcRoamingEnabledByUser(); } - loge("isWfcRoamingEnabledByUser: ImsManager null, returning default value."); + Rlog.e(TAG, "isWfcRoamingEnabledByUser: ImsManager null, returning default value."); return false; } @@ -1103,7 +1103,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { mgr.setWfcRoamingSetting(enabled); } - loge("setWfcRoamingSetting: ImsManager null, value not set."); + Rlog.e(TAG, "setWfcRoamingSetting: ImsManager null, value not set."); } /** @@ -1145,7 +1145,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { return mgr.isWfcEnabledByPlatform(); } - loge("isWfcEnabledByPlatform: ImsManager null, returning default value."); + Rlog.e(TAG, "isWfcEnabledByPlatform: ImsManager null, returning default value."); return false; } @@ -1240,7 +1240,7 @@ public class ImsManager implements IFeatureConnector { ImsConfig config = getConfigInterface(); return getProvisionedBool(config, item); } catch (ImsException ex) { - Log.w(TAG, "getProvisionedBoolNoException: operation failed for item=" + item + logw("getProvisionedBoolNoException: operation failed for item=" + item + ". Exception:" + ex.getMessage() + ". Returning false."); return false; } @@ -1255,7 +1255,7 @@ public class ImsManager implements IFeatureConnector { ImsConfig config = getConfigInterface(); setProvisionedBool(config, item, value); } catch (ImsException ex) { - Log.w(TAG, "setProvisionedBoolNoException: operation failed for item=" + item + logw("setProvisionedBoolNoException: operation failed for item=" + item + ", value=" + value + ". Exception:" + ex.getMessage()); return false; } @@ -1277,7 +1277,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { mgr.updateImsServiceConfig(force); } - loge("updateImsServiceConfig: ImsManager null, returning without update."); + Rlog.e(TAG, "updateImsServiceConfig: ImsManager null, returning without update."); } /** @@ -1454,7 +1454,7 @@ public class ImsManager implements IFeatureConnector { ImsRegistrationImplBase.REGISTRATION_TECH_LTE); } } catch (RemoteException e) { - Log.e(TAG, "updateUtFeatureValue: couldn't reach telephony! returning provisioned"); + loge("updateUtFeatureValue: couldn't reach telephony! returning provisioned"); } } boolean isFeatureOn = isCarrierSupported && isProvisioned; @@ -1550,7 +1550,7 @@ public class ImsManager implements IFeatureConnector { if (c != null) { mStatusCallbacks.remove(c); } else { - Log.w(TAG, "removeNotifyStatusChangedCallback: callback is null!"); + logw("removeNotifyStatusChangedCallback: callback is null!"); } } @@ -1602,7 +1602,7 @@ public class ImsManager implements IFeatureConnector { * @param listener To listen to IMS registration events; It cannot be null * @throws NullPointerException if {@code listener} is null * @throws ImsException if calling the IMS service results in an error - * @deprecated use {@link #addRegistrationCallback(ImsMmTelManager.RegistrationCallback)} + * @deprecated use {@link #addRegistrationCallback(RegistrationManager.RegistrationCallback)} * instead. */ public void addRegistrationListener(ImsConnectionStateListener listener) throws ImsException { @@ -1624,11 +1624,11 @@ public class ImsManager implements IFeatureConnector { /** * Adds a callback that gets called when IMS registration has changed for the slot ID * associated with this ImsManager. - * @param callback A {@link ImsMmTelManager.RegistrationCallback} that will notify the caller - * when IMS registration status has changed. + * @param callback A {@link RegistrationManager.RegistrationCallback} that will notify the + * caller when IMS registration status has changed. * @throws ImsException when the ImsService connection is not available. */ - public void addRegistrationCallback(ImsMmTelManager.RegistrationCallback callback) + public void addRegistrationCallback(RegistrationManager.RegistrationCallback callback) throws ImsException { if (callback == null) { throw new NullPointerException("registration callback can't be null"); @@ -1647,10 +1647,10 @@ public class ImsManager implements IFeatureConnector { /** * Removes a previously added registration callback that was added via - * {@link #addRegistrationCallback(ImsMmTelManager.RegistrationCallback)} . - * @param callback A {@link ImsMmTelManager.RegistrationCallback} that was previously added. + * {@link #addRegistrationCallback(RegistrationManager.RegistrationCallback)} . + * @param callback A {@link RegistrationManager.RegistrationCallback} that was previously added. */ - public void removeRegistrationListener(ImsMmTelManager.RegistrationCallback callback) { + public void removeRegistrationListener(RegistrationManager.RegistrationCallback callback) { if (callback == null) { throw new NullPointerException("registration callback can't be null"); } @@ -1663,8 +1663,8 @@ public class ImsManager implements IFeatureConnector { * Adds a callback that gets called when IMS registration has changed for a specific * subscription. * - * @param callback A {@link ImsMmTelManager.RegistrationCallback} that will notify the caller - * when IMS registration status has changed. + * @param callback A {@link RegistrationManager.RegistrationCallback} that will notify the + * caller when IMS registration status has changed. * @param subId The subscription ID to register this registration callback for. * @throws RemoteException when the ImsService connection is not available. */ @@ -1679,8 +1679,8 @@ public class ImsManager implements IFeatureConnector { } /** - * Removes a previously registered {@link ImsMmTelManager.RegistrationCallback} callback that is - * associated with a specific subscription. + * Removes a previously registered {@link RegistrationManager.RegistrationCallback} callback + * that is associated with a specific subscription. */ public void removeRegistrationCallbackForSubscription(IImsRegistrationCallback callback, int subId) { @@ -1816,11 +1816,23 @@ public class ImsManager implements IFeatureConnector { try { return mMmTelFeatureConnection.getRegistrationTech(); } catch (RemoteException e) { - Log.w(TAG, "getRegistrationTech: no connection to ImsService."); + logw("getRegistrationTech: no connection to ImsService."); return ImsRegistrationImplBase.REGISTRATION_TECH_NONE; } } + public void getRegistrationTech(Consumer<Integer> callback) { + mExecutorFactory.executeRunnable(() -> { + try { + int tech = mMmTelFeatureConnection.getRegistrationTech(); + callback.accept(tech); + } catch (RemoteException e) { + logw("getRegistrationTech(C): no connection to ImsService."); + callback.accept(ImsRegistrationImplBase.REGISTRATION_TECH_NONE); + } + }); + } + /** * Closes the connection and removes all active callbacks. * All the resources that were allocated to the service are also released. @@ -1986,7 +1998,7 @@ public class ImsManager implements IFeatureConnector { public void changeMmTelCapability(CapabilityChangeRequest r) throws ImsException { checkAndThrowExceptionIfServiceUnavailable(); try { - Log.i(TAG, "changeMmTelCapability: changing capabilities for sub: " + getSubId() + logi("changeMmTelCapability: changing capabilities for sub: " + getSubId() + ", request: " + r); mMmTelFeatureConnection.changeEnabledCapabilities(r, null); if (mImsConfigListener == null) { @@ -2018,8 +2030,7 @@ public class ImsManager implements IFeatureConnector { CarrierConfigManager.KEY_IGNORE_RTT_MODE_SETTING_BOOL); boolean shouldImsRttBeOn = isRttUiSettingEnabled || isRttAlwaysOnCarrierConfig; - Log.i(ImsManager.class.getSimpleName(), "update RTT: settings value: " - + isRttUiSettingEnabled + " always-on carrierconfig: " + logi("update RTT: settings value: " + isRttUiSettingEnabled + " always-on carrierconfig: " + isRttAlwaysOnCarrierConfig); if (isCarrierSupported) { @@ -2033,12 +2044,11 @@ public class ImsManager implements IFeatureConnector { ProvisioningManager.PROVISIONING_VALUE_DISABLED; mExecutorFactory.executeRunnable(() -> { try { - Log.i(ImsManager.class.getSimpleName(), "Setting RTT enabled to " + enabled); + logi("Setting RTT enabled to " + enabled); getConfigInterface().setProvisionedValue( ImsConfig.ConfigConstants.RTT_SETTING_ENABLED, value); } catch (ImsException e) { - Log.e(ImsManager.class.getSimpleName(), "Unable to set RTT value enabled to " - + enabled + ": " + e); + loge("Unable to set RTT value enabled to " + enabled + ": " + e); } }); } @@ -2080,7 +2090,7 @@ public class ImsManager implements IFeatureConnector { try { return result.poll(RESPONSE_WAIT_TIME_MS, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { - Log.w(TAG, "queryMmTelCapability: interrupted while waiting for response"); + logw("queryMmTelCapability: interrupted while waiting for response"); } return false; } @@ -2094,8 +2104,7 @@ public class ImsManager implements IFeatureConnector { } setRttConfig(enabled); } catch (ImsException e) { - Log.e(ImsManager.class.getSimpleName(), "Unable to set RTT enabled to " + enabled - + ": " + e); + loge("Unable to set RTT enabled to " + enabled + ": " + e); } } @@ -2279,23 +2288,31 @@ public class ImsManager implements IFeatureConnector { // Throws an exception if the ImsService Feature is not ready to accept commands. return new ImsCallSession(mMmTelFeatureConnection.createCallSession(profile)); } catch (RemoteException e) { - Rlog.w(TAG, "CreateCallSession: Error, remote exception: " + e.getMessage()); + logw("CreateCallSession: Error, remote exception: " + e.getMessage()); throw new ImsException("createCallSession()", e, ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN); } } - private static void log(String s) { - Rlog.d(TAG, s); + private void log(String s) { + Rlog.d(TAG + " [" + mPhoneId + "]", s); + } + + private void logi(String s) { + Rlog.i(TAG + " [" + mPhoneId + "]", s); + } + + private void logw(String s) { + Rlog.w(TAG + " [" + mPhoneId + "]", s); } - private static void loge(String s) { - Rlog.e(TAG, s); + private void loge(String s) { + Rlog.e(TAG + " [" + mPhoneId + "]", s); } - private static void loge(String s, Throwable t) { - Rlog.e(TAG, s, t); + private void loge(String s, Throwable t) { + Rlog.e(TAG + " [" + mPhoneId + "]", s, t); } /** @@ -2344,7 +2361,7 @@ public class ImsManager implements IFeatureConnector { try { mMmTelFeatureConnection.changeEnabledCapabilities(request, null); } catch (RemoteException e) { - Log.e(TAG, "setLteFeatureValues: Exception: " + e.getMessage()); + loge("setLteFeatureValues: Exception: " + e.getMessage()); } } @@ -2529,7 +2546,7 @@ public class ImsManager implements IFeatureConnector { if (mgr != null) { mgr.factoryReset(); } - loge("factoryReset: ImsManager null."); + Rlog.e(TAG, "factoryReset: ImsManager null."); } /** diff --git a/src/java/com/android/ims/MmTelFeatureConnection.java b/src/java/com/android/ims/MmTelFeatureConnection.java index 9b209764..48f160d5 100644 --- a/src/java/com/android/ims/MmTelFeatureConnection.java +++ b/src/java/com/android/ims/MmTelFeatureConnection.java @@ -74,6 +74,7 @@ public class MmTelFeatureConnection extends FeatureConnection { private final Context mContext; private final Object mLock; + private final int mSlotId; // Map of sub id -> List<callbacks> for sub id linked callbacks. private final SparseArray<Set<T>> mCallbackSubscriptionMap = new SparseArray<>(); // List of all active callbacks to ImsService @@ -81,9 +82,10 @@ public class MmTelFeatureConnection extends FeatureConnection { @VisibleForTesting public SubscriptionManager.OnSubscriptionsChangedListener mSubChangedListener; - public CallbackAdapterManager(Context context, Object lock) { + public CallbackAdapterManager(Context context, Object lock, int slotId) { mContext = context; mLock = lock; + mSlotId = slotId; if (Looper.myLooper() == null) { Looper.prepare(); } @@ -94,7 +96,8 @@ public class MmTelFeatureConnection extends FeatureConnection { SubscriptionManager manager = mContext.getSystemService( SubscriptionManager.class); if (manager == null) { - Log.w(TAG, "onSubscriptionsChanged: could not find SubscriptionManager."); + Log.w(TAG + " [" + mSlotId + "]", "onSubscriptionsChanged: could not find " + + "SubscriptionManager."); return; } List<SubscriptionInfo> subInfos = manager.getActiveSubscriptionInfoList(false); @@ -130,7 +133,7 @@ public class MmTelFeatureConnection extends FeatureConnection { // for the slot, independent of subscription (deprecated behavior). // Throws a IllegalStateException if this registration fails. registerCallback(localCallback); - Log.i(TAG, "Local callback added: " + localCallback); + Log.i(TAG + " [" + mSlotId + "]", "Local callback added: " + localCallback); mRemoteCallbacks.register(localCallback); } } @@ -149,7 +152,7 @@ public class MmTelFeatureConnection extends FeatureConnection { // Removes a callback associated with the MmTelFeature. public final void removeCallback(T localCallback) { - Log.i(TAG, "Local callback removed: " + localCallback); + Log.i(TAG + " [" + mSlotId + "]", "Local callback removed: " + localCallback); synchronized (mLock) { if (mRemoteCallbacks.unregister(localCallback)) { // Will only occur if we have record of this callback in mRemoteCallbacks. @@ -245,7 +248,8 @@ public class MmTelFeatureConnection extends FeatureConnection { if (manager != null) { manager.addOnSubscriptionsChangedListener(mSubChangedListener); } else { - Log.w(TAG, "registerForSubscriptionsChanged: could not find SubscriptionManager."); + Log.w(TAG + " [" + mSlotId + "]", "registerForSubscriptionsChanged: could not find" + + " SubscriptionManager."); } } @@ -254,8 +258,8 @@ public class MmTelFeatureConnection extends FeatureConnection { if (manager != null) { manager.removeOnSubscriptionsChangedListener(mSubChangedListener); } else { - Log.w(TAG, "unregisterForSubscriptionsChanged: could not find" - + " SubscriptionManager."); + Log.w(TAG + " [" + mSlotId + "]", "unregisterForSubscriptionsChanged: could not" + + " find SubscriptionManager."); } } @@ -271,7 +275,7 @@ public class MmTelFeatureConnection extends FeatureConnection { mRemoteCallbacks.unregister(callbackItem); } clearCallbacksForAllSubscriptions(); - Log.i(TAG, "Closing connection and clearing callbacks"); + Log.i(TAG + " [" + mSlotId + "]", "Closing connection and clearing callbacks"); } } @@ -286,7 +290,7 @@ public class MmTelFeatureConnection extends FeatureConnection { CallbackAdapterManager<IImsRegistrationCallback> { public ImsRegistrationCallbackAdapter(Context context, Object lock) { - super(context, lock); + super(context, lock, mSlotId); } @Override @@ -300,7 +304,8 @@ public class MmTelFeatureConnection extends FeatureConnection { + " binder is dead."); } } else { - Log.e(TAG, "ImsRegistrationCallbackAdapter: ImsRegistration is null"); + Log.e(TAG + " [" + mSlotId + "]", "ImsRegistrationCallbackAdapter: ImsRegistration" + + " is null"); throw new IllegalStateException("ImsRegistrationCallbackAdapter: MmTelFeature is" + "not available!"); } @@ -313,11 +318,12 @@ public class MmTelFeatureConnection extends FeatureConnection { try { imsRegistration.removeRegistrationCallback(localCallback); } catch (RemoteException e) { - Log.w(TAG, "ImsRegistrationCallbackAdapter - unregisterCallback: couldn't" - + " remove registration callback"); + Log.w(TAG + " [" + mSlotId + "]", "ImsRegistrationCallbackAdapter -" + + " unregisterCallback: couldn't remove registration callback"); } } else { - Log.e(TAG, "ImsRegistrationCallbackAdapter: ImsRegistration is null"); + Log.e(TAG + " [" + mSlotId + "]", "ImsRegistrationCallbackAdapter: ImsRegistration" + + " is null"); } } } @@ -325,7 +331,7 @@ public class MmTelFeatureConnection extends FeatureConnection { private class CapabilityCallbackManager extends CallbackAdapterManager<IImsCapabilityCallback> { public CapabilityCallbackManager(Context context, Object lock) { - super(context, lock); + super(context, lock, mSlotId); } @Override @@ -348,7 +354,8 @@ public class MmTelFeatureConnection extends FeatureConnection { + " binder is null."); } } else { - Log.w(TAG, "CapabilityCallbackManager, register: Couldn't get binder"); + Log.w(TAG + " [" + mSlotId + "]", "CapabilityCallbackManager, register: Couldn't" + + " get binder"); throw new IllegalStateException("CapabilityCallbackManager: MmTelFeature is" + " not available!"); } @@ -363,7 +370,8 @@ public class MmTelFeatureConnection extends FeatureConnection { binder = getServiceInterface(mBinder); } catch (RemoteException e) { // binder is null - Log.w(TAG, "CapabilityCallbackManager, unregister: couldn't get binder."); + Log.w(TAG + " [" + mSlotId + "]", "CapabilityCallbackManager, unregister:" + + " couldn't get binder."); return; } } @@ -371,17 +379,19 @@ public class MmTelFeatureConnection extends FeatureConnection { try { binder.removeCapabilityCallback(localCallback); } catch (RemoteException e) { - Log.w(TAG, "CapabilityCallbackManager, unregister: Binder is dead."); + Log.w(TAG + " [" + mSlotId + "]", "CapabilityCallbackManager, unregister:" + + " Binder is dead."); } } else { - Log.w(TAG, "CapabilityCallbackManager, unregister: binder is null."); + Log.w(TAG + " [" + mSlotId + "]", "CapabilityCallbackManager, unregister:" + + " binder is null."); } } } private class ProvisioningCallbackManager extends CallbackAdapterManager<IImsConfigCallback> { public ProvisioningCallbackManager (Context context, Object lock) { - super(context, lock); + super(context, lock, mSlotId); } @Override @@ -389,7 +399,8 @@ public class MmTelFeatureConnection extends FeatureConnection { IImsConfig binder = getConfigInterface(); if (binder == null) { // Config interface is not currently available. - Log.w(TAG, "ProvisioningCallbackManager - couldn't register, binder is null."); + Log.w(TAG + " [" + mSlotId + "]", "ProvisioningCallbackManager - couldn't register," + + " binder is null."); throw new IllegalStateException("ImsConfig is not available!"); } try { @@ -403,13 +414,15 @@ public class MmTelFeatureConnection extends FeatureConnection { public void unregisterCallback(IImsConfigCallback localCallback) { IImsConfig binder = getConfigInterface(); if (binder == null) { - Log.w(TAG, "ProvisioningCallbackManager - couldn't unregister, binder is null."); + Log.w(TAG + " [" + mSlotId + "]", "ProvisioningCallbackManager - couldn't" + + " unregister, binder is null."); return; } try { binder.removeImsConfigCallback(localCallback); } catch (RemoteException e) { - Log.w(TAG, "ProvisioningCallbackManager - couldn't unregister, binder is dead."); + Log.w(TAG + " [" + mSlotId + "]", "ProvisioningCallbackManager - couldn't" + + " unregister, binder is dead."); } } } @@ -434,7 +447,7 @@ public class MmTelFeatureConnection extends FeatureConnection { TelephonyManager tm = serviceProxy.getTelephonyManager(); if (tm == null) { - Rlog.w(TAG, "create: TelephonyManager is null!"); + Rlog.w(TAG + " [" + slotId + "]", "create: TelephonyManager is null!"); // Binder can be unset in this case because it will be torn down/recreated as part of // a retry mechanism until the serviceProxy binder is set successfully. return serviceProxy; @@ -447,7 +460,7 @@ public class MmTelFeatureConnection extends FeatureConnection { // Trigger the cache to be updated for feature status. serviceProxy.getFeatureState(); } else { - Rlog.w(TAG, "create: binder is null! Slot Id: " + slotId); + Rlog.w(TAG + " [" + slotId + "]", "create: binder is null!"); } return serviceProxy; } @@ -511,14 +524,14 @@ public class MmTelFeatureConnection extends FeatureConnection { switch (feature) { case ImsFeature.FEATURE_MMTEL: { if (!mIsAvailable) { - Log.i(TAG, "MmTel enabled on slotId: " + slotId); + Log.i(TAG + " [" + mSlotId + "]", "MmTel enabled"); mIsAvailable = true; } break; } case ImsFeature.FEATURE_EMERGENCY_MMTEL: { mSupportsEmergencyCalling = true; - Log.i(TAG, "Emergency calling enabled on slotId: " + slotId); + Log.i(TAG + " [" + mSlotId + "]", "Emergency calling enabled"); break; } } @@ -533,13 +546,13 @@ public class MmTelFeatureConnection extends FeatureConnection { } switch (feature) { case ImsFeature.FEATURE_MMTEL: { - Log.i(TAG, "MmTel removed on slotId: " + slotId); + Log.i(TAG + " [" + mSlotId + "]", "MmTel removed"); onRemovedOrDied(); break; } case ImsFeature.FEATURE_EMERGENCY_MMTEL: { mSupportsEmergencyCalling = false; - Log.i(TAG, "Emergency calling disabled on slotId: " + slotId); + Log.i(TAG + " [" + mSlotId + "]", "Emergency calling disabled"); break; } } @@ -549,7 +562,7 @@ public class MmTelFeatureConnection extends FeatureConnection { @Override protected void handleImsStatusChangedCallback(int slotId, int feature, int status) { synchronized (mLock) { - Log.i(TAG, "imsStatusChanged: slot: " + slotId + " feature: " + Log.i(TAG + " [" + mSlotId + "]", "imsStatusChanged: slot: " + slotId + " feature: " + ImsFeature.FEATURE_LOG_MAP.get(feature) + " status: " + ImsFeature.STATE_LOG_MAP.get(status)); if (mSlotId == slotId && feature == ImsFeature.FEATURE_MMTEL) { @@ -590,7 +603,7 @@ public class MmTelFeatureConnection extends FeatureConnection { } } } catch (RemoteException e) { - Log.w(TAG, "closeConnection: couldn't remove listener!"); + Log.w(TAG + " [" + mSlotId + "]", "closeConnection: couldn't remove listener!"); } } @@ -764,7 +777,8 @@ public class MmTelFeatureConnection extends FeatureConnection { String[] numbers) throws RemoteException { if (isEmergency && !isEmergencyMmTelAvailable()) { // Don't query the ImsService if emergency calling is not available on the ImsService. - Log.i(TAG, "MmTel does not support emergency over IMS, fallback to CS."); + Log.i(TAG + " [" + mSlotId + "]", "MmTel does not support emergency over IMS, fallback" + + " to CS."); return MmTelFeature.PROCESS_CALL_CSFB; } synchronized (mLock) { |