Make TelecomManager#endCall a public API.

A broad category of apps such as wearable companion apps and call blocking
apps rely on the ability to reject a ringing call.
Previously this was achieved using a broken TelephonyManager API which
lacked permission checks.
To support these applications, removing the @hide attribute on the existing
TelecomManager#endCall API so that apps with the existing
ANSWER_PHONE_CALLS permission can reject ringing calls and end ongoing
calls.  Logically if an app has permission to answer a call, it should be
able to end it.

Test: Created test app to verify API permission checks.
Test: Added new CTS tests to cover this API.
Bug: 78290258
Merged-In: Ic6527969793ebe05eb9c5fa8205558ae788ea572
Change-Id: Ic6527969793ebe05eb9c5fa8205558ae788ea572
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 05a3020..99d47aa 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -1291,13 +1291,18 @@
     }
 
     /**
-     * Ends an ongoing call.
-     * TODO: L-release - need to convert all invocations of ITelecomService#endCall to use this
-     * method (clockwork & gearhead).
-     * @hide
+     * Ends the foreground call on the device.
+     * <p>
+     * If there is a ringing call, calling this method rejects the ringing call.  Otherwise the
+     * foreground call is ended.
+     * <p>
+     * Requires permission {@link android.Manifest.permission#ANSWER_PHONE_CALLS}.
+     *
+     * @return {@code true} if there is a call which will be rejected or terminated, {@code false}
+     * otherwise.
      */
+    @RequiresPermission(Manifest.permission.ANSWER_PHONE_CALLS)
     @SystemApi
-    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
     public boolean endCall() {
         try {
             if (isServiceConnected()) {