Merge "Add new TelecomManager method to check if a self-mgd app is in a call." into tm-dev

This commit is contained in:
Tyler Gunn
2022-04-04 20:03:08 +00:00
committed by Android (Google) Code Review
2 changed files with 34 additions and 0 deletions

View File

@@ -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.

View File

@@ -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);
}