Merge "IMS: Check ConferDialer config according to subscriptions" into atel.lnx.2.0-dev
diff --git a/Android.mk b/Android.mk
index 16c4adc..c8e950d 100755
--- a/Android.mk
+++ b/Android.mk
@@ -30,6 +30,8 @@
     $(phone_common_dir)/src-N
 
 LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs))
+LOCAL_SRC_FILES += src/org/codeaurora/presenceserv/IPresenceService.aidl \
+                   src/org/codeaurora/presenceserv/IPresenceServiceCB.aidl
 LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs)) \
     $(support_library_root_dir)/v7/cardview/res \
     $(support_library_root_dir)/v7/recyclerview/res \
diff --git a/InCallUI/res/layout/call_button_fragment.xml b/InCallUI/res/layout/call_button_fragment.xml
index 2e9e40b..9e3ec0a 100644
--- a/InCallUI/res/layout/call_button_fragment.xml
+++ b/InCallUI/res/layout/call_button_fragment.xml
@@ -197,6 +197,24 @@
             android:contentDescription="@string/onscreenManageConferenceText"
             android:visibility="gone" />
 
+        <ImageButton android:id="@+id/rxtxVideoCallButton"
+            style="@style/InCallButton"
+            android:background="@drawable/btn_change_to_video"
+            android:contentDescription="@string/overflowBothCallMenuItemText"
+            android:visibility="gone" />
+
+        <ImageButton android:id="@+id/rxVedioCallButton"
+            style="@style/InCallButton"
+            android:background="@drawable/btn_change_to_hm_video"
+            android:contentDescription="@string/overflowRXCallMenuItemText"
+            android:visibility="gone" />
+
+        <ImageButton android:id="@+id/volteCallButton"
+            style="@style/InCallButton"
+            android:background="@drawable/btn_compound_audio"
+            android:contentDescription="@string/overflowVOCallMenuItemText"
+            android:visibility="gone" />
+
     </LinearLayout>
 
 </LinearLayout>
diff --git a/InCallUI/res/layout/primary_call_info.xml b/InCallUI/res/layout/primary_call_info.xml
index 1b6e01c..a9ef075 100644
--- a/InCallUI/res/layout/primary_call_info.xml
+++ b/InCallUI/res/layout/primary_call_info.xml
@@ -137,7 +137,7 @@
 
     <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="@dimen/in_call_layout_height"
         android:orientation="horizontal"
         android:clipChildren="false"
         android:clipToPadding="false">
@@ -145,7 +145,7 @@
         <ImageView android:id="@+id/hdAudioIcon"
             android:src="@drawable/ic_hd_24dp"
             android:layout_width="24dp"
-            android:layout_height="match_parent"
+            android:layout_height="wrap_content"
             android:layout_marginEnd="8dp"
             android:tint="@color/incall_call_banner_subtext_color"
             android:scaleType="fitCenter"
diff --git a/InCallUI/res/layout/video_call_views.xml b/InCallUI/res/layout/video_call_views.xml
index d514f6d..1926fcc 100644
--- a/InCallUI/res/layout/video_call_views.xml
+++ b/InCallUI/res/layout/video_call_views.xml
@@ -20,11 +20,15 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent" >
 
-    <TextureView
-        android:id="@+id/incomingVideo"
-        android:layout_gravity="center"
+    <FrameLayout
         android:layout_width="match_parent"
-        android:layout_height="match_parent" />
+        android:layout_height="match_parent">
+        <TextureView
+            android:id="@+id/incomingVideo"
+            android:layout_gravity="center"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+    </FrameLayout>
     <!-- The width and height are replaced at runtime based on the selected camera. -->
     <FrameLayout
         android:id="@+id/previewVideoContainer"
diff --git a/InCallUI/res/values/array.xml b/InCallUI/res/values/array.xml
index 7877ec8..afd9f55 100644
--- a/InCallUI/res/values/array.xml
+++ b/InCallUI/res/values/array.xml
@@ -132,4 +132,38 @@
         <item>@string/description_direction_left</item>
         <item>@null</item>
     </array>
+
+   <array name="enhance_incoming_call_widget_video_without_sms_targets">
+       <item>@drawable/ic_lockscreen_answer</item>
+       <item>@drawable/ic_enhance_answer_rx_video</item>
+       <item>@drawable/ic_lockscreen_decline</item>
+       <item>@drawable/ic_enhance_answer_video</item>
+   </array>
+   <array name="enhance_incoming_call_widget_video_with_sms_targets">
+       <item>@drawable/ic_enhance_answer_video</item>
+       <item>@drawable/ic_lockscreen_text</item>
+       <item>@drawable/ic_lockscreen_decline</item>
+       <item>@drawable/ic_lockscreen_answer</item>
+       <item>@drawable/ic_enhance_answer_rx_video</item>
+       <item>@null</item>
+   </array>
+   <array name="enhance_incoming_call_widget_video_upgrade_request_targets">
+       <item>@drawable/ic_enhance_answer_video</item>
+       <item>@null</item>
+       <item>@drawable/ic_enhance_decline_video</item>
+       <item>@drawable/ic_enhance_answer_rx_video</item>
+   </array>
+   <array name="enhance_incoming_call_bidirectional_video_accept_request_targets">
+       <item>@drawable/ic_enhance_answer_video</item>
+       <item>@drawable/ic_enhance_decline_video</item>
+   </array>
+   <array name="enhance_incoming_call_video_transmit_accept_request_targets">
+       <item>@drawable/ic_enhance_answer_tx_video</item>
+       <item>@drawable/ic_enhance_decline_video</item>
+   </array>
+   <array name="enhance_incoming_call_video_receive_accept_request_targets">
+       <item>@drawable/ic_enhance_answer_rx_video</item>
+       <item>@drawable/ic_enhance_decline_video</item>
+   </array>
+
 </resources>
diff --git a/InCallUI/res/values/config.xml b/InCallUI/res/values/config.xml
index 1512f6c..763b0e2 100644
--- a/InCallUI/res/values/config.xml
+++ b/InCallUI/res/values/config.xml
@@ -26,4 +26,8 @@
     <integer name="video_call_auto_fullscreen_timeout">5000</integer>
     <!-- When international prefix is enabled in CDMA mode, whether with international prefix -->
     <bool name="phone_number_with_intl_prefix">false</bool>
+
+    <bool name="config_regional_number_patterns_video_call">false</bool>
+     <!-- When set to true, this config enables enhance videocall ui -->
+    <bool name="config_enable_enhance_video_call_ui">false</bool>
 </resources>
diff --git a/InCallUI/res/values/dimens.xml b/InCallUI/res/values/dimens.xml
index 59da786..15520e5 100644
--- a/InCallUI/res/values/dimens.xml
+++ b/InCallUI/res/values/dimens.xml
@@ -63,6 +63,9 @@
     <dimen name="primary_call_elevation">0dp</dimen>
     <dimen name="dialpad_elevation">2dp</dimen>
 
+    <!-- layout height -->
+    <dimen name="in_call_layout_height">40dp</dimen>
+
     <!-- The InCallUI dialpad will sometimes want digits sizes that are different from dialer.
          Note: These are the default sizes for small (<600dp height) devices: larger screen sizes
          apply the values in values-h600dp/dimens.xml. -->
diff --git a/InCallUI/res/values/qtistrings.xml b/InCallUI/res/values/qtistrings.xml
index 203286d..ea8a952 100644
--- a/InCallUI/res/values/qtistrings.xml
+++ b/InCallUI/res/values/qtistrings.xml
@@ -177,4 +177,7 @@
     <string-array name="international_idp_values" translatable="false">
         <item>"0033"</item>
     </string-array>
+    <string name="video_call_downgrade_without_lte_toast">Move out of LTE coverage area downgrade the call.</string>
+    <string name="video_call">Video Calling</string>
+    <string name="video_call_cannot_upgrade">cannot accept video calls at this time</string>
 </resources>
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java
index d7289a2..db597b2 100644
--- a/InCallUI/src/com/android/incallui/CallButtonFragment.java
+++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java
@@ -33,6 +33,9 @@
 import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_TRANSFER_CONSULTATIVE;
 import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_UPGRADE_TO_VIDEO;
 import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_RECORD;
+import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_RXTX_VIDEO_CALL;
+import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_RX_VIDEO_CALL;
+import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_VO_VIDEO_CALL;
 
 import android.content.Context;
 import android.content.res.ColorStateList;
@@ -44,6 +47,8 @@
 import android.graphics.drawable.StateListDrawable;
 import android.os.Bundle;
 import android.telecom.CallAudioState;
+import android.telecom.VideoProfile;
+import android.telephony.PhoneNumberUtils;
 import android.util.SparseIntArray;
 import android.view.ContextThemeWrapper;
 import android.view.HapticFeedbackConstants;
@@ -57,7 +62,9 @@
 import android.widget.PopupMenu;
 import android.widget.PopupMenu.OnDismissListener;
 import android.widget.PopupMenu.OnMenuItemClickListener;
+import android.widget.Toast;
 
+import com.android.contacts.common.CallUtil;
 import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
 import com.android.dialer.R;
 
@@ -98,7 +105,10 @@
         public static final int BUTTON_TRANSFER_ASSURED = 13;
         public static final int BUTTON_TRANSFER_CONSULTATIVE = 14;
         public static final int BUTTON_RECORD = 15;
-        public static final int BUTTON_COUNT = 16;
+        public static final int BUTTON_RXTX_VIDEO_CALL = 16;
+        public static final int BUTTON_RX_VIDEO_CALL = 17;
+        public static final int BUTTON_VO_VIDEO_CALL = 18;
+        public static final int BUTTON_COUNT = 19;
     }
 
     private SparseIntArray mButtonVisibilityMap = new SparseIntArray(BUTTON_COUNT);
@@ -121,6 +131,9 @@
     private ImageButton mConsultativeTransferButton;
     private ImageButton mAddParticipantButton;
     private ImageButton mRecordButton;
+    private ImageButton mRxTxVideoCallButton;
+    private ImageButton mRxVideoCallButton;
+    private ImageButton mVoVideoCallButton;
 
     private PopupMenu mAudioModePopup;
     private boolean mAudioModePopupVisible;
@@ -199,6 +212,12 @@
         mManageVideoCallConferenceButton.setOnClickListener(this);
         mRecordButton = (ImageButton) parent.findViewById(R.id.recordButton);
         mRecordButton.setOnClickListener(this);
+        mRxTxVideoCallButton = (ImageButton) parent.findViewById(R.id.rxtxVideoCallButton);
+        mRxTxVideoCallButton.setOnClickListener(this);
+        mRxVideoCallButton = (ImageButton) parent.findViewById(R.id.rxVedioCallButton);
+        mRxVideoCallButton.setOnClickListener(this);
+        mVoVideoCallButton = (ImageButton) parent.findViewById(R.id.volteCallButton);
+        mVoVideoCallButton.setOnClickListener(this);
         return parent;
     }
 
@@ -273,6 +292,12 @@
                 ((InCallActivity) getActivity()).stopInCallRecorder();
                 mRecordButton.setBackgroundResource(R.drawable.btn_start_record);
             }
+        } else if(id == R.id.rxtxVideoCallButton){
+            getPresenter().changeToVideo(VideoProfile.STATE_BIDIRECTIONAL);
+        } else if(id == R.id.rxVedioCallButton){
+            getPresenter().changeToVideo(VideoProfile.STATE_RX_ENABLED);
+        } else if(id == R.id.volteCallButton){
+            getPresenter().changeToVideo(VideoProfile.STATE_AUDIO_ONLY);
         } else {
             Log.wtf(this, "onClick: unexpected");
             return;
@@ -430,6 +455,9 @@
         mManageVideoCallConferenceButton.setEnabled(isEnabled);
         mAddParticipantButton.setEnabled(isEnabled);
         mRecordButton.setEnabled(isEnabled);
+        mRxTxVideoCallButton.setEnabled(isEnabled);
+        mRxVideoCallButton.setEnabled(isEnabled);
+        mVoVideoCallButton.setEnabled(isEnabled);
     }
 
     @Override
@@ -478,6 +506,12 @@
             return mConsultativeTransferButton;
         } else if (id == BUTTON_RECORD) {
             return mRecordButton;
+        } else if (id == BUTTON_RXTX_VIDEO_CALL) {
+            return mRxTxVideoCallButton;
+        } else if (id == BUTTON_RX_VIDEO_CALL) {
+            return mRxVideoCallButton;
+        } else if (id == BUTTON_VO_VIDEO_CALL) {
+            return mVoVideoCallButton;
         } else {
             Log.w(this, "Invalid button id");
             return null;
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index 7f8e171..d21cab5 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -31,6 +31,9 @@
 import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_TRANSFER_CONSULTATIVE;
 import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_UPGRADE_TO_VIDEO;
 import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_RECORD;
+import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_RXTX_VIDEO_CALL;
+import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_RX_VIDEO_CALL;
+import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_VO_VIDEO_CALL;
 
 import android.content.Context;
 import android.os.Build;
@@ -44,6 +47,7 @@
 
 import com.android.contacts.common.compat.CallSdkCompat;
 import com.android.contacts.common.compat.SdkVersionOverride;
+import com.android.dialer.util.PresenceHelper;
 import com.android.dialer.compat.UserManagerCompat;
 import com.android.incallui.AudioModeProvider.AudioModeListener;
 import com.android.incallui.InCallCameraManager.Listener;
@@ -69,6 +73,7 @@
     private boolean mAutomaticallyMuted = false;
     private boolean mPreviousMuteState = false;
     private static final int MAX_PARTICIPANTS_LIMIT = 6;
+    private boolean mEnhanceEnable = false;
 
     // NOTE: Capability constant definition has been duplicated to avoid bundling
     // the Dialer with Frameworks.
@@ -81,6 +86,8 @@
     public void onUiReady(CallButtonUi ui) {
         super.onUiReady(ui);
 
+        mEnhanceEnable = ui.getContext().getResources().getBoolean(
+                R.bool.config_enable_enhance_video_call_ui);
         AudioModeProvider.getInstance().addListener(this);
 
         // register for call state changes last
@@ -335,6 +342,21 @@
         mCall.setSessionModificationState(Call.SessionModificationState.WAITING_FOR_RESPONSE);
     }
 
+    public void changeToVideo(int videoState) {
+        if(mCall == null) {
+            return;
+        }
+
+        if(VideoProfile.isVideo(videoState) &&
+                !PresenceHelper.getVTCapability(mCall.getNumber())) {
+            Context context = getUi().getContext();
+            Toast.makeText(context,context.getString(R.string.video_call_cannot_upgrade),
+                    Toast.LENGTH_SHORT).show();
+            return;
+        }
+        final VideoProfile videoProfile = new VideoProfile(videoState);
+        QtiCallUtils.changeToVideoCall(mCall, videoProfile);
+    }
     /**
      * Switches the camera between the front-facing and back-facing camera.
      * @param useFrontFacingCamera True if we should switch to using the front-facing camera, or
@@ -478,19 +500,33 @@
             showAddParticipant = showAddParticipant&&(call.isConferenceCall());
         }
 
+        boolean showRxTx = false;
+        boolean showRx = false;
+        boolean showVolte = false;
+
+        if (mEnhanceEnable && showUpgradeToVideo) {
+            boolean isAudioAndVtCap = (VideoProfile.isAudioOnly(mCall.getVideoState()) &&
+                    PresenceHelper.getVTCapability(call.getNumber()));
+            showRxTx = (VideoProfile.isReceptionEnabled(mCall.getVideoState()) || isAudioAndVtCap);
+            showRx = (VideoProfile.isBidirectional(mCall.getVideoState()) || isAudioAndVtCap);
+            showVolte = VideoProfile.isVideo(mCall.getVideoState());
+            Log.v(this, "updateButtonsState showRxTx = " + showRxTx +
+                    " showRx" + showRx + " showVolte = " + showVolte);
+        }
+
         ui.showButton(BUTTON_AUDIO, true);
         ui.showButton(BUTTON_SWAP, showSwap);
         ui.showButton(BUTTON_HOLD, showHold);
         ui.setHold(isCallOnHold);
         ui.showButton(BUTTON_MUTE, showMute);
         ui.showButton(BUTTON_ADD_CALL, showAddCall);
-        ui.showButton(BUTTON_UPGRADE_TO_VIDEO, showUpgradeToVideo);
+        ui.showButton(BUTTON_UPGRADE_TO_VIDEO, showUpgradeToVideo && !mEnhanceEnable);
         ui.showButton(BUTTON_DOWNGRADE_TO_AUDIO, showDowngradeToAudio && !useExt);
         ui.showButton(BUTTON_SWITCH_CAMERA, isVideo);
         ui.showButton(BUTTON_PAUSE_VIDEO, isVideo && !useExt);
         ui.showButton(BUTTON_DIALPAD, true);
         ui.showButton(BUTTON_MERGE, showMerge);
-        ui.enableAddParticipant(showAddParticipant);
+        ui.enableAddParticipant(showAddParticipant && !mEnhanceEnable);
 
         ui.showButton(BUTTON_RECORD, showRecord);
         /* Depending on the transfer capabilities, display the corresponding buttons */
@@ -507,6 +543,12 @@
             ui.showButton(BUTTON_TRANSFER_ASSURED, false);
             ui.showButton(BUTTON_TRANSFER_CONSULTATIVE, false);
         }
+        if (mEnhanceEnable) {
+            Log.v(this, "Add three new buttons");
+            ui.showButton(BUTTON_RXTX_VIDEO_CALL, showRxTx);
+            ui.showButton(BUTTON_RX_VIDEO_CALL, showRx);
+            ui.showButton(BUTTON_VO_VIDEO_CALL, showVolte);
+        }
 
         ui.updateButtonStates();
     }
diff --git a/InCallUI/src/com/android/incallui/GlowPadAnswerFragment.java b/InCallUI/src/com/android/incallui/GlowPadAnswerFragment.java
index 48e4730..d9b4dda 100644
--- a/InCallUI/src/com/android/incallui/GlowPadAnswerFragment.java
+++ b/InCallUI/src/com/android/incallui/GlowPadAnswerFragment.java
@@ -91,6 +91,8 @@
         final int directionDescriptionsResourceId;
         final int handleDrawableResourceId;
         mGlowpad.setVideoState(videoState);
+        final boolean isEnhanceUIEnabled = getContext().getResources().getBoolean(
+                R.bool.config_enable_enhance_video_call_ui);
 
         switch (targetSet) {
             case TARGET_SET_FOR_AUDIO_WITH_SMS:
@@ -127,7 +129,12 @@
                 handleDrawableResourceId = R.drawable.ic_incall_video_handle;
                 break;
             case TARGET_SET_FOR_QTI_VIDEO_WITHOUT_SMS:
-                targetResourceId = R.array.qti_incoming_call_widget_video_without_sms_targets;
+                if (isEnhanceUIEnabled) {
+                    targetResourceId =
+                            R.array.enhance_incoming_call_widget_video_without_sms_targets;
+                } else {
+                    targetResourceId = R.array.qti_incoming_call_widget_video_without_sms_targets;
+                }
                 targetDescriptionsResourceId =
                         R.array.qti_incoming_call_widget_video_without_sms_target_descriptions;
                 directionDescriptionsResourceId =
@@ -135,7 +142,11 @@
                 handleDrawableResourceId = R.drawable.ic_incall_video_handle;
                 break;
             case TARGET_SET_FOR_QTI_VIDEO_WITH_SMS:
-                targetResourceId = R.array.qti_incoming_call_widget_video_with_sms_targets;
+                if (isEnhanceUIEnabled) {
+                    targetResourceId = R.array.enhance_incoming_call_widget_video_with_sms_targets;
+                } else {
+                    targetResourceId = R.array.qti_incoming_call_widget_video_with_sms_targets;
+                }
                 targetDescriptionsResourceId =
                         R.array.qti_incoming_call_widget_video_with_sms_target_descriptions;
                 directionDescriptionsResourceId =
@@ -179,7 +190,12 @@
                 handleDrawableResourceId = R.drawable.ic_incall_video_handle;
                 break;
             case TARGET_SET_FOR_QTI_VIDEO_ACCEPT_REJECT_REQUEST:
-                targetResourceId = R.array.qti_incoming_call_widget_video_request_targets;
+                if (isEnhanceUIEnabled) {
+                    targetResourceId =
+                            R.array.enhance_incoming_call_widget_video_upgrade_request_targets;
+                } else {
+                    targetResourceId = R.array.qti_incoming_call_widget_video_request_targets;
+                }
                 targetDescriptionsResourceId =
                         R.array.qti_incoming_call_widget_video_request_target_descriptions;
                 directionDescriptionsResourceId = R.array.
@@ -187,8 +203,13 @@
                 handleDrawableResourceId = R.drawable.ic_incall_video_handle;
                 break;
             case TARGET_SET_FOR_QTI_BIDIRECTIONAL_VIDEO_ACCEPT_REJECT_REQUEST:
-                targetResourceId = R.array.
+                if (isEnhanceUIEnabled) {
+                    targetResourceId = R.array.
+                        enhance_incoming_call_bidirectional_video_accept_request_targets;
+                } else {
+                    targetResourceId = R.array.
                         qti_incoming_call_widget_bidirectional_video_accept_reject_request_targets;
+                }
                 targetDescriptionsResourceId =
                         R.array.qti_incoming_call_widget_video_request_target_descriptions;
                 directionDescriptionsResourceId = R.array.
@@ -196,8 +217,13 @@
                 handleDrawableResourceId = R.drawable.ic_incall_video_handle;
                 break;
             case TARGET_SET_FOR_QTI_VIDEO_TRANSMIT_ACCEPT_REJECT_REQUEST:
-                targetResourceId = R.array.
-                        qti_incoming_call_widget_video_transmit_accept_reject_request_targets;
+                if (isEnhanceUIEnabled) {
+                    targetResourceId =
+                            R.array.enhance_incoming_call_video_transmit_accept_request_targets;
+                } else {
+                    targetResourceId = R.array.
+                           qti_incoming_call_widget_video_transmit_accept_reject_request_targets;
+                }
                 targetDescriptionsResourceId = R.array.
                         qti_incoming_call_widget_video_transmit_request_target_descriptions;
                 directionDescriptionsResourceId = R.array
@@ -205,8 +231,13 @@
                 handleDrawableResourceId = R.drawable.ic_incall_video_handle;
                 break;
             case TARGET_SET_FOR_QTI_VIDEO_RECEIVE_ACCEPT_REJECT_REQUEST:
-                targetResourceId = R.array.
-                        qti_incoming_call_widget_video_receive_accept_reject_request_targets;
+                if (isEnhanceUIEnabled) {
+                    targetResourceId = R.array.
+                            enhance_incoming_call_video_receive_accept_request_targets;
+                } else {
+                    targetResourceId = R.array.
+                            qti_incoming_call_widget_video_receive_accept_reject_request_targets;
+                }
                 targetDescriptionsResourceId =
                         R.array.qti_incoming_call_widget_video_receive_request_target_descriptions;
                 directionDescriptionsResourceId = R.array
diff --git a/InCallUI/src/com/android/incallui/GlowPadWrapper.java b/InCallUI/src/com/android/incallui/GlowPadWrapper.java
index bc2d4da..c88a984 100644
--- a/InCallUI/src/com/android/incallui/GlowPadWrapper.java
+++ b/InCallUI/src/com/android/incallui/GlowPadWrapper.java
@@ -115,22 +115,27 @@
         if (resId == R.drawable.ic_lockscreen_answer) {
             mAnswerFragment.onAnswer(VideoProfile.STATE_AUDIO_ONLY, getContext());
             mTargetTriggered = true;
-        } else if (resId == R.drawable.ic_lockscreen_decline) {
+        } else if (resId == R.drawable.ic_lockscreen_decline ||
+                resId == R.drawable.ic_enhance_decline_video) {
             mAnswerFragment.onDecline(getContext());
             mTargetTriggered = true;
         } else if (resId == R.drawable.ic_lockscreen_text) {
             mAnswerFragment.onText();
             mTargetTriggered = true;
-        } else if (resId == R.drawable.ic_videocam || resId == R.drawable.ic_lockscreen_answer_video) {
+        } else if (resId == R.drawable.ic_videocam ||
+                resId == R.drawable.ic_lockscreen_answer_video ||
+                resId == R.drawable.ic_enhance_answer_video) {
             mAnswerFragment.onAnswer(mVideoState, getContext());
             mTargetTriggered = true;
         } else if (resId == R.drawable.ic_lockscreen_decline_video) {
             mAnswerFragment.onDeclineUpgradeRequest(getContext());
             mTargetTriggered = true;
-        } else if (resId == R.drawable.qti_ic_lockscreen_answer_tx_video) {
+        } else if (resId == R.drawable.qti_ic_lockscreen_answer_tx_video ||
+                resId == R.drawable.ic_enhance_answer_tx_video) {
             mAnswerFragment.onAnswer(VideoProfile.STATE_TX_ENABLED, getContext());
             mTargetTriggered = true;
-        } else if (resId == R.drawable.qti_ic_lockscreen_answer_rx_video) {
+        } else if (resId == R.drawable.qti_ic_lockscreen_answer_rx_video ||
+                resId == R.drawable.ic_enhance_answer_rx_video) {
             mAnswerFragment.onAnswer(VideoProfile.STATE_RX_ENABLED, getContext());
             mTargetTriggered = true;
         } else if (resId == R.drawable.qti_ic_lockscreen_deflect) {
diff --git a/InCallUI/src/com/android/incallui/QtiCallUtils.java b/InCallUI/src/com/android/incallui/QtiCallUtils.java
index d6085b5..f3a88f1 100644
--- a/InCallUI/src/com/android/incallui/QtiCallUtils.java
+++ b/InCallUI/src/com/android/incallui/QtiCallUtils.java
@@ -193,6 +193,9 @@
         alert.show();
     }
 
+    public static void changeToVideoCall(Call call, VideoProfile videoProfile) {
+            changeToVideoClicked(call, videoProfile);
+    }
     /**
      * Converts the call type to string
      */
diff --git a/res/drawable-hdpi/ic_hm_videocam.png b/res/drawable-hdpi/ic_hm_videocam.png
new file mode 100644
index 0000000..f80c2f3
--- /dev/null
+++ b/res/drawable-hdpi/ic_hm_videocam.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_m_videocam.png b/res/drawable-hdpi/ic_m_videocam.png
new file mode 100644
index 0000000..7724a8d
--- /dev/null
+++ b/res/drawable-hdpi/ic_m_videocam.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_videocam_off.png b/res/drawable-hdpi/ic_videocam_off.png
new file mode 100644
index 0000000..f59144c
--- /dev/null
+++ b/res/drawable-hdpi/ic_videocam_off.png
Binary files differ
diff --git a/res/drawable/btn_change_to_hm_video.xml b/res/drawable/btn_change_to_hm_video.xml
new file mode 100644
index 0000000..af23bc2
--- /dev/null
+++ b/res/drawable/btn_change_to_hm_video.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2016, The Linux Foundation. All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:id="@+id/backgroundItem"
+          android:drawable="@drawable/btn_background" />
+
+    <item>
+        <bitmap android:src="@drawable/ic_hm_videocam"
+            android:gravity="center"
+            android:tint="@color/selectable_icon_tint"
+            android:autoMirrored="true" />
+    </item>
+
+</layer-list>
diff --git a/res/drawable/ic_enhance_answer_rx_video.xml b/res/drawable/ic_enhance_answer_rx_video.xml
new file mode 100644
index 0000000..0dedbcb
--- /dev/null
+++ b/res/drawable/ic_enhance_answer_rx_video.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<!-- Used with incoming call wigdet. -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:state_enabled="true" android:state_active="false" android:state_focused="false"
+        android:drawable="@drawable/ic_enhance_answer_rx_video_normal_layer"/>
+    <item
+        android:state_enabled="true" android:state_active="true"  android:state_focused="false"
+        android:drawable="@drawable/ic_enhance_answer_rx_video_activated_layer" />
+    <item
+        android:state_enabled="true" android:state_active="false"  android:state_focused="true"
+        android:drawable="@drawable/ic_enhance_answer_rx_video_activated_layer" />
+</selector>
diff --git a/res/drawable/ic_enhance_answer_rx_video_activated_layer.xml b/res/drawable/ic_enhance_answer_rx_video_activated_layer.xml
new file mode 100644
index 0000000..e0e19d5
--- /dev/null
+++ b/res/drawable/ic_enhance_answer_rx_video_activated_layer.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/fab_blue" />
+    <item>
+        <bitmap
+            android:gravity="center"
+            android:src="@drawable/ic_hm_videocam"
+            android:tint="@color/glowpad_widget_active_color"
+            android:autoMirrored="true" />
+    </item>
+</layer-list>
diff --git a/res/drawable/ic_enhance_answer_rx_video_normal_layer.xml b/res/drawable/ic_enhance_answer_rx_video_normal_layer.xml
new file mode 100644
index 0000000..2d49b1d
--- /dev/null
+++ b/res/drawable/ic_enhance_answer_rx_video_normal_layer.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- A fake circle to fix the size of this layer asset. -->
+    <item>
+        <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
+            <solid android:color="#00000000"/>
+            <size
+                android:width="@dimen/incoming_call_widget_circle_size"
+                android:height="@dimen/incoming_call_widget_circle_size" />
+        </shape>
+    </item>
+    <item>
+        <bitmap
+            android:gravity="center"
+            android:src="@drawable/ic_hm_videocam"
+            android:tint="@color/glowpad_call_widget_normal_tint"
+            android:autoMirrored="true" />
+    </item>
+</layer-list>
diff --git a/res/drawable/ic_enhance_answer_tx_video.xml b/res/drawable/ic_enhance_answer_tx_video.xml
new file mode 100644
index 0000000..33ba0e1
--- /dev/null
+++ b/res/drawable/ic_enhance_answer_tx_video.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<!-- Used with incoming call wigdet. -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:state_enabled="true" android:state_active="false" android:state_focused="false"
+        android:drawable="@drawable/ic_enhance_answer_tx_video_normal_layer"/>
+    <item
+        android:state_enabled="true" android:state_active="true"  android:state_focused="false"
+        android:drawable="@drawable/ic_enhance_answer_tx_video_activated_layer" />
+    <item
+        android:state_enabled="true" android:state_active="false"  android:state_focused="true"
+        android:drawable="@drawable/ic_enhance_answer_tx_video_activated_layer" />
+</selector>
diff --git a/res/drawable/ic_enhance_answer_tx_video_activated_layer.xml b/res/drawable/ic_enhance_answer_tx_video_activated_layer.xml
new file mode 100644
index 0000000..76e04e9
--- /dev/null
+++ b/res/drawable/ic_enhance_answer_tx_video_activated_layer.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/fab_blue" />
+    <item>
+        <bitmap
+            android:gravity="center"
+            android:src="@drawable/ic_m_videocam"
+            android:tint="@color/glowpad_widget_active_color"
+            android:autoMirrored="true" />
+    </item>
+</layer-list>
diff --git a/res/drawable/ic_enhance_answer_tx_video_normal_layer.xml b/res/drawable/ic_enhance_answer_tx_video_normal_layer.xml
new file mode 100644
index 0000000..95d6c81
--- /dev/null
+++ b/res/drawable/ic_enhance_answer_tx_video_normal_layer.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- A fake circle to fix the size of this layer asset. -->
+    <item>
+        <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
+            <solid android:color="#00000000"/>
+            <size
+                android:width="@dimen/incoming_call_widget_circle_size"
+                android:height="@dimen/incoming_call_widget_circle_size" />
+        </shape>
+    </item>
+    <item>
+        <bitmap
+            android:gravity="center"
+            android:src="@drawable/ic_m_videocam"
+            android:tint="@color/glowpad_call_widget_normal_tint"
+            android:autoMirrored="true" />
+    </item>
+</layer-list>
diff --git a/res/drawable/ic_enhance_answer_video.xml b/res/drawable/ic_enhance_answer_video.xml
new file mode 100644
index 0000000..a79cd97
--- /dev/null
+++ b/res/drawable/ic_enhance_answer_video.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<!-- Used with incoming call wigdet. -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:state_enabled="true" android:state_active="false" android:state_focused="false"
+        android:drawable="@drawable/ic_enhance_answer_video_normal_layer"/>
+    <item
+        android:state_enabled="true" android:state_active="true"  android:state_focused="false"
+        android:drawable="@drawable/ic_enhance_answer_video_activated_layer" />
+   <item
+        android:state_enabled="true" android:state_active="false"  android:state_focused="true"
+        android:drawable="@drawable/ic_enhance_answer_video_activated_layer" />
+</selector>
diff --git a/res/drawable/ic_enhance_answer_video_activated_layer.xml b/res/drawable/ic_enhance_answer_video_activated_layer.xml
new file mode 100644
index 0000000..76e04e9
--- /dev/null
+++ b/res/drawable/ic_enhance_answer_video_activated_layer.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/fab_blue" />
+    <item>
+        <bitmap
+            android:gravity="center"
+            android:src="@drawable/ic_m_videocam"
+            android:tint="@color/glowpad_widget_active_color"
+            android:autoMirrored="true" />
+    </item>
+</layer-list>
diff --git a/res/drawable/ic_enhance_answer_video_normal_layer.xml b/res/drawable/ic_enhance_answer_video_normal_layer.xml
new file mode 100644
index 0000000..95d6c81
--- /dev/null
+++ b/res/drawable/ic_enhance_answer_video_normal_layer.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- A fake circle to fix the size of this layer asset. -->
+    <item>
+        <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
+            <solid android:color="#00000000"/>
+            <size
+                android:width="@dimen/incoming_call_widget_circle_size"
+                android:height="@dimen/incoming_call_widget_circle_size" />
+        </shape>
+    </item>
+    <item>
+        <bitmap
+            android:gravity="center"
+            android:src="@drawable/ic_m_videocam"
+            android:tint="@color/glowpad_call_widget_normal_tint"
+            android:autoMirrored="true" />
+    </item>
+</layer-list>
diff --git a/res/drawable/ic_enhance_decline_video.xml b/res/drawable/ic_enhance_decline_video.xml
new file mode 100644
index 0000000..854f7a2
--- /dev/null
+++ b/res/drawable/ic_enhance_decline_video.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<!-- Used with incoming call wigdet. -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:state_enabled="true" android:state_active="false" android:state_focused="false"
+        android:drawable="@drawable/ic_enhance_decline_video_normal_layer"/>
+    <item
+        android:state_enabled="true" android:state_active="true"  android:state_focused="false"
+        android:drawable="@drawable/ic_enhance_decline_video_activated_layer" />
+   <item
+        android:state_enabled="true" android:state_active="false"  android:state_focused="true"
+        android:drawable="@drawable/ic_enhance_decline_video_activated_layer" />
+</selector>
diff --git a/res/drawable/ic_enhance_decline_video_activated_layer.xml b/res/drawable/ic_enhance_decline_video_activated_layer.xml
new file mode 100644
index 0000000..074fe95
--- /dev/null
+++ b/res/drawable/ic_enhance_decline_video_activated_layer.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/fab_red" />
+    <item>
+        <bitmap
+            android:gravity="center"
+            android:src="@drawable/ic_videocam_off"
+            android:tint="#ffffff"
+            android:autoMirrored="true" />
+    </item>
+</layer-list>
diff --git a/res/drawable/ic_enhance_decline_video_normal_layer.xml b/res/drawable/ic_enhance_decline_video_normal_layer.xml
new file mode 100644
index 0000000..30c7d9c
--- /dev/null
+++ b/res/drawable/ic_enhance_decline_video_normal_layer.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- A fake circle to fix the size of this layer asset. -->
+    <item>
+        <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
+            <solid android:color="#00000000"/>
+            <size
+                android:width="56dp"
+                android:height="56dp" />
+        </shape>
+    </item>
+    <item>
+        <bitmap
+            android:gravity="center"
+            android:src="@drawable/ic_videocam_off"
+            android:tint="#0288d1"
+            android:autoMirrored="true" />
+    </item>
+</layer-list>
diff --git a/res/values-zh-rCN/qtistrings.xml b/res/values-zh-rCN/qtistrings.xml
new file mode 100644
index 0000000..25f18c0
--- /dev/null
+++ b/res/values-zh-rCN/qtistrings.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
+  ~
+  ~ Redistribution and use in source and binary forms, with or without
+  ~ modification, are permitted provided that the following conditions are
+  ~ met:
+  ~      Redistributions of source code must retain the above copyright
+  ~       notice, this list of conditions and the following disclaimer.
+  ~      Redistributions in binary form must reproduce the above
+  ~       copyright notice, this list of conditions and the following
+  ~       disclaimer in the documentation and/or other materials provided
+  ~       with the distribution.
+  ~      Neither the name of The Linux Foundation nor the names of its
+  ~       contributors may be used to endorse or promote products derived
+  ~       from this software without specific prior written permission.
+  ~
+  ~ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+  ~ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+  ~ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+  ~ ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+  ~ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+  ~ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+  ~ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+  ~ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+  ~ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+  ~ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+  ~ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  ~
+  -->
+
+<!-- The xml contains Qti specific resource strings neede for any value added features. -->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="video_call_upgrade">不能升级!</string>
+</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 10b689e..8b1fa55 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -142,4 +142,5 @@
     <color name="searchview_edittext">#59ffffff</color>
     <color name="no_call_log">#42000000</color>
     <color name="list_all_call">#d3000000</color>
+    <bool name="config_regional_presence_enable">false</bool>
 </resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index 1149281..614cdf2 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -32,4 +32,5 @@
 <resources>
   <bool name="config_regional_video_call_welcome_dialog">false</bool>
   <bool name="config_regional_pup_no_available_network">false</bool>
+  <bool name="config_regional_call_data_usage_enable">false</bool>
 </resources>
diff --git a/res/values/symbols.xml b/res/values/symbols.xml
new file mode 100644
index 0000000..2b1c756
--- /dev/null
+++ b/res/values/symbols.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (c) 2015, The Linux Foundation. All rights reserved.
+  ~
+  ~ Redistribution and use in source and binary forms, with or without
+  ~ modification, are permitted provided that the following conditions are
+  ~ met:
+  ~     * Redistributions of source code must retain the above copyright
+  ~       notice, this list of conditions and the following disclaimer.
+  ~     * Redistributions in binary form must reproduce the above
+  ~       copyright notice, this list of conditions and the following
+  ~       disclaimer in the documentation and/or other materials provided
+  ~       with the distribution.
+  ~     * Neither the name of The Linux Foundation nor the names of its
+  ~       contributors may be used to endorse or promote products derived
+  ~       from this software without specific prior written permission.
+  ~
+  ~ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+  ~ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+  ~ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+  ~ ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+  ~ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+  ~ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+  ~ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+  ~ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+  ~ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+  ~ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+  ~ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  -->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <java-symbol type="bool" name="config_regional_number_patterns_video_call" />
+</resources>
diff --git a/res/xml/video_calling_settings.xml b/res/xml/video_calling_settings.xml
new file mode 100644
index 0000000..65e1da6
--- /dev/null
+++ b/res/xml/video_calling_settings.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <SwitchPreference
+        android:key="video_calling_preference"
+        android:persistent="false"
+        android:title="@string/video_call" />
+
+</PreferenceScreen>
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
old mode 100755
new mode 100644
index 8c4c4b4..12304c0
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -58,6 +58,7 @@
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.android.contacts.common.CallUtil;
 import com.android.contacts.common.dialog.ClearFrequentsDialog;
 import com.android.contacts.common.interactions.ImportExportDialogFragment;
 import com.android.contacts.common.interactions.TouchPointManager;
@@ -87,6 +88,7 @@
 import com.android.dialer.util.DialerUtils;
 import com.android.dialer.util.IntentUtil;
 import com.android.dialer.util.IntentUtil.CallIntentBuilder;
+import com.android.dialer.util.PresenceHelper;
 import com.android.dialer.util.TelecomUtil;
 import com.android.dialer.util.WifiCallUtils;
 import com.android.dialer.voicemail.VoicemailArchiveActivity;
@@ -516,6 +518,12 @@
         mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
         SmartDialPrefix.initializeNanpSettings(this);
 
+        boolean isPresenceEnabled = this.getResources().getBoolean(
+                R.bool.config_regional_presence_enable);
+        if (isPresenceEnabled && !PresenceHelper.isBound()) {
+            PresenceHelper.bindService((Context) DialtactsActivity.this);
+        }
+
         mWifiCallUtils = new WifiCallUtils();
         if (resources.getBoolean(R.bool.config_regional_pup_no_available_network)
                 && mFirstLaunch) {
@@ -629,6 +637,14 @@
     }
 
     @Override
+    protected void onStop() {
+        if (PresenceHelper.isBound()) {
+            PresenceHelper.unbindService((Context) DialtactsActivity.this);
+        }
+        super.onStop();
+    }
+
+    @Override
     protected void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
         outState.putString(KEY_SEARCH_QUERY, mSearchQuery);
@@ -1423,6 +1439,12 @@
             // an error message.
             phoneNumber = "";
         }
+        if (getResources().getBoolean(R.bool.config_regional_number_patterns_video_call) &&
+                !CallUtil.isVideoCallNumValid(phoneNumber) &&
+                        isVideoCall && (CallUtil.isVideoEnabled(this))) {
+            Toast.makeText(this,R.string.toast_make_video_call_failed, Toast.LENGTH_LONG).show();
+            return;
+        }
 
         final Intent intent = new CallIntentBuilder(phoneNumber)
                 .setIsVideoCall(isVideoCall)
diff --git a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
index 85039f7..8b9b8fc 100644
--- a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
+++ b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
@@ -32,10 +32,10 @@
 import com.android.dialer.R;
 import com.android.dialer.util.DialerUtils;
 import com.android.dialer.util.AppCompatConstants;
+import com.android.dialer.util.PresenceHelper;
 import com.google.common.collect.Lists;
 
 import java.util.ArrayList;
-
 /**
  * Adapter for a ListView containing history items from the details of a call.
  */
@@ -107,8 +107,13 @@
         TextView durationView = (TextView) result.findViewById(R.id.duration);
 
         int callType = details.callTypes[0];
-        boolean isVideoCall = (details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO
-                && CallUtil.isVideoEnabled(mContext);
+        boolean isPresenceEnabled = mContext.getResources().getBoolean(
+                R.bool.config_regional_presence_enable);
+        boolean isVideoCall = (details.features & Calls.FEATURES_VIDEO)
+                == Calls.FEATURES_VIDEO && CallUtil.isVideoEnabled(mContext);
+        if (isPresenceEnabled) {
+            isVideoCall &= PresenceHelper.startAvailabilityFetch(details.number.toString());
+        }
         boolean isVoLTE = (callType == AppCompatConstants.INCOMING_IMS_TYPE) ||
                           (callType == AppCompatConstants.OUTGOING_IMS_TYPE) ||
                           (callType == AppCompatConstants.MISSED_IMS_TYPE);
diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
index baf2e1a..e27ea78 100644
--- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
+++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
@@ -60,6 +60,7 @@
 import com.android.dialer.service.ExtendedBlockingButtonRenderer;
 import com.android.dialer.util.DialerUtils;
 import com.android.dialer.util.PhoneNumberUtil;
+import com.android.dialer.util.PresenceHelper;
 import com.android.dialer.voicemail.VoicemailPlaybackLayout;
 import com.android.dialer.voicemail.VoicemailPlaybackPresenter;
 import com.android.dialerbind.ObjectFactory;
@@ -67,6 +68,8 @@
 
 import java.util.List;
 
+import org.codeaurora.presenceserv.IPresenceService;
+
 /**
  * This is an object containing references to views contained by the call log list item. This
  * improves performance by reducing the frequency with which we need to find views by IDs.
@@ -504,10 +507,14 @@
         } else {
             callButtonView.setVisibility(View.GONE);
         }
-
-        // If one of the calls had video capabilities, show the video call button.
-        if (mCallLogCache.isVideoEnabled() && canPlaceCallToNumber &&
-                phoneCallDetailsViews.callTypeIcons.isVideoShown()) {
+        boolean isPresenceEnabled = mContext.getResources().getBoolean(
+                R.bool.config_regional_presence_enable);
+        boolean showVideoCallBtn = isPresenceEnabled ? PresenceHelper.startAvailabilityFetch(number)
+                : phoneCallDetailsViews.callTypeIcons.isVideoShown();
+        //If presence is enabled,only both of sides had video capabilities,
+        //show the video call button,If not, one of the calls had video capabilities,
+        //the video call button will be shown.
+        if (mCallLogCache.isVideoEnabled() && canPlaceCallToNumber && showVideoCallBtn) {
             videoCallButtonView.setTag(IntentProvider.getReturnVideoCallIntentProvider(number));
             videoCallButtonView.setVisibility(View.VISIBLE);
         } else {
@@ -729,4 +736,4 @@
         viewHolder.workIconView = new ImageButton(context);
         return viewHolder;
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java
index 322ecd4..1c81455 100644
--- a/src/com/android/dialer/settings/DialerSettingsActivity.java
+++ b/src/com/android/dialer/settings/DialerSettingsActivity.java
@@ -31,6 +31,7 @@
 import com.android.contacts.common.compat.CompatUtils;
 import com.android.contacts.common.compat.TelephonyManagerCompat;
 import com.android.dialer.SpeedDialListActivity;
+import com.android.contacts.common.CallUtil;
 import com.android.dialer.R;
 import com.android.dialer.compat.FilteredNumberCompat;
 import com.android.dialer.compat.SettingsCompat;
@@ -134,6 +135,27 @@
             accessibilitySettingsHeader.intent = accessibilitySettingsIntent;
             target.add(accessibilitySettingsHeader);
         }
+        //video calling
+        boolean enablePresence = this.getResources().getBoolean(
+                R.bool.config_regional_presence_enable);
+        if(enablePresence){
+            Header videocallingHeader = new Header();
+            videocallingHeader.titleRes = R.string.video_call;
+            videocallingHeader.fragment = VideoCallingSettingsFragment.class.getName();
+            target.add(videocallingHeader);
+        }
+
+        boolean usageEnable = getResources().getBoolean(
+                R.bool.config_regional_call_data_usage_enable);
+        if (usageEnable) {
+            final Header historyInfoHeader = new Header();
+            historyInfoHeader.titleRes = R.string.call_data_info_label;
+            historyInfoHeader.summaryRes = R.string.call_data_info_description;
+            historyInfoHeader.intent = new Intent(Intent.ACTION_MAIN);
+            historyInfoHeader.intent
+                    .setAction("android.intent.action.SHOW_TIMERINFO");
+            target.add(historyInfoHeader);
+        }
     }
 
     @Override
diff --git a/src/com/android/dialer/settings/VideoCallingSettingsFragment.java b/src/com/android/dialer/settings/VideoCallingSettingsFragment.java
new file mode 100644
index 0000000..fa73ab7
--- /dev/null
+++ b/src/com/android/dialer/settings/VideoCallingSettingsFragment.java
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ **/
+
+package com.android.dialer.settings;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import android.preference.SwitchPreference;
+
+import java.lang.Object;
+import java.lang.Override;
+import java.lang.String;
+
+import com.android.contacts.common.CallUtil;
+import com.android.dialer.R;
+
+public class VideoCallingSettingsFragment extends PreferenceFragment implements
+        Preference.OnPreferenceChangeListener {
+
+    private final static String KEY_VIDEO_CALL = "video_calling_preference";
+    private SwitchPreference mVideoCallingPreference;
+    private Context mContext;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        addPreferencesFromResource(R.xml.video_calling_settings);
+
+        mContext = getActivity();
+        mVideoCallingPreference = (SwitchPreference)findPreference(KEY_VIDEO_CALL);
+        mVideoCallingPreference.setOnPreferenceChangeListener(this);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        int enable = Settings.System.getInt(mContext.getContentResolver(),
+                CallUtil.DIALOG_VIDEO_CALLING,CallUtil.DISABLE_VIDEO_CALLING);
+        if(mVideoCallingPreference != null)
+            mVideoCallingPreference.setChecked(enable == CallUtil.ENABLE_VIDEO_CALLING);
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object objValue) {
+        if (preference == mVideoCallingPreference) {
+            boolean isCheck = mVideoCallingPreference.isChecked();
+            CallUtil.createVideoCallingDialog(isCheck , mContext);
+            Settings.System.putInt(mContext.getContentResolver(), CallUtil.CONFIG_VIDEO_CALLING,
+                    isCheck ? CallUtil.ENABLE_VIDEO_CALLING : CallUtil.DISABLE_VIDEO_CALLING);
+        }
+        return true;
+    }
+
+}
diff --git a/src/com/android/dialer/util/PresenceHelper.java b/src/com/android/dialer/util/PresenceHelper.java
new file mode 100644
index 0000000..cf94df0
--- /dev/null
+++ b/src/com/android/dialer/util/PresenceHelper.java
@@ -0,0 +1,134 @@
+/**
+ * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ **/
+package com.android.dialer.util;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.ServiceConnection;
+import android.content.Intent;
+import android.os.IBinder;
+import android.os.RemoteException;
+
+import com.android.incallui.Log;
+
+import org.codeaurora.presenceserv.IPresenceService;
+import org.codeaurora.presenceserv.IPresenceServiceCB;
+
+/**
+ * General presnece service utility methods for the Dialer.
+ */
+public class PresenceHelper {
+
+    private static final String TAG = "PresenceHelper";
+    private static volatile IPresenceService mService;
+    private static boolean mIsBound;
+
+    private static ServiceConnection mConnection = new ServiceConnection() {
+
+        public void onServiceConnected(ComponentName className, IBinder service) {
+            Log.d(TAG, "PresenceService connected");
+            mService = IPresenceService.Stub.asInterface(service);
+            try {
+                mService.registerCallback(mCallback);
+            } catch (RemoteException e) {
+                Log.e(TAG, "PresenceService registerCallback error " + e);
+            }
+        }
+        public void onServiceDisconnected(ComponentName className) {
+            Log.d(TAG, "PresenceService disconnected");
+            mService = null;
+        }
+    };
+
+    private static IPresenceServiceCB mCallback = new IPresenceServiceCB.Stub() {
+
+        public void setIMSEnabledCB() {
+            Log.d(TAG, "PresenceService setIMSEnabled callback");
+        }
+
+    };
+
+    public static void bindService(Context context) {
+        Log.d(TAG, "PresenceService BindService ");
+        Intent intent = new Intent(IPresenceService.class.getName());
+        intent.setClassName("com.qualcomm.qti.presenceserv",
+                "com.qualcomm.qti.presenceserv.PresenceService");
+        mIsBound = context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
+    }
+
+    public static void unbindService(Context context) {
+        Log.d(TAG, "PresenceService unbindService");
+        if (mService == null) {
+            Log.d(TAG, "PresenceService unbindService: mService is null");
+            return;
+        }
+        try {
+            mService.unregisterCallback(mCallback);
+        } catch (RemoteException e) {
+            Log.e(TAG, "PresenceService unregister error " + e);
+        }
+        if (mIsBound) {
+            Log.d(TAG, "PresenceService unbind");
+            context.unbindService(mConnection);
+            mIsBound = false;
+        }
+    }
+
+    public static boolean isBound() {
+        return mIsBound;
+    }
+
+    public static boolean startAvailabilityFetch(String number){
+        Log.d(TAG, "startAvailabilityFetch   number " + number);
+        if (mService == null) {
+             Log.d(TAG, "startAvailabilityFetch mService is null");
+             return false;
+        }
+        try {
+            return mService.invokeAvailabilityFetch(number);
+        } catch (Exception e) {
+            Log.d(TAG, "getVTCapOfContact ERROR " + e);
+        }
+        return false;
+    }
+
+    public static boolean getVTCapability(String number) {
+        Log.d(TAG, "getVTCapability   number " + number);
+        if (null == mService) {
+            Log.d(TAG, "getVTCapability mService is null");
+            return false;
+        }
+        try {
+            return mService.hasVTCapability(number);
+        } catch (Exception e) {
+            Log.d(TAG, "getVTCapability ERROR " + e);
+        }
+        return false;
+    }
+}
diff --git a/src/org/codeaurora/presenceserv/IPresenceService.aidl b/src/org/codeaurora/presenceserv/IPresenceService.aidl
new file mode 100644
index 0000000..edd0ac1
--- /dev/null
+++ b/src/org/codeaurora/presenceserv/IPresenceService.aidl
@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ **/
+
+package org.codeaurora.presenceserv;
+
+import org.codeaurora.presenceserv.IPresenceServiceCB;
+
+/**
+ * Presence service interface.
+ */
+interface IPresenceService {
+
+    String getImsEnablerState();
+    boolean hasVTCapability(String number);
+    void invokPublish();
+    boolean invokeAvailabilityFetch(String number);
+    void invokeCapabilityPolling(String number);
+    void invokeListAvailabilityFetch();
+    void invokeListCapabilityPolling();
+    void registerCallback(IPresenceServiceCB cb);
+    void unregisterCallback(IPresenceServiceCB cb);
+
+}
+
diff --git a/src/org/codeaurora/presenceserv/IPresenceServiceCB.aidl b/src/org/codeaurora/presenceserv/IPresenceServiceCB.aidl
new file mode 100644
index 0000000..05ad7d7
--- /dev/null
+++ b/src/org/codeaurora/presenceserv/IPresenceServiceCB.aidl
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ **/
+package org.codeaurora.presenceserv;
+
+/**
+ * Presence service callback interface.
+ */
+interface IPresenceServiceCB {
+
+    void setIMSEnabledCB();
+}
+