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

Commit 27bf4346 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Add new TelecomManager method to check if a self-mgd app is in a call.

Adding a new method which NotificationManager will use to check if a
VOIP app is currently engaged in any self-managed calls.  Structured to
accept a package name and userhandle rather than a PhoneAccountHandle so
that NotificationManager doesn't need to query all phone account handles
to find the right one to pass in.

NotificationMgr is part of the system service, so this @hide method is
sufficient.  We can consider making this a system API in the future
when we mainline Telecom.

Test: Manual test with Telecom test app to validate method behavior.
Test: Added new unit test to exercise backing functionality for new method.
Bug: 226959797
Change-Id: I74c0568ad2ec308fe50cada7315e3a677363cccc
parent c1f9e4c0
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -2600,6 +2600,33 @@ public class TelecomManager {
        return false;
    }

    /**
     * Determines whether there are any ongoing {@link PhoneAccount#CAPABILITY_SELF_MANAGED}
     * calls for a given {@code packageName} and {@code userHandle}.
     *
     * @param packageName the package name of the app to check calls for.
     * @param userHandle the user handle on which to check for calls.
     * @return {@code true} if there are ongoing calls, {@code false} otherwise.
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    public boolean isInSelfManagedCall(@NonNull String packageName,
            @NonNull UserHandle userHandle) {
        ITelecomService service = getTelecomService();
        if (service != null) {
            try {
                return service.isInSelfManagedCall(packageName, userHandle,
                        mContext.getOpPackageName());
            } catch (RemoteException e) {
                Log.e(TAG, "RemoteException isInSelfManagedCall: " + e);
                e.rethrowFromSystemServer();
                return false;
            }
        } else {
            throw new IllegalStateException("Telecom service is not present");
        }
    }

    /**
     * Handles {@link Intent#ACTION_CALL} intents trampolined from UserCallActivity.
     * @param intent The {@link Intent#ACTION_CALL} intent to handle.
+7 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.telecom.TelecomAnalytics;
import android.telecom.PhoneAccountHandle;
import android.net.Uri;
import android.os.Bundle;
import android.os.UserHandle;
import android.telecom.PhoneAccount;

/**
@@ -374,4 +375,10 @@ interface ITelecomService {
     * @see TelecomServiceImpl#setTestCallDiagnosticService
     */
    void setTestCallDiagnosticService(in String packageName);

    /**
     * @see TelecomServiceImpl#isInSelfManagedCall
     */
    boolean isInSelfManagedCall(String packageName, in UserHandle userHandle,
        String callingPackage);
}