Fully populate the AccessibilityEvent for the in-call UI.

This is a patch from Svetoslav Ganov <svetoslavganov@google.com> from the
Accessibility team.

Since the "call card" component of the in-call UI has no focusable
elements, that causes the "TalkBack" accessibility feature to ignore some
important info like the name and number of who's calling you :-(

The fix is for the CallCard to manually fill in the AccessibilityEvent
based on the contents of the various onscreen UI elements.

BUG=2375776
TESTED=verified in-call UI is read correctly when TalkBack is enabled.
DRNO=timsullivan
diff --git a/src/com/android/phone/CallCard.java b/src/com/android/phone/CallCard.java
index 766eb72..db5fa01 100755
--- a/src/com/android/phone/CallCard.java
+++ b/src/com/android/phone/CallCard.java
@@ -29,6 +29,7 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
 import android.widget.Button;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
@@ -1434,6 +1435,35 @@
         }
     }
 
+    // Accessibility event support.
+    // Since none of the CallCard elements are focusable, we need to manually
+    // fill in the AccessibilityEvent here (so that the name / number / etc will
+    // get pronounced by a screen reader, for example.)
+    @Override
+    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+        dispatchPopulateAccessibilityEvent(event, mUpperTitle);
+        dispatchPopulateAccessibilityEvent(event, mPhoto);
+        dispatchPopulateAccessibilityEvent(event, mManageConferencePhotoButton);
+        dispatchPopulateAccessibilityEvent(event, mName);
+        dispatchPopulateAccessibilityEvent(event, mPhoneNumber);
+        dispatchPopulateAccessibilityEvent(event, mLabel);
+        dispatchPopulateAccessibilityEvent(event, mSocialStatus);
+        dispatchPopulateAccessibilityEvent(event, mSecondaryCallName);
+        dispatchPopulateAccessibilityEvent(event, mSecondaryCallStatus);
+        dispatchPopulateAccessibilityEvent(event, mSecondaryCallPhoto);
+        return true;
+    }
+
+    private void dispatchPopulateAccessibilityEvent(AccessibilityEvent event, View view) {
+        List<CharSequence> eventText = event.getText();
+        int size = eventText.size();
+        view.dispatchPopulateAccessibilityEvent(event);
+        // if no text added write null to keep relative position
+        if (size == eventText.size()) {
+            eventText.add(null);
+        }
+    }
+
 
     // Debugging / testing code
 
diff --git a/src/com/android/phone/InCallScreen.java b/src/com/android/phone/InCallScreen.java
index 63568d9..1ff2f30 100755
--- a/src/com/android/phone/InCallScreen.java
+++ b/src/com/android/phone/InCallScreen.java
@@ -28,9 +28,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.res.Resources;
-import android.graphics.Shader;
 import android.graphics.Typeface;
-import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.media.AudioManager;
 import android.net.Uri;
@@ -55,10 +53,10 @@
 import android.view.ViewGroup;
 import android.view.Window;
 import android.view.WindowManager;
+import android.view.accessibility.AccessibilityEvent;
 import android.view.animation.Animation;
 import android.view.animation.AnimationUtils;
 import android.widget.EditText;
-import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.SlidingDrawer;
 import android.widget.TextView;
@@ -4910,6 +4908,13 @@
         }
     }
 
+    @Override
+    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+        super.dispatchPopulateAccessibilityEvent(event);
+        mCallCard.dispatchPopulateAccessibilityEvent(event);
+        return true;
+    }
+
     private void log(String msg) {
         Log.d(LOG_TAG, msg);
     }