Change permission checks for endCall method.

Allow EITHER MODIFY_PHONE_STATE or ANSWER_PHONE_CALLS permission to use
this API.

Test: Manual test via test app.
Test: Added CTS tests.
Bug: 78290258
Change-Id: Ia5beade115387d0c07550a84aca3f210442e3516
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index 2c00941..ea55e63 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -771,7 +771,9 @@
             try {
                 Log.startSession("TSI.eC");
                 synchronized (mLock) {
-                    enforceModifyPermission();
+                    if (!enforceAnswerCallPermission(callingPackage, Binder.getCallingUid())) {
+                        throw new SecurityException("requires ANSWER_PHONE_CALLS permission");
+                    }
 
                     long token = Binder.clearCallingIdentity();
                     try {