Promotion of atel.lnx.2.0-00011.

CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
1063221 988088   I24a938626e86a3fade82ca0c92e557345b095ea9   Dialer: add upgrade for smart search table.
1050432   Iedc06167bf2edd50c7405a09cd99e68fdc3f4f7c   IMS-VT: Fix orientation change not working after back ke
1059292   I9753f5c984b0a2dd974599c9b049731eba08b2ac   IMS-VT: Make sure modify call progress spinner is displa
1062760   I5c1d2b1de7bca43b2432270a4a2c410290917675   Dialer: Can't show Card 2 call log one card existed
1059806   I2339aa5b333a9415d17f092f3ef8647a79b0304a   IMS: Customize HD icon in CallCard for some carriers

Change-Id: I1ce0a08d029e2b5af271f46782e6268823aa999d
CRs-Fixed: 1050432, 1059292, 1059806, 1063221, 988088, 1062760
diff --git a/InCallUI/res/drawable-hdpi/ic_hd2_24dp.png b/InCallUI/res/drawable-hdpi/ic_hd2_24dp.png
new file mode 100644
index 0000000..b4cbe6d
--- /dev/null
+++ b/InCallUI/res/drawable-hdpi/ic_hd2_24dp.png
Binary files differ
diff --git a/InCallUI/res/drawable-mdpi/ic_hd2_24dp.png b/InCallUI/res/drawable-mdpi/ic_hd2_24dp.png
new file mode 100644
index 0000000..f4bc997
--- /dev/null
+++ b/InCallUI/res/drawable-mdpi/ic_hd2_24dp.png
Binary files differ
diff --git a/InCallUI/res/drawable-xhdpi/ic_hd2_24dp.png b/InCallUI/res/drawable-xhdpi/ic_hd2_24dp.png
new file mode 100644
index 0000000..4ac0961
--- /dev/null
+++ b/InCallUI/res/drawable-xhdpi/ic_hd2_24dp.png
Binary files differ
diff --git a/InCallUI/res/drawable-xxhdpi/ic_hd2_24dp.png b/InCallUI/res/drawable-xxhdpi/ic_hd2_24dp.png
new file mode 100644
index 0000000..f1e6f1f
--- /dev/null
+++ b/InCallUI/res/drawable-xxhdpi/ic_hd2_24dp.png
Binary files differ
diff --git a/InCallUI/res/layout-h400dp/call_card_fragment.xml b/InCallUI/res/layout-h400dp/call_card_fragment.xml
index 54b9e36..ccff385 100644
--- a/InCallUI/res/layout-h400dp/call_card_fragment.xml
+++ b/InCallUI/res/layout-h400dp/call_card_fragment.xml
@@ -116,7 +116,7 @@
                 <ProgressBar
                     android:id="@+id/progress_bar"
                     style="@android:style/Widget.Material.ProgressBar"
-                    android:layout_gravity="center"
+                    android:layout_gravity="left|center_vertical"
                     android:layout_width="48dp"
                     android:layout_height="48dp"
                     android:indeterminate="true" />
diff --git a/InCallUI/res/layout-w500dp-land/call_card_fragment.xml b/InCallUI/res/layout-w500dp-land/call_card_fragment.xml
index bdd1e27..1efe527 100644
--- a/InCallUI/res/layout-w500dp-land/call_card_fragment.xml
+++ b/InCallUI/res/layout-w500dp-land/call_card_fragment.xml
@@ -109,7 +109,7 @@
             <ProgressBar
                 android:id="@+id/progress_bar"
                 style="@android:style/Widget.Material.ProgressBar"
-                android:layout_gravity="center"
+                android:layout_gravity="left|center_vertical"
                 android:layout_width="48dp"
                 android:layout_height="48dp"
                 android:indeterminate="true" />
diff --git a/InCallUI/res/layout/call_card_fragment.xml b/InCallUI/res/layout/call_card_fragment.xml
index f865944..2a4c3e2 100644
--- a/InCallUI/res/layout/call_card_fragment.xml
+++ b/InCallUI/res/layout/call_card_fragment.xml
@@ -91,7 +91,7 @@
         <ProgressBar
             android:id="@+id/progress_bar"
             style="@android:style/Widget.Material.ProgressBar"
-            android:layout_gravity="center"
+            android:layout_gravity="left|center_vertical"
             android:layout_width="48dp"
             android:layout_height="48dp"
             android:indeterminate="true" />
diff --git a/InCallUI/res/values-mcc460-mnc01/qticonfig.xml b/InCallUI/res/values-mcc460-mnc01/qticonfig.xml
new file mode 100644
index 0000000..5f789c5
--- /dev/null
+++ b/InCallUI/res/values-mcc460-mnc01/qticonfig.xml
@@ -0,0 +1,32 @@
+<!--
+  ~ 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.
+  -->
+<resources>
+    <!-- Config to show/hide HD Icon2 -->
+    <bool name="config_show_hd2">true</bool>
+</resources>
diff --git a/InCallUI/res/values-mcc460-mnc06/qticonfig.xml b/InCallUI/res/values-mcc460-mnc06/qticonfig.xml
new file mode 100644
index 0000000..5f789c5
--- /dev/null
+++ b/InCallUI/res/values-mcc460-mnc06/qticonfig.xml
@@ -0,0 +1,32 @@
+<!--
+  ~ 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.
+  -->
+<resources>
+    <!-- Config to show/hide HD Icon2 -->
+    <bool name="config_show_hd2">true</bool>
+</resources>
diff --git a/InCallUI/res/values-mcc460-mnc09/qticonfig.xml b/InCallUI/res/values-mcc460-mnc09/qticonfig.xml
new file mode 100644
index 0000000..5f789c5
--- /dev/null
+++ b/InCallUI/res/values-mcc460-mnc09/qticonfig.xml
@@ -0,0 +1,32 @@
+<!--
+  ~ 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.
+  -->
+<resources>
+    <!-- Config to show/hide HD Icon2 -->
+    <bool name="config_show_hd2">true</bool>
+</resources>
diff --git a/InCallUI/res/values/qticonfig.xml b/InCallUI/res/values/qticonfig.xml
index 8483d84..67c50f3 100644
--- a/InCallUI/res/values/qticonfig.xml
+++ b/InCallUI/res/values/qticonfig.xml
@@ -54,4 +54,6 @@
     <bool name="add_participant_only_in_conference">false</bool>
     <!-- Config to if show preview before the receiver accepts a show me upgrade video call -->
     <bool name="config_enable_modify_call_preview">false</bool>
+    <!-- Config to show/hide HD Icon2 -->
+    <bool name="config_show_hd2">false</bool>
 </resources>
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index c64f8c6..bbc95d3 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -45,6 +45,7 @@
 import android.provider.Settings;
 import android.telecom.DisconnectCause;
 import android.telephony.PhoneNumberUtils;
+import android.telephony.SubscriptionManager;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 import android.view.Gravity;
@@ -1357,6 +1358,11 @@
      */
     @Override
     public void showHdAudioIndicator(boolean visible) {
+        int subId = CallList.getInstance().getActiveSubId();
+        if (SubscriptionManager.getResourcesForSubId(getContext(), subId)
+                .getBoolean(R.bool.config_show_hd2)) {
+            mHdAudioIcon.setImageResource(R.drawable.ic_hd2_24dp);
+        }
         mHdAudioIcon.setVisibility(visible ? View.VISIBLE : View.GONE);
     }
 
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index 68a03b9..8fe52d0 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -1811,16 +1811,18 @@
      * orientation event listener if allowOrientationChange is true, disables it if false.
      *
      * @param orientation {@link ActivityInfo#screenOrientation} Actual orientation value to set
+     * @return returns whether the new orientation mode was set successfully or not.
      */
-    public void setInCallAllowsOrientationChange(int orientation) {
+    public boolean setInCallAllowsOrientationChange(int orientation) {
         if (mInCallActivity == null) {
             Log.e(this, "InCallActivity is null. Can't set requested orientation.");
-            return;
+            return false;
         }
 
         mInCallActivity.setRequestedOrientation(orientation);
         mInCallActivity.enableInCallOrientationEventListener(
                 orientation == InCallOrientationEventListener.FULL_SENSOR_SCREEN_ORIENTATION);
+        return true;
     }
 
     /* returns TRUE if screen is turned ON else false */
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
index eab6ca2..33717f6 100644
--- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
@@ -670,11 +670,11 @@
 
     private void checkForOrientationAllowedChange(Call call) {
         final int newMode = OrientationModeHandler.getInstance().getOrientation(call);
-        if (newMode != mActivityOrientationMode) {
+        if (newMode != mActivityOrientationMode && InCallPresenter.
+                getInstance().setInCallAllowsOrientationChange(newMode)) {
             Log.d(this, "checkForOrientationAllowedChange: currMode = " +
                     mActivityOrientationMode + " newMode = " + newMode);
             mActivityOrientationMode = newMode;
-            InCallPresenter.getInstance().setInCallAllowsOrientationChange(newMode);
         }
     }
 
diff --git a/src/com/android/dialer/calllog/MSimCallLogFragment.java b/src/com/android/dialer/calllog/MSimCallLogFragment.java
index 8f484d8..1eefe53 100644
--- a/src/com/android/dialer/calllog/MSimCallLogFragment.java
+++ b/src/com/android/dialer/calllog/MSimCallLogFragment.java
@@ -71,7 +71,6 @@
 import android.util.Log;
 import android.preference.PreferenceManager;
 import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
 
 import java.util.List;
 
@@ -612,9 +611,8 @@
         }
 
         // Update the sub filter's content.
-        final TelephonyManager telephony = (TelephonyManager) getActivity().getSystemService(
-                Context.TELEPHONY_SERVICE);
-        if (!telephony.isMultiSimEnabled()) {
+        final SubscriptionManager subscriptionManager = SubscriptionManager.from(getActivity());
+        if (subscriptionManager.getActiveSubscriptionInfoCount() < 2) {
             mFilterSubSpinnerView.setVisibility(View.GONE);
         }else{
             ArrayAdapter<SpinnerContent> filterSubAdapter = new ArrayAdapter<SpinnerContent>(
diff --git a/src/com/android/dialer/database/DialerDatabaseHelper.java b/src/com/android/dialer/database/DialerDatabaseHelper.java
old mode 100755
new mode 100644
index 05f94a5..1d3de31
--- a/src/com/android/dialer/database/DialerDatabaseHelper.java
+++ b/src/com/android/dialer/database/DialerDatabaseHelper.java
@@ -19,6 +19,7 @@
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
 import android.database.Cursor;
 import android.database.DatabaseUtils;
 import android.database.sqlite.SQLiteDatabase;
@@ -50,6 +51,7 @@
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 
+import java.io.File;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -84,6 +86,8 @@
      * </pre>
      */
     public static final int DATABASE_VERSION = 9;
+    public static final int DATABASE_SHAREPREF_VERSION = 1;
+    public static final String DATABASE_SHAREPREF_KEY = "database_sharepref_key";
     public static final String DATABASE_NAME = "dialer.db";
 
     /**
@@ -459,6 +463,11 @@
         setupTables(db);
     }
 
+    @Override
+    public void onOpen(SQLiteDatabase db) {
+        upgradeSmartSearchDatabase(db);
+    }
+
     private void setupTables(SQLiteDatabase db) {
         dropTables(db);
         db.execSQL("CREATE TABLE " + Tables.SMARTDIAL_TABLE + " ("
@@ -514,6 +523,49 @@
         }
     }
 
+    private boolean isNeedUpgradeForSmartSearch() {
+        String FILENAME = "upgradeSmartSearchTable";
+
+        Log.d(TAG, "Shared Preference Created with name:  " + FILENAME);
+        SharedPreferences pref = mContext.getSharedPreferences(FILENAME,
+                mContext.MODE_PRIVATE);
+        if (pref != null) {
+            int mSharePrefVersion = pref.getInt(DATABASE_SHAREPREF_KEY,0);
+            if(mSharePrefVersion < DATABASE_SHAREPREF_VERSION) {
+                Editor editor;
+                editor = pref.edit();
+                editor.putInt(DATABASE_SHAREPREF_KEY, DATABASE_SHAREPREF_VERSION);
+                editor.commit();
+                return true;
+            }
+            return false;
+        } else {
+            Log.d(TAG, "fail to get SharedPreferences !");
+            return false;
+        }
+    }
+
+    private void upgradeSmartSearchDatabase(SQLiteDatabase db) {
+        if (isNeedUpgradeForSmartSearch()) {
+            db.beginTransaction();
+            try {
+                upgradeDatabaseSmartSearch(db);
+                db.setTransactionSuccessful();
+            } catch (Throwable ex) {
+                Log.e(TAG, ex.getMessage(), ex);
+            } finally {
+                db.endTransaction();
+            }
+        }
+    }
+
+    private void upgradeDatabaseSmartSearch(SQLiteDatabase db) {
+        db.execSQL("ALTER TABLE " +  Tables.SMARTDIAL_TABLE + " ADD COLUMN " +
+                SmartDialDbColumns.ACCOUNT_TYPE + " TEXT;");
+        db.execSQL("ALTER TABLE " +  Tables.SMARTDIAL_TABLE + " ADD COLUMN " +
+                SmartDialDbColumns.ACCOUNT_NAME + " TEXT;");
+    }
+
     public void dropTables(SQLiteDatabase db) {
         db.execSQL("DROP TABLE IF EXISTS " + Tables.PREFIX_TABLE);
         db.execSQL("DROP TABLE IF EXISTS " + Tables.SMARTDIAL_TABLE);