Allow reject request in ANSWERED state

Until the call state is changed to ACTIVE
after user triggers answer,
the call state is ANSWERED.
And at this time, the user can trigger the reject.
However, the reject is possible
only if the call state is RINGING.

So, the reject should be allowed
even when the call state is ANSWERED.

Test: Manual
Bug: 150180636

Change-Id: Ic850531a3a8947ecd2a852c53871d3743caadca2
Signed-off-by: Sungjae <sung_jae.kim@samsung.com>
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 52112b1..d15a503 100755
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -2259,7 +2259,7 @@
                         "reject call failed due to null CS callId=%s", getId());
             }
             Log.addEvent(this, LogUtils.Events.REQUEST_REJECT, reason);
-        } else if (isRinging("reject")) {
+        } else if (isRinging("reject") || isAnswered("reject")) {
             // Ensure video state history tracks video state at time of rejection.
             mVideoStateHistory |= mVideoState;
 
@@ -2291,7 +2291,7 @@
                         "reject call failed due to null CS callId=%s", getId());
             }
             Log.addEvent(this, LogUtils.Events.REQUEST_REJECT);
-        } else if (isRinging("reject")) {
+        } else if (isRinging("reject") || isAnswered("reject")) {
             // Ensure video state history tracks video state at time of rejection.
             mVideoStateHistory |= mVideoState;
 
@@ -2930,6 +2930,18 @@
         return false;
     }
 
+    /**
+     * @return True if the call is answered, else logs the action name.
+     */
+    private boolean isAnswered(String actionName) {
+        if (mState == CallState.ANSWERED) {
+            return true;
+        }
+
+        Log.i(this, "Request to %s a non-answered call %s", actionName, this);
+        return false;
+    }
+
     @SuppressWarnings("rawtypes")
     private void decrementAssociatedCallCount(ServiceBinder binder) {
         if (binder != null) {