Merge changes from topic 'mockDelete' into nyc-dev

* changes:
  Using FilteredNumCompat for unblock
  Updating AsyncQueryHandler with FilteredNumCompat
  Implementing Compat class for Filtering
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 9ba4a2b..785d3d3 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -1124,10 +1124,19 @@
 
     public void dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
         if (event.getEventType() == AccessibilityEvent.TYPE_ANNOUNCEMENT) {
-            dispatchPopulateAccessibilityEvent(event, mCallStateLabel);
-            dispatchPopulateAccessibilityEvent(event, mPrimaryName);
-            dispatchPopulateAccessibilityEvent(event, mCallTypeLabel);
-            dispatchPopulateAccessibilityEvent(event, mPhoneNumber);
+            // Indicate this call is in active if no label is provided. The label is empty when
+            // the call is in active, not in other status such as onhold or dialing etc.
+            if (!mCallStateLabel.isShown() || TextUtils.isEmpty(mCallStateLabel.getText())) {
+                event.getText().add(
+                        TextUtils.expandTemplate(
+                                getResources().getText(R.string.accessibility_call_is_active),
+                                mPrimaryName.getText()));
+            } else {
+                dispatchPopulateAccessibilityEvent(event, mCallStateLabel);
+                dispatchPopulateAccessibilityEvent(event, mPrimaryName);
+                dispatchPopulateAccessibilityEvent(event, mCallTypeLabel);
+                dispatchPopulateAccessibilityEvent(event, mPhoneNumber);
+            }
             return;
         }
         dispatchPopulateAccessibilityEvent(event, mCallStateLabel);
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index dd255e0..00835c8 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -337,7 +337,7 @@
         getUi().setEndCallButtonEnabled(shouldShowEndCallButton(mPrimary, callState),
                 callState != Call.State.INCOMING /* animate */);
 
-        maybeSendAccessibilityEvent(oldState, newState);
+        maybeSendAccessibilityEvent(oldState, newState, primaryChanged);
     }
 
     @Override
@@ -697,6 +697,13 @@
             return retval;
         }
 
+        // Sometimes there is intemediate state that two calls are in active even one is about
+        // to be on hold.
+        retval = callList.getSecondActiveCall();
+        if (retval != null && retval != ignore) {
+            return retval;
+        }
+
         // Disconnected calls get primary position if there are no active calls
         // to let user know quickly what call has disconnected. Disconnected
         // calls are very short lived.
@@ -1062,7 +1069,8 @@
         return true;
     }
 
-    private void maybeSendAccessibilityEvent(InCallState oldState, InCallState newState) {
+    private void maybeSendAccessibilityEvent(InCallState oldState, InCallState newState,
+                                             boolean primaryChanged) {
         if (mContext == null) {
             return;
         }
@@ -1071,8 +1079,11 @@
         if (!am.isEnabled()) {
             return;
         }
+        // Announce the current call if it's new incoming/outgoing call or primary call is changed
+        // due to switching calls between two ongoing calls (one is on hold).
         if ((oldState != InCallState.OUTGOING && newState == InCallState.OUTGOING)
-                || (oldState != InCallState.INCOMING && newState == InCallState.INCOMING)) {
+                || (oldState != InCallState.INCOMING && newState == InCallState.INCOMING)
+                || primaryChanged) {
             if (getUi() != null) {
                 getUi().sendAccessibilityAnnouncement();
             }
diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java
index 99def36..d0f3c10 100644
--- a/InCallUI/src/com/android/incallui/CallList.java
+++ b/InCallUI/src/com/android/incallui/CallList.java
@@ -298,6 +298,10 @@
         return getFirstCallWithState(Call.State.ACTIVE);
     }
 
+    public Call getSecondActiveCall() {
+        return getCallWithState(Call.State.ACTIVE, 1);
+    }
+
     public Call getBackgroundCall() {
         return getFirstCallWithState(Call.State.ONHOLD);
     }
diff --git a/InCallUI/src/com/android/incallui/VideoPauseController.java b/InCallUI/src/com/android/incallui/VideoPauseController.java
index a529d20..01b6b0d 100644
--- a/InCallUI/src/com/android/incallui/VideoPauseController.java
+++ b/InCallUI/src/com/android/incallui/VideoPauseController.java
@@ -23,6 +23,8 @@
 import com.android.incallui.InCallVideoCallCallbackNotifier.SessionModificationListener;
 import com.google.common.base.Preconditions;
 
+import android.telecom.VideoProfile;
+
 /**
  * This class is responsible for generating video pause/resume requests when the InCall UI is sent
  * to the background and subsequently brought back to the foreground.
@@ -192,10 +194,11 @@
         Preconditions.checkState(!areSame(call, mPrimaryCallContext));
         final boolean canVideoPause = VideoUtils.canVideoPause(call);
 
-        if ((isIncomingCall(mPrimaryCallContext) || isDialing(mPrimaryCallContext))
+        if ((isIncomingCall(mPrimaryCallContext) || isDialing(mPrimaryCallContext) ||
+                (call != null && VideoProfile.isPaused(call.getVideoState())))
                 && canVideoPause && !mIsInBackground) {
-            // Send resume request for the active call, if user rejects incoming call or ends
-            // dialing call and UI is in the foreground.
+            // Send resume request for the active call, if user rejects incoming call, ends dialing
+            // call, or the call was previously in a paused state and UI is in the foreground.
             sendRequest(call, true);
         } else if (isIncomingCall(call) && canVideoPause(mPrimaryCallContext)) {
             // Send pause request if there is an active video call, and we just received a new
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 734dde8..830af65 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1025,4 +1025,7 @@
 
     <!-- Label under the name of a blocked number in the call log. [CHAR LIMIT=15] -->
     <string name="blocked_number_call_log_label">Blocked</string>
+
+    <!-- Accessibility announcement to indicate which call is active -->
+    <string name="accessibility_call_is_active"><xliff:g id="nameOrNumber">^1</xliff:g> is active</string>
 </resources>