Add video call handling for heads up notifications.

- Add isVideo method to the InCallUI call.
- Added cases and actions for isVideo to StatusBarNotifier.
- Added cases for isVideo for processing incoming call in the
full-screen experience in AnswerPresenter.
- Did what I figured would be some cleanup, to consolidate some
helper methods only ever called once, and reorder some methods
to be more alphabetical.
- Added new intent type for video calls (and revised old one for
audio calls), which are dispatched by the StatusBarNotifier and
received by the InCallApp.
- Update icons used, and deleted unused icons.

Bug: 16013878
Change-Id: If0a8d04e2ee6eaf8258ce6a677b22d55a584f9ab
diff --git a/InCallUI/AndroidManifest.xml b/InCallUI/AndroidManifest.xml
index 1ab6936..62443da 100644
--- a/InCallUI/AndroidManifest.xml
+++ b/InCallUI/AndroidManifest.xml
@@ -60,7 +60,8 @@
         <receiver android:name="InCallApp$NotificationBroadcastReceiver" android:exported="false">
             <intent-filter>
                 <action android:name="com.android.incallui.ACTION_HANG_UP_ONGOING_CALL" />
-                <action android:name="com.android.incallui.ACTION_ANSWER_INCOMING_CALL" />
+                <action android:name="com.android.incallui.ACTION_ANSWER_VIDEO_INCOMING_CALL" />
+                <action android:name="com.android.incallui.ACTION_ANSWER_VOICE_INCOMING_CALL" />
                 <action android:name="com.android.incallui.ACTION_DECLINE_INCOMING_CALL" />
             </intent-filter>
         </receiver>
diff --git a/InCallUI/res/drawable-hdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-hdpi/stat_sys_phone_call.png
deleted file mode 100644
index 7eda84c..0000000
--- a/InCallUI/res/drawable-hdpi/stat_sys_phone_call.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/drawable-hdpi/stat_sys_phone_call_end.png b/InCallUI/res/drawable-hdpi/stat_sys_phone_call_end.png
deleted file mode 100644
index bc74937..0000000
--- a/InCallUI/res/drawable-hdpi/stat_sys_phone_call_end.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/drawable-ldrtl-hdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-ldrtl-hdpi/stat_sys_phone_call.png
deleted file mode 100644
index e0f33f8..0000000
--- a/InCallUI/res/drawable-ldrtl-hdpi/stat_sys_phone_call.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/drawable-ldrtl-mdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-ldrtl-mdpi/stat_sys_phone_call.png
deleted file mode 100644
index d771d87..0000000
--- a/InCallUI/res/drawable-ldrtl-mdpi/stat_sys_phone_call.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/drawable-ldrtl-xhdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-ldrtl-xhdpi/stat_sys_phone_call.png
deleted file mode 100644
index 86af9c2..0000000
--- a/InCallUI/res/drawable-ldrtl-xhdpi/stat_sys_phone_call.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/drawable-mdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-mdpi/stat_sys_phone_call.png
deleted file mode 100644
index 70a4bbe..0000000
--- a/InCallUI/res/drawable-mdpi/stat_sys_phone_call.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/drawable-mdpi/stat_sys_phone_call_end.png b/InCallUI/res/drawable-mdpi/stat_sys_phone_call_end.png
deleted file mode 100644
index 15e7e67..0000000
--- a/InCallUI/res/drawable-mdpi/stat_sys_phone_call_end.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/drawable-xhdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-xhdpi/stat_sys_phone_call.png
deleted file mode 100644
index 1bb4340..0000000
--- a/InCallUI/res/drawable-xhdpi/stat_sys_phone_call.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/drawable-xhdpi/stat_sys_phone_call_end.png b/InCallUI/res/drawable-xhdpi/stat_sys_phone_call_end.png
deleted file mode 100644
index b0b1bc1..0000000
--- a/InCallUI/res/drawable-xhdpi/stat_sys_phone_call_end.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call.png
deleted file mode 100644
index 9348384..0000000
--- a/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call_end.png b/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call_end.png
deleted file mode 100644
index 1f3a81b..0000000
--- a/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call_end.png
+++ /dev/null
Binary files differ
diff --git a/InCallUI/res/values/strings.xml b/InCallUI/res/values/strings.xml
index 3c10302..19ba8a6 100644
--- a/InCallUI/res/values/strings.xml
+++ b/InCallUI/res/values/strings.xml
@@ -211,10 +211,10 @@
          scenarios such as accepting an incoming call or accepting a video call request.
          [CHAR LIMIT=40] -->
     <string name="notification_action_accept">Accept</string>
-    <!-- Label for "Decline" notification action. This is somewhat generic, and may refer to
+    <!-- Label for "Dismiss" notification action. This is somewhat generic, and may refer to
          scenarios such as declining an incoming call or declining a video call request.
          [CHAR LIMIT=40] -->
-    <string name="notification_action_decline">Decline</string>
+    <string name="notification_action_dismiss">Dismiss</string>
 
     <!-- Message for "call back" Action, which is displayed in the missed call notificaiton.
          The user will be able to call back to the person or the phone number.
diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java
index 188fabb..8659454 100644
--- a/InCallUI/src/com/android/incallui/AnswerPresenter.java
+++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java
@@ -93,11 +93,21 @@
         final List<String> textMsgs = CallList.getInstance().getTextResponses(call.getId());
         getUi().showAnswerUi(true);
 
-        if (call.can(CallCapabilities.RESPOND_VIA_TEXT) && textMsgs != null) {
-            getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITH_SMS);
-            getUi().configureMessageDialog(textMsgs);
+        boolean withSms = call.can(CallCapabilities.RESPOND_VIA_TEXT) && textMsgs != null;
+        if (call.isVideoCall()) {
+            if (withSms) {
+                getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITH_SMS);
+                getUi().configureMessageDialog(textMsgs);
+            } else {
+                getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITHOUT_SMS);
+            }
         } else {
-            getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITHOUT_SMS);
+            if (withSms) {
+                getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITH_SMS);
+                getUi().configureMessageDialog(textMsgs);
+            } else {
+                getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITHOUT_SMS);
+            }
         }
     }
 
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java
index 835de2c..6a4ee98 100644
--- a/InCallUI/src/com/android/incallui/Call.java
+++ b/InCallUI/src/com/android/incallui/Call.java
@@ -21,6 +21,7 @@
 import android.telecomm.PhoneAccount;
 import android.telecomm.RemoteCallVideoProvider;
 import android.telecomm.GatewayInfo;
+import android.telecomm.VideoCallProfile;
 import android.telephony.DisconnectCause;
 
 import java.util.ArrayList;
@@ -158,7 +159,6 @@
     private int mDisconnectCause;
     private String mParentCallId;
     private final List<String> mChildCallIds = new ArrayList<>();
-    private int mVideoState;
 
     private InCallVideoClient mCallVideoClient;
 
@@ -322,8 +322,10 @@
         return mParentCallId;
     }
 
-    public int getVideoState() {
-        return mVideoState;
+    public boolean isVideoCall() {
+        int videoState = mTelecommCall.getDetails().getVideoState();
+        return (videoState & VideoCallProfile.VIDEO_STATE_BIDIRECTIONAL)
+                == VideoCallProfile.VIDEO_STATE_BIDIRECTIONAL;
     }
 
     @Override
diff --git a/InCallUI/src/com/android/incallui/InCallApp.java b/InCallUI/src/com/android/incallui/InCallApp.java
index 759f391..77fac7f 100644
--- a/InCallUI/src/com/android/incallui/InCallApp.java
+++ b/InCallUI/src/com/android/incallui/InCallApp.java
@@ -32,12 +32,14 @@
      * choose first ringing call, first active call, or first background call (typically in
      * HOLDING state).
      */
-    public static final String ACTION_HANG_UP_ONGOING_CALL =
-            "com.android.incallui.ACTION_HANG_UP_ONGOING_CALL";
-    public static final String ACTION_ANSWER_INCOMING_CALL =
-            "com.android.incallui.ACTION_ANSWER_INCOMING_CALL";
     public static final String ACTION_DECLINE_INCOMING_CALL =
             "com.android.incallui.ACTION_DECLINE_INCOMING_CALL";
+    public static final String ACTION_HANG_UP_ONGOING_CALL =
+            "com.android.incallui.ACTION_HANG_UP_ONGOING_CALL";
+    public static final String ACTION_ANSWER_VIDEO_INCOMING_CALL =
+            "com.android.incallui.ACTION_ANSWER_VIDEO_INCOMING_CALL";
+    public static final String ACTION_ANSWER_VOICE_INCOMING_CALL =
+            "com.android.incallui.ACTION_ANSWER_VOICE_INCOMING_CALL";
 
     public InCallApp() {
     }
@@ -64,12 +66,15 @@
             Log.i(this, "Broadcast from Notification: " + action);
 
             // TODO: Commands of this nature should exist in the CallList.
-            if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) {
-                InCallPresenter.getInstance().hangUpOngoingCall(context);
-            } else if (action.equals(ACTION_ANSWER_INCOMING_CALL)) {
-                InCallPresenter.getInstance().answerIncomingCall(context);
-            } else if (action.equals(ACTION_DECLINE_INCOMING_CALL)) {
+            if (action.equals(ACTION_DECLINE_INCOMING_CALL)) {
                 InCallPresenter.getInstance().declineIncomingCall(context);
+            } else if (action.equals(ACTION_ANSWER_VOICE_INCOMING_CALL)) {
+                InCallPresenter.getInstance().answerIncomingCall(context);
+            } else if (action.equals(ACTION_ANSWER_VIDEO_INCOMING_CALL)) {
+                //TODO: Answer as a video call here instead of an audio call.
+                InCallPresenter.getInstance().answerIncomingCall(context);
+            } else if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) {
+                InCallPresenter.getInstance().hangUpOngoingCall(context);
             }
         }
     }
diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
index 1208527..f2f883a 100644
--- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java
+++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
@@ -225,21 +225,22 @@
         // it has available, and may make a subsequent call later (same thread) if it had to
         // call into the contacts provider for more data.
         mContactInfoCache.findInfo(call, isIncoming, new ContactInfoCacheCallback() {
-                @Override
-                public void onContactInfoComplete(String callId, ContactCacheEntry entry) {
-                    Call call = CallList.getInstance().getCallById(callId);
-                    if (call != null) {
-                        buildAndSendNotification(call, entry);
-                    }
+            @Override
+            public void onContactInfoComplete(String callId, ContactCacheEntry entry) {
+                Call call = CallList.getInstance().getCallById(callId);
+                if (call != null) {
+                    buildAndSendNotification(call, entry);
                 }
+            }
 
-                @Override
-                public void onImageLoadComplete(String callId, ContactCacheEntry entry) {
-                    Call call = CallList.getInstance().getCallById(callId);
-                    if (call != null) {
-                        buildAndSendNotification(call, entry);
-                    }
-                } });
+            @Override
+            public void onImageLoadComplete(String callId, ContactCacheEntry entry) {
+                Call call = CallList.getInstance().getCallById(callId);
+                if (call != null) {
+                    buildAndSendNotification(call, entry);
+                }
+            }
+        });
     }
 
     /**
@@ -300,12 +301,14 @@
                 state == Call.State.ONHOLD ||
                 Call.State.isDialing(state)) {
             addHangupAction(builder);
-        }
-        // Add answer/decline options for incomng calls (incoming | call_waiting)
-        if (state == Call.State.INCOMING ||
-                state == Call.State.CALL_WAITING) {
-            addDeclineAction(builder);
-            addAnswerAction(builder);
+        } else if (state == Call.State.INCOMING || state == Call.State.CALL_WAITING) {
+            addDismissAction(builder);
+            if (call.isVideoCall()) {
+                addVoiceAction(builder);
+                addVideoCallAction(builder);
+            } else {
+                addAnswerAction(builder);
+            }
         }
 
         addPersonReference(builder, contactInfo, call);
@@ -420,7 +423,7 @@
         if (call.getState() == Call.State.ONHOLD) {
             return R.drawable.stat_sys_phone_call_on_hold;
         }
-        return R.drawable.stat_sys_phone_call;
+        return R.drawable.fab_ic_call;
     }
 
     /**
@@ -459,31 +462,54 @@
         return call;
     }
 
-    private void addHangupAction(Notification.Builder builder) {
-        Log.i(this, "Will show \"hang-up\" action in the ongoing active call Notification");
-
-        // TODO: use better asset.
-        builder.addAction(R.drawable.stat_sys_phone_call_end,
-                mContext.getText(R.string.notification_action_end_call),
-                createHangUpOngoingCallPendingIntent(mContext));
-    }
-
     private void addAnswerAction(Notification.Builder builder) {
         Log.i(this, "Will show \"answer\" action in the incoming call Notification");
 
-        // TODO: use better asset and string
-        builder.addAction(R.drawable.stat_sys_phone_call,
+        PendingIntent answerVoicePendingIntent = createNotificationPendingIntent(
+                mContext, InCallApp.ACTION_ANSWER_VOICE_INCOMING_CALL);
+        builder.addAction(R.drawable.fab_ic_call,
                 mContext.getText(R.string.description_target_answer),
-                createAnswerCallPendingIntent(mContext));
+                answerVoicePendingIntent);
     }
 
-    private void addDeclineAction(Notification.Builder builder) {
-        Log.i(this, "Will show \"decline\" action in the incoming call Notification");
+    private void addDismissAction(Notification.Builder builder) {
+        Log.i(this, "Will show \"dismiss\" action in the incoming call Notification");
 
-        // TODO: use better asset and string
-        builder.addAction(R.drawable.stat_sys_phone_call_end,
-                mContext.getText(R.string.description_target_decline),
-                createDeclineCallPendingIntent(mContext));
+        PendingIntent declinePendingIntent =
+                createNotificationPendingIntent(mContext, InCallApp.ACTION_DECLINE_INCOMING_CALL);
+        builder.addAction(R.drawable.ic_close_dk,
+                mContext.getText(R.string.notification_action_dismiss),
+                declinePendingIntent);
+    }
+
+    private void addHangupAction(Notification.Builder builder) {
+        Log.i(this, "Will show \"hang-up\" action in the ongoing active call Notification");
+
+        PendingIntent hangupPendingIntent =
+                createNotificationPendingIntent(mContext, InCallApp.ACTION_HANG_UP_ONGOING_CALL);
+        builder.addAction(R.drawable.fab_ic_end_call,
+                mContext.getText(R.string.notification_action_end_call),
+                hangupPendingIntent);
+    }
+
+    private void addVideoCallAction(Notification.Builder builder) {
+        Log.i(this, "Will show \"video\" action in the incoming call Notification");
+
+        PendingIntent answerVideoPendingIntent = createNotificationPendingIntent(
+                mContext, InCallApp.ACTION_ANSWER_VIDEO_INCOMING_CALL);
+        builder.addAction(R.drawable.ic_videocam,
+                mContext.getText(R.string.notification_action_answer_video),
+                answerVideoPendingIntent);
+    }
+
+    private void addVoiceAction(Notification.Builder builder) {
+        Log.i(this, "Will show \"voice\" action in the incoming call Notification");
+
+        PendingIntent answerVoicePendingIntent = createNotificationPendingIntent(
+                mContext, InCallApp.ACTION_ANSWER_VOICE_INCOMING_CALL);
+        builder.addAction(R.drawable.fab_ic_call,
+                mContext.getText(R.string.notification_action_answer_voice),
+                answerVoicePendingIntent);
     }
 
     /**
@@ -545,6 +571,7 @@
 
         return builder;
     }
+
     private PendingIntent createLaunchPendingIntent() {
 
         final Intent intent = InCallPresenter.getInstance().getInCallIntent(
@@ -561,30 +588,6 @@
     }
 
     /**
-     * Returns PendingIntent for hanging up ongoing phone call. This will typically be used from
-     * Notification context.
-     */
-    private static PendingIntent createHangUpOngoingCallPendingIntent(Context context) {
-        return createNotificationPendingIntent(context, InCallApp.ACTION_HANG_UP_ONGOING_CALL);
-    }
-
-    /**
-     * Returns PendingIntent for answering a phone call. This will typically be used from
-     * Notification context.
-     */
-    private static PendingIntent createAnswerCallPendingIntent(Context context) {
-        return createNotificationPendingIntent(context, InCallApp.ACTION_ANSWER_INCOMING_CALL);
-    }
-
-    /**
-     * Returns PendingIntent for declining a phone call. This will typically be used from
-     * Notification context.
-     */
-    private static PendingIntent createDeclineCallPendingIntent(Context context) {
-        return createNotificationPendingIntent(context, InCallApp.ACTION_DECLINE_INCOMING_CALL);
-    }
-
-    /**
      * Returns PendingIntent for answering a phone call. This will typically be used from
      * Notification context.
      */