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

Commit ef173400 authored by Shuo Qian's avatar Shuo Qian Committed by android-build-merger
Browse files

Merge "Add Call Redirection app into RoleManagerAdapter in Telecom"

am: 6ac9134e

Change-Id: Ia2a1f736f8bc20923c7a3af5f9494d13520c72c7
parents 96a3d2d6 6ac9134e
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -25,6 +25,21 @@ import java.util.List;
 * and remove direct dependencies.
 */
public interface RoleManagerAdapter {
    /**
     * Returns the package name of the app which fills the {@link android.app.role.RoleManager} call
     * redirection role.
     * @return the package name of the app filling the role, {@code null} otherwise}.
     */
    String getDefaultCallRedirectionApp();

    /**
     * Override the {@link android.app.role.RoleManager} call redirection app with another value.
     * Used for testing purposes only.
     * @param packageName Package name of the app to fill the call redirection role.  Where
     *                    {@code null}, the override is removed.
     */
    void setTestDefaultCallRedirectionApp(String packageName);

    /**
     * Returns the package name of the app which fills the {@link android.app.role.RoleManager} call
     * screening role.
+30 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ 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 = "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.
@@ -34,6 +36,7 @@ public class RoleManagerAdapterImpl implements RoleManagerAdapter {
    private static final String ROLE_CALL_COMPANION_APP =
            "android.app.role.ROLE_CALL_COMPANION_APP";

    private String mOverrideDefaultCallRedirectionApp = null;
    private String mOverrideDefaultCallScreeningApp = null;
    private String mOverrideDefaultCarModeApp = null;
    private List<String> mOverrideCallCompanionApps = new ArrayList<>();
@@ -42,6 +45,19 @@ public class RoleManagerAdapterImpl implements RoleManagerAdapter {
    public RoleManagerAdapterImpl() {
    }

    @Override
    public String getDefaultCallRedirectionApp() {
        if (mOverrideDefaultCallRedirectionApp != null) {
            return mOverrideDefaultCallRedirectionApp;
        }
        return getRoleManagerCallRedirectionApp();
    }

    @Override
    public void setTestDefaultCallRedirectionApp(String packageName) {
        mOverrideDefaultCallRedirectionApp = packageName;
    }

    @Override
    public String getDefaultCallScreeningApp() {
        if (mOverrideDefaultCallScreeningApp != null) {
@@ -89,6 +105,11 @@ public class RoleManagerAdapterImpl implements RoleManagerAdapter {
        mCurrentUserHandle = currentUserHandle;
    }

    private String getRoleManagerCallRedirectionApp() {
        // TODO: Link in RoleManager
        return null;
    }

    private String getRoleManagerCallScreeningApp() {
        // TODO: Link in RoleManager
        return null;
@@ -110,6 +131,15 @@ public class RoleManagerAdapterImpl implements RoleManagerAdapter {
     * @param pw The {@code IndentingPrintWriter} to write the state to.
     */
    public void dump(IndentingPrintWriter pw) {
        pw.print("DefaultCallRedirectionApp: ");
        if (mOverrideDefaultCallRedirectionApp != null) {
            pw.print("(override ");
            pw.print(mOverrideDefaultCallRedirectionApp);
            pw.print(") ");
            pw.print(getRoleManagerCallRedirectionApp());
        }
        pw.println();

        pw.print("DefaultCallScreeningApp: ");
        if (mOverrideDefaultCallScreeningApp != null) {
            pw.print("(override ");
+22 −0
Original line number Diff line number Diff line
@@ -1668,6 +1668,28 @@ public class TelecomServiceImpl {
            }
        }

        @Override
        public void setTestDefaultCallRedirectionApp(String packageName) {
            try {
                Log.startSession("TSI.sTDCRA");
                enforceModifyPermission();
                if (!Build.IS_USERDEBUG) {
                    throw new SecurityException("Test-only API.");
                }
                synchronized (mLock) {
                    long token = Binder.clearCallingIdentity();
                    try {
                        mCallsManager.getRoleManagerAdapter().setTestDefaultCallRedirectionApp(
                                packageName);
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                }
            } finally {
                Log.endSession();
            }
        }

        @Override
        public void setTestDefaultCallScreeningApp(String packageName) {
            try {