Loading src/com/android/server/telecom/CallsManager.java +22 −5 Original line number Diff line number Diff line Loading @@ -4669,18 +4669,35 @@ public class CallsManager extends Call.ListenerBase } /** * Determines if there are any ongoing self managed calls for the given package/user. * Determines if there are any ongoing self-managed calls for the given package/user. * @param packageName The package name to check. * @param userHandle The userhandle to check. * @param userHandle The {@link UserHandle} to check. * @return {@code true} if the app has ongoing calls, or {@code false} otherwise. */ public boolean isInSelfManagedCall(String packageName, UserHandle userHandle) { return isInSelfManagedCallCrossUsers(packageName, userHandle, false); } /** * Determines if there are any ongoing self-managed calls for the given package/user (unless * hasCrossUsers has been enabled). * @param packageName The package name to check. * @param userHandle The {@link UserHandle} to check. * @param hasCrossUserAccess indicates if calls across all users should be returned. * @return {@code true} if the app has ongoing calls, or {@code false} otherwise. */ public boolean isInSelfManagedCallCrossUsers( String packageName, UserHandle userHandle, boolean hasCrossUserAccess) { return mSelfManagedCallsBeingSetup.stream().anyMatch(c -> c.isSelfManaged() && c.getTargetPhoneAccount().getComponentName().getPackageName().equals(packageName) && c.getTargetPhoneAccount().getUserHandle().equals(userHandle)) || mCalls.stream().anyMatch(c -> c.isSelfManaged() && (!hasCrossUserAccess ? c.getTargetPhoneAccount().getUserHandle().equals(userHandle) : true)) || mCalls.stream().anyMatch(c -> c.isSelfManaged() && c.getTargetPhoneAccount().getComponentName().getPackageName().equals(packageName) && c.getTargetPhoneAccount().getUserHandle().equals(userHandle)); && (!hasCrossUserAccess ? c.getTargetPhoneAccount().getUserHandle().equals(userHandle) : true)); } @VisibleForTesting Loading src/com/android/server/telecom/TelecomServiceImpl.java +4 −5 Original line number Diff line number Diff line Loading @@ -2510,19 +2510,18 @@ public class TelecomServiceImpl { */ @Override public boolean isInSelfManagedCall(String packageName, UserHandle userHandle, String callingPackage) { String callingPackage, boolean hasCrossUserAccess) { try { if (Binder.getCallingUid() != Process.SYSTEM_UID) { throw new SecurityException("Only the system can call this API"); } mContext.enforceCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE, "READ_PRIVILEGED_PHONE_STATE required."); enforceInAppCrossUserPermission(); Log.startSession("TSI.iISMC", Log.getPackageAbbreviation(callingPackage)); synchronized (mLock) { long token = Binder.clearCallingIdentity(); try { return mCallsManager.isInSelfManagedCall(packageName, userHandle); return mCallsManager.isInSelfManagedCallCrossUsers( packageName, userHandle, hasCrossUserAccess); } finally { Binder.restoreCallingIdentity(token); } Loading Loading
src/com/android/server/telecom/CallsManager.java +22 −5 Original line number Diff line number Diff line Loading @@ -4669,18 +4669,35 @@ public class CallsManager extends Call.ListenerBase } /** * Determines if there are any ongoing self managed calls for the given package/user. * Determines if there are any ongoing self-managed calls for the given package/user. * @param packageName The package name to check. * @param userHandle The userhandle to check. * @param userHandle The {@link UserHandle} to check. * @return {@code true} if the app has ongoing calls, or {@code false} otherwise. */ public boolean isInSelfManagedCall(String packageName, UserHandle userHandle) { return isInSelfManagedCallCrossUsers(packageName, userHandle, false); } /** * Determines if there are any ongoing self-managed calls for the given package/user (unless * hasCrossUsers has been enabled). * @param packageName The package name to check. * @param userHandle The {@link UserHandle} to check. * @param hasCrossUserAccess indicates if calls across all users should be returned. * @return {@code true} if the app has ongoing calls, or {@code false} otherwise. */ public boolean isInSelfManagedCallCrossUsers( String packageName, UserHandle userHandle, boolean hasCrossUserAccess) { return mSelfManagedCallsBeingSetup.stream().anyMatch(c -> c.isSelfManaged() && c.getTargetPhoneAccount().getComponentName().getPackageName().equals(packageName) && c.getTargetPhoneAccount().getUserHandle().equals(userHandle)) || mCalls.stream().anyMatch(c -> c.isSelfManaged() && (!hasCrossUserAccess ? c.getTargetPhoneAccount().getUserHandle().equals(userHandle) : true)) || mCalls.stream().anyMatch(c -> c.isSelfManaged() && c.getTargetPhoneAccount().getComponentName().getPackageName().equals(packageName) && c.getTargetPhoneAccount().getUserHandle().equals(userHandle)); && (!hasCrossUserAccess ? c.getTargetPhoneAccount().getUserHandle().equals(userHandle) : true)); } @VisibleForTesting Loading
src/com/android/server/telecom/TelecomServiceImpl.java +4 −5 Original line number Diff line number Diff line Loading @@ -2510,19 +2510,18 @@ public class TelecomServiceImpl { */ @Override public boolean isInSelfManagedCall(String packageName, UserHandle userHandle, String callingPackage) { String callingPackage, boolean hasCrossUserAccess) { try { if (Binder.getCallingUid() != Process.SYSTEM_UID) { throw new SecurityException("Only the system can call this API"); } mContext.enforceCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE, "READ_PRIVILEGED_PHONE_STATE required."); enforceInAppCrossUserPermission(); Log.startSession("TSI.iISMC", Log.getPackageAbbreviation(callingPackage)); synchronized (mLock) { long token = Binder.clearCallingIdentity(); try { return mCallsManager.isInSelfManagedCall(packageName, userHandle); return mCallsManager.isInSelfManagedCallCrossUsers( packageName, userHandle, hasCrossUserAccess); } finally { Binder.restoreCallingIdentity(token); } Loading