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

Commit 99b8cf49 authored by Youming Ye's avatar Youming Ye
Browse files

Changes to RoleManagerAdapterImpl to match roles xml definitions.

Change-Id: I1de7305551f9ce3fc1bdf423bc984f3af7b9621a
Test: CTS
Bug: 78174835
parent 7e070a08
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -1226,7 +1226,8 @@ public class InCallController extends CallsManagerListenerBase {
                        serviceInfo.metaData.getBoolean(
                                TelecomManager.METADATA_INCLUDE_SELF_MANAGED_CALLS, false);

                int currentType = getInCallServiceType(entry.serviceInfo, packageManager);
                int currentType = getInCallServiceType(entry.serviceInfo, packageManager,
                        packageName);
                if (requestedType == 0 || requestedType == currentType) {
                    if (requestedType == IN_CALL_SERVICE_TYPE_NON_UI) {
                        // We enforce the rule that self-managed calls are not supported by non-ui
@@ -1250,7 +1251,8 @@ public class InCallController extends CallsManagerListenerBase {
    /**
     * Returns the type of InCallService described by the specified serviceInfo.
     */
    private int getInCallServiceType(ServiceInfo serviceInfo, PackageManager packageManager) {
    private int getInCallServiceType(ServiceInfo serviceInfo, PackageManager packageManager,
            String packageName) {
        // Verify that the InCallService requires the BIND_INCALL_SERVICE permission which
        // enforces that only Telecom can bind to it.
        boolean hasServiceBindPermission = serviceInfo.permission != null &&
@@ -1268,12 +1270,12 @@ public class InCallController extends CallsManagerListenerBase {
        }

        // Check to see if the service holds permissions or metadata for third party apps.
        boolean hasInCallServiceUIMetadata = serviceInfo.metaData != null &&
                serviceInfo.metaData.containsKey(TelecomManager.METADATA_IN_CALL_SERVICE_UI);
        boolean isUIService = serviceInfo.metaData != null &&
                serviceInfo.metaData.getBoolean(TelecomManager.METADATA_IN_CALL_SERVICE_UI);
        boolean isThirdPartyCompanionApp = packageManager.checkPermission(
                Manifest.permission.CALL_COMPANION_APP,
                serviceInfo.packageName) == PackageManager.PERMISSION_GRANTED &&
                !hasInCallServiceUIMetadata;
                !isUIService;

        // Check to see if the service is a car-mode UI type by checking that it has the
        // CONTROL_INCALL_EXPERIENCE (to verify it is a system app) and that it has the
@@ -1286,16 +1288,17 @@ public class InCallController extends CallsManagerListenerBase {
                        TelecomManager.METADATA_IN_CALL_SERVICE_CAR_MODE_UI, false) &&
                (hasControlInCallPermission || isThirdPartyCompanionApp);
        if (isCarModeUIService) {
            // ThirdPartyInCallService shouldn't be used when role manager hasn't assigned any car
            // mode role holders, i.e. packageName is null.
            if (isUIService || (isThirdPartyCompanionApp && packageName != null)) {
                return IN_CALL_SERVICE_TYPE_CAR_MODE_UI;
            }
        }

        // Check to see that it is the default dialer package
        boolean isDefaultDialerPackage = Objects.equals(serviceInfo.packageName,
                mDefaultDialerCache.getDefaultDialerApplication(
                    mCallsManager.getCurrentUserHandle().getIdentifier()));
        boolean isUIService = serviceInfo.metaData != null &&
                serviceInfo.metaData.getBoolean(
                        TelecomManager.METADATA_IN_CALL_SERVICE_UI, false);
        if (isDefaultDialerPackage && isUIService) {
            return IN_CALL_SERVICE_TYPE_DIALER_UI;
        }
+4 −8
Original line number Diff line number Diff line
@@ -26,15 +26,11 @@ import java.util.List;
import java.util.stream.Collectors;

public class RoleManagerAdapterImpl implements RoleManagerAdapter {
    // TODO: replace with actual role manager const.
    private static final String ROLE_CALL_REDIRECTION_APP = "android.app.role.PROXY_CALLING_APP";
    // TODO: replace with actual role manager const.
    private static final String ROLE_CAR_MODE_DIALER = "android.app.role.ROLE_CAR_MODE_DIALER";
    // TODO: replace with actual role manager const.
    private static final String ROLE_CAR_MODE_DIALER = "android.app.role.CAR_MODE_DIALER_APP";
    private static final String ROLE_CALL_SCREENING = "android.app.role.CALL_SCREENING_APP";
    // TODO: replace with actual role manager const.
    private static final String ROLE_CALL_COMPANION_APP =
            "android.app.role.ROLE_CALL_COMPANION_APP";
            "android.app.role.CALL_COMPANION_APP";

    private String mOverrideDefaultCallRedirectionApp = null;
    private String mOverrideDefaultCallScreeningApp = null;
@@ -165,7 +161,7 @@ public class RoleManagerAdapterImpl implements RoleManagerAdapter {
        pw.println();

        pw.print("DefaultCarModeDialerApp: ");
        if (mOverrideDefaultCallScreeningApp != null) {
        if (mOverrideDefaultCarModeApp != null) {
            pw.print("(override ");
            pw.print(mOverrideDefaultCarModeApp);
            pw.print(") ");
@@ -174,7 +170,7 @@ public class RoleManagerAdapterImpl implements RoleManagerAdapter {
        pw.println();

        pw.print("DefaultCallCompanionApps: ");
        if (mOverrideDefaultCallScreeningApp != null) {
        if (mOverrideCallCompanionApps != null) {
            pw.print("(override ");
            pw.print(mOverrideCallCompanionApps.stream().collect(Collectors.joining(", ")));
            pw.print(") ");