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

Commit 319f21d1 authored by Brad Ebinger's avatar Brad Ebinger Committed by Automerger Merge Worker
Browse files

Fix NPE in IMS Push refactor am: 461681f0

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1449476

Change-Id: I9795a3f5b581a6ab48f752db8c040cf96dfce190
parents 4dd627b2 461681f0
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -628,8 +628,7 @@ public class ImsServiceController {
        }
        if (featurePair.featureType != ImsFeature.FEATURE_EMERGENCY_MMTEL) {
            IInterface f = createImsFeature(featurePair.slotId, featurePair.featureType);
            addImsFeatureBinder(featurePair.slotId, featurePair.featureType, f.asBinder(),
                    capabilities);
            addImsFeatureBinder(featurePair.slotId, featurePair.featureType, f, capabilities);
            addImsFeatureStatusCallback(featurePair.slotId, featurePair.featureType);
        } else {
            // Don't update ImsService for emergency MMTEL feature.
@@ -722,10 +721,17 @@ public class ImsServiceController {
        mIImsServiceController.removeImsFeature(slotId, featureType);
    }

    private void addImsFeatureBinder(int slotId, int featureType, IBinder b, long capabilities)
    private void addImsFeatureBinder(int slotId, int featureType, IInterface b, long capabilities)
            throws RemoteException {
        ImsFeatureContainer fc =
                (b == null) ? null : createFeatureContainer(slotId, b, capabilities);
        if (b == null) {

            Log.w(LOG_TAG, "addImsFeatureBinder: null IInterface reported for "
                    + ImsFeature.FEATURE_LOG_MAP.get(featureType));
            mLocalLog.log("addImsFeatureBinder: null IInterface reported for "
                    + ImsFeature.FEATURE_LOG_MAP.get(featureType));
            return;
        }
        ImsFeatureContainer fc = createFeatureContainer(slotId, b.asBinder(), capabilities);
        mRepo.addConnection(slotId, featureType, fc);
    }

+20 −0
Original line number Diff line number Diff line
@@ -474,6 +474,26 @@ public class ImsServiceControllerTest extends ImsTestBase {
        validateRcsFeatureContainerDoesntExist(SLOT_0);
    }

    /**
     * Ensures that ImsServiceController handles a null ImsFeature instance properly.
     */
    @SmallTest
    @Test
    public void testBindServiceAndImsFeatureReturnedNull() throws RemoteException {
        when(mMockServiceControllerBinder.createRcsFeature(anyInt()))
                .thenReturn(null);
        HashSet<ImsFeatureConfiguration.FeatureSlotPair> testFeatures = new HashSet<>();
        testFeatures.add(new ImsFeatureConfiguration.FeatureSlotPair(SLOT_0,
                ImsFeature.FEATURE_RCS));

        bindAndConnectService(testFeatures);

        verify(mMockServiceControllerBinder).createRcsFeature(SLOT_0);
        verify(mMockCallbacks).imsServiceFeatureCreated(eq(SLOT_0), eq(ImsFeature.FEATURE_RCS),
                eq(mTestImsServiceController));
        validateRcsFeatureContainerDoesntExist(SLOT_0);
    }

    /**
     * Ensures ImsService and ImsResolver are notified when a feature is added.
     */