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

Commit fa7996ea authored by Nadav Bar's avatar Nadav Bar Committed by Hall Liu
Browse files

Fix check for component enabled state in IncallServiceController

Add a check for the component enabled setting, as the previous check only accounted for the state where the component was declared as enabled in the manifest.
This caused the IncallServiceController to skip services that are
disabled in the manifest but enabled in runtime.

Bug: 167677227.
Test: atest TelecomUnitTests:InCallControllerTest
Test: atest CtsTelecomTestCases:NonUiInCallServiceTest
Change-Id: I54053dcf3fa57054befb2e0d654863d11231cab4
parent bd2c250a
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -1523,7 +1523,10 @@ public class InCallController extends CallsManagerListenerBase {
                if (requestedType == IN_CALL_SERVICE_TYPE_NON_UI) {
                    mKnownNonUiInCallServices.add(foundComponentName);
                }
                if (serviceInfo.enabled && (requestedType == 0 || requestedType == currentType)) {
                
                boolean isEnabled = isServiceEnabled(foundComponentName,
                        serviceInfo, packageManager);
                if (isEnabled && (requestedType == 0 || requestedType == currentType)) {
                    retval.add(new InCallServiceInfo(foundComponentName,
                            isExternalCallsSupported, isSelfManageCallsSupported, requestedType));
                }
@@ -1533,6 +1536,21 @@ public class InCallController extends CallsManagerListenerBase {
        return retval;
    }

    private boolean isServiceEnabled(ComponentName componentName,
            ServiceInfo serviceInfo, PackageManager packageManager) {
        int componentEnabledState = packageManager.getComponentEnabledSetting(componentName);

        if (componentEnabledState == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
            return true;
        }

        if (componentEnabledState == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) {
            return serviceInfo.isEnabled();
        }

        return false;
    }

    private boolean shouldUseCarModeUI() {
        return mCarModeTracker.isInCarMode();
    }
+22 −0
Original line number Diff line number Diff line
@@ -1260,6 +1260,28 @@ public class InCallControllerTests extends TelecomTestCase {
            }
        }).when(mMockPackageManager).queryIntentServicesAsUser(
                any(Intent.class), anyInt(), eq(CURRENT_USER_ID));

        if (useDefaultDialer) {
            when(mMockPackageManager
                    .getComponentEnabledSetting(new ComponentName(DEF_PKG, DEF_CLASS)))
                    .thenReturn(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
        }

        when(mMockPackageManager
                .getComponentEnabledSetting(new ComponentName(SYS_PKG, SYS_CLASS)))
                .thenReturn(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);

        when(mMockPackageManager
                .getComponentEnabledSetting(new ComponentName(CAR_PKG, CAR_CLASS)))
                .thenReturn(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);

        when(mMockPackageManager
                .getComponentEnabledSetting(new ComponentName(COMPANION_PKG, COMPANION_CLASS)))
                .thenReturn(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);

        when(mMockPackageManager
                .getComponentEnabledSetting(new ComponentName(CAR2_PKG, CAR2_CLASS)))
                .thenReturn(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
    }

    private void setupMockPackageManagerLocationPermission(final String pkg,