From 3afcd20f6ae8d19a31e6b00e616ca1c63234a3a8 Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Mon, 18 May 2020 17:46:06 -0700 Subject: Fix MmTelFeatureConnection Memory Leak In FeatureConnection, we never cleaned up the ImsFeatureStatusCallback after it was destroyed, leaving zombie FeatureConnections around. Bug: 156893040 Fixes: 157948894 Test: atest FrameworksTelephonyTests Merged-In: Idcf8b558c3807a3f9f5094afee532e76ea6f02cb Change-Id: Idcf8b558c3807a3f9f5094afee532e76ea6f02cb --- .../java/android/telephony/TelephonyManager.java | 23 ++++++++++++++++++++++ .../com/android/internal/telephony/ITelephony.aidl | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 7d1398b51ec8..6b498b5f8697 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -7329,6 +7329,29 @@ public class TelephonyManager { return null; } + /** + * Unregister a IImsServiceFeatureCallback previously associated with an ImsFeature through + * {@link #getImsMmTelFeatureAndListen(int, IImsServiceFeatureCallback)} or + * {@link #getImsRcsFeatureAndListen(int, IImsServiceFeatureCallback)}. + * @param slotIndex The SIM slot associated with the callback. + * @param featureType The {@link android.telephony.ims.feature.ImsFeature.FeatureType} + * associated with the callback. + * @param callback The callback to be unregistered. + * @hide + */ + public void unregisterImsFeatureCallback(int slotIndex, int featureType, + IImsServiceFeatureCallback callback) { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + telephony.unregisterImsFeatureCallback(slotIndex, featureType, callback); + } + } catch (RemoteException e) { + Rlog.e(TAG, "unregisterImsFeatureCallback, RemoteException: " + + e.getMessage()); + } + } + /** * @return the {@IImsRegistration} interface that corresponds with the slot index and feature. * @param slotIndex The SIM slot corresponding to the ImsService ImsRegistration is active for. diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 5293efa6bce7..5a6b997f0723 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -850,6 +850,14 @@ interface ITelephony { */ IImsRcsFeature getRcsFeatureAndListen(int slotId, in IImsServiceFeatureCallback callback); + /** + * Unregister a callback that was previously registered through + * {@link #getMmTelFeatureAndListen} or {@link #getRcsFeatureAndListen}. This should always be + * called when the callback is no longer being used. + */ + void unregisterImsFeatureCallback(int slotId, int featureType, + in IImsServiceFeatureCallback callback); + /** * Returns the IImsRegistration associated with the slot and feature specified. */ -- cgit v1.2.3-59-g8ed1b