Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db509755 authored by Brad Ebinger's avatar Brad Ebinger Committed by android-build-merger
Browse files

Merge "IMS can't recover after IMS relaunch"

am: 3683752d

Change-Id: I54921bf3adaa4528afc6ff6adc02292e12419453
parents dfc8e7fb 3683752d
Loading
Loading
Loading
Loading
+20 −17
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public class ImsServiceController {
                mIsBinding = false;
                mIsBound = false;
            }
            notifyAllFeaturesRemoved();
            cleanupAllFeatures();
            cleanUpService();
            startDelayedRebindToService();
        }
@@ -144,7 +144,7 @@ public class ImsServiceController {
            if (isServiceControllerAvailable()) {
                mImsServiceControllerBinder.unlinkToDeath(mImsDeathRecipient, 0);
            }
            notifyAllFeaturesRemoved();
            cleanupAllFeatures();
            cleanUpService();
        }
    }
@@ -373,6 +373,7 @@ public class ImsServiceController {
                    boolean bindSucceeded = startBindToService(imsServiceIntent,
                            mImsServiceConnection, serviceFlags);
                    if (!bindSucceeded) {
                        mIsBinding = false;
                        mBackoff.notifyFailed();
                    }
                    return bindSucceeded;
@@ -700,8 +701,7 @@ public class ImsServiceController {
    }

    // This method should only be called when synchronized on mLock
    private void removeImsServiceFeature(ImsFeatureConfiguration.FeatureSlotPair featurePair)
            throws RemoteException {
    private void removeImsServiceFeature(ImsFeatureConfiguration.FeatureSlotPair featurePair) {
        if (!isServiceControllerAvailable() || mCallbacks == null) {
            Log.w(LOG_TAG, "removeImsServiceFeature called with null values.");
            return;
@@ -714,11 +714,18 @@ public class ImsServiceController {
            if (callbackToRemove != null) {
                mFeatureStatusCallbacks.remove(callbackToRemove);
            }
            removeImsFeature(featurePair.slotId, featurePair.featureType,
                    (callbackToRemove != null ? callbackToRemove.getCallback() : null));
            removeImsFeatureBinder(featurePair.slotId, featurePair.featureType);
            // Signal ImsResolver to change supported ImsFeatures for this ImsServiceController
            mCallbacks.imsServiceFeatureRemoved(featurePair.slotId, featurePair.featureType, this);
            try {
                removeImsFeature(featurePair.slotId, featurePair.featureType,
                        (callbackToRemove != null ? callbackToRemove.getCallback() : null));
            } catch (RemoteException e) {
                // The connection to this ImsService doesn't exist. This may happen if the service
                // has died and we are removing features.
                Log.i(LOG_TAG, "Couldn't remove feature {" + featurePair.featureType
                        + "}, connection is down: " + e.getMessage());
            }
        } else {
            // Don't update ImsService for emergency MMTEL feature.
            Log.i(LOG_TAG, "doesn't support emergency calling on slot " + featurePair.slotId);
@@ -773,19 +780,15 @@ public class ImsServiceController {
                .findFirst().orElse(null);
    }

    private void notifyAllFeaturesRemoved() {
        if (mCallbacks == null) {
            Log.w(LOG_TAG, "notifyAllFeaturesRemoved called with invalid callbacks.");
            return;
        }
    private void cleanupAllFeatures() {
        synchronized (mLock) {
            for (ImsFeatureConfiguration.FeatureSlotPair feature : mImsFeatures) {
                if (feature.featureType != ImsFeature.FEATURE_EMERGENCY_MMTEL) {
                    // don't update ImsServiceController for emergency MMTEL.
                    mCallbacks.imsServiceFeatureRemoved(feature.slotId, feature.featureType, this);
                }
                sendImsFeatureRemovedCallback(feature.slotId, feature.featureType);
            // Remove all features and clean up all associated Binders.
            for (ImsFeatureConfiguration.FeatureSlotPair i : mImsFeatures) {
                removeImsServiceFeature(i);
            }
            // remove all MmTelFeatureConnection callbacks, since we have already sent removed
            // callback.
            removeImsServiceFeatureCallbacks();
        }
    }

+12 −9
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public class ImsServiceControllerCompat extends ImsServiceController {
    }

    @Override
    protected String getServiceInterface() {
    protected final String getServiceInterface() {
        // Return compatibility version of String.
        return ImsService.SERVICE_INTERFACE;
    }
@@ -70,7 +70,7 @@ public class ImsServiceControllerCompat extends ImsServiceController {
     * Converts the new command to {@link MMTelFeature#turnOnIms()}.
     */
    @Override
    public void enableIms(int slotId) {
    public final void enableIms(int slotId) {
        MmTelFeatureCompatAdapter adapter = mMmTelCompatAdapters.get(slotId);
        if (adapter == null) {
            Log.w(TAG, "enableIms: adapter null for slot :" + slotId);
@@ -87,7 +87,7 @@ public class ImsServiceControllerCompat extends ImsServiceController {
     * Converts the new command to {@link MMTelFeature#turnOffIms()}.
     */
    @Override
    public void disableIms(int slotId) {
    public final void disableIms(int slotId) {
        MmTelFeatureCompatAdapter adapter = mMmTelCompatAdapters.get(slotId);
        if (adapter == null) {
            Log.w(TAG, "enableIms: adapter null for slot :" + slotId);
@@ -104,7 +104,7 @@ public class ImsServiceControllerCompat extends ImsServiceController {
     * @return the IImsRegistration that corresponds to the slot id specified.
     */
    @Override
    public IImsRegistration getRegistration(int slotId) throws RemoteException {
    public final IImsRegistration getRegistration(int slotId) {
        ImsRegistrationCompatAdapter adapter = mRegCompatAdapters.get(slotId);
        if (adapter == null) {
            Log.w(TAG, "getRegistration: Registration does not exist for slot " + slotId);
@@ -117,7 +117,7 @@ public class ImsServiceControllerCompat extends ImsServiceController {
     * @return the IImsConfig that corresponds to the slot id specified.
     */
    @Override
    public IImsConfig getConfig(int slotId) throws RemoteException {
    public final IImsConfig getConfig(int slotId) {
        ImsConfigCompatAdapter adapter = mConfigCompatAdapters.get(slotId);
        if (adapter == null) {
            Log.w(TAG, "getConfig: Config does not exist for slot " + slotId);
@@ -127,13 +127,14 @@ public class ImsServiceControllerCompat extends ImsServiceController {
    }

    @Override
    protected void notifyImsServiceReady() throws RemoteException {
    protected final void notifyImsServiceReady() {
        Log.d(TAG, "notifyImsServiceReady");
        // don't do anything for compat impl.
    }

    @Override
    protected IInterface createImsFeature(int slotId, int featureType, IImsFeatureStatusCallback c)
    protected final IInterface createImsFeature(int slotId, int featureType,
            IImsFeatureStatusCallback c)
            throws RemoteException {
        switch (featureType) {
            case ImsFeature.MMTEL: {
@@ -148,15 +149,17 @@ public class ImsServiceControllerCompat extends ImsServiceController {
    }

    @Override
    protected void removeImsFeature(int slotId, int featureType, IImsFeatureStatusCallback c)
    protected final void removeImsFeature(int slotId, int featureType, IImsFeatureStatusCallback c)
            throws RemoteException {
        if (featureType == ImsFeature.MMTEL) {
            mMmTelCompatAdapters.remove(slotId);
            mRegCompatAdapters.remove(slotId);
            mConfigCompatAdapters.remove(slotId);
        }
        if (mServiceController != null) {
            mServiceController.removeImsFeature(slotId, featureType, c);
        }
    }

    @Override
    protected void setServiceController(IBinder serviceController) {
+7 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;

@@ -66,8 +65,13 @@ public class ImsServiceControllerStaticCompat extends ImsServiceControllerCompat
    }

    @Override
    protected MmTelInterfaceAdapter getInterface(int slotId, IImsFeatureStatusCallback c)
            throws RemoteException {
    // used for add/remove features and cleanup in ImsServiceController.
    protected boolean isServiceControllerAvailable() {
        return mImsServiceCompat != null;
    }

    @Override
    protected MmTelInterfaceAdapter getInterface(int slotId, IImsFeatureStatusCallback c) {
        if (mImsServiceCompat == null) {
            Log.w(TAG, "getInterface: IImsService returned null.");
            return null;