Merge "Fix MWI missing on blocked VVM3 SIM" into nyc-mr1-dev
diff --git a/res/values-b+sr+Latn/strings.xml b/res/values-b+sr+Latn/strings.xml
index e6f8784..62b56f3 100644
--- a/res/values-b+sr+Latn/strings.xml
+++ b/res/values-b+sr+Latn/strings.xml
@@ -548,7 +548,7 @@
     <string name="voicemail_number_not_set" msgid="6724904736891087856">"&lt;Nije podešeno&gt;"</string>
     <string name="other_settings" msgid="3672912580359716394">"Druga podešavanja poziva"</string>
     <string name="calling_via_template" msgid="4839419581866928142">"Pozivanje preko <xliff:g id="PROVIDER_NAME">%s</xliff:g>"</string>
-    <string name="contactPhoto" msgid="4713193418046639466">"fotografija kontakta"</string>
+    <string name="contactPhoto" msgid="4713193418046639466">"slika kontakta"</string>
     <string name="goPrivate" msgid="865837794424530980">"idi na privatno"</string>
     <string name="selectContact" msgid="781975788478987237">"izaberite kontakt"</string>
     <string name="not_voice_capable" msgid="2739898841461577811">"Audio pozivi nisu podržani"</string>
diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml
index 9f1f683..48100d0 100644
--- a/res/values-sr/strings.xml
+++ b/res/values-sr/strings.xml
@@ -548,7 +548,7 @@
     <string name="voicemail_number_not_set" msgid="6724904736891087856">"&lt;Није подешено&gt;"</string>
     <string name="other_settings" msgid="3672912580359716394">"Друга подешавања позива"</string>
     <string name="calling_via_template" msgid="4839419581866928142">"Позивање преко <xliff:g id="PROVIDER_NAME">%s</xliff:g>"</string>
-    <string name="contactPhoto" msgid="4713193418046639466">"фотографија контакта"</string>
+    <string name="contactPhoto" msgid="4713193418046639466">"слика контакта"</string>
     <string name="goPrivate" msgid="865837794424530980">"иди на приватно"</string>
     <string name="selectContact" msgid="781975788478987237">"изаберите контакт"</string>
     <string name="not_voice_capable" msgid="2739898841461577811">"Аудио позиви нису подржани"</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 61e0a5b..34cdeb5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1325,7 +1325,7 @@
 
     <!-- Status hint label for an incoming call over a wifi network which has not been accepted yet.
          [CHAR LIMIT=25] -->
-    <string name="status_hint_label_incoming_wifi_call">Incoming Wi-Fi call</string>
+    <string name="status_hint_label_incoming_wifi_call">Wi-Fi call from</string>
     <!-- Status hint label for a call being made over a wifi network. [CHAR LIMIT=25] -->
     <string name="status_hint_label_wifi_call">Wi-Fi call</string>
 
diff --git a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
index 3cc25c3..58797de 100644
--- a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
+++ b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
@@ -188,7 +188,7 @@
 
         if (readVoicemails.size() > 0) {
             if (imapHelper.markMessagesAsRead(readVoicemails)) {
-                mQueryHelper.markReadInDatabase(readVoicemails);
+                mQueryHelper.markCleanInDatabase(readVoicemails);
             } else {
                 success = false;
             }
diff --git a/src/com/android/phone/vvm/omtp/sync/VoicemailsQueryHelper.java b/src/com/android/phone/vvm/omtp/sync/VoicemailsQueryHelper.java
index 1c71a23..9906386 100644
--- a/src/com/android/phone/vvm/omtp/sync/VoicemailsQueryHelper.java
+++ b/src/com/android/phone/vvm/omtp/sync/VoicemailsQueryHelper.java
@@ -21,7 +21,6 @@
 import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
-import android.provider.CallLog.Calls;
 import android.provider.VoicemailContract;
 import android.provider.VoicemailContract.Voicemails;
 import android.telecom.PhoneAccountHandle;
@@ -150,15 +149,6 @@
                 new String[] { Long.toString(voicemail.getId()) });
     }
 
-    /**
-     * Sends an update command to the voicemail content provider for a list of voicemails.
-     * From the view of the provider, since the updater is the owner of the entry, a blank
-     * "update" means that the voicemail source is indicating that the server has up-to-date
-     * information on the voicemail. This flips the "dirty" bit to "0".
-     *
-     * @param voicemails The list of voicemails to update
-     * @return The number of voicemails updated
-     */
     public int markReadInDatabase(List<Voicemail> voicemails) {
         int count = voicemails.size();
         for (int i = 0; i < count; i++) {
@@ -174,7 +164,32 @@
         Uri uri = ContentUris.withAppendedId(mSourceUri, voicemail.getId());
         ContentValues contentValues = new ContentValues();
         contentValues.put(Voicemails.IS_READ, "1");
-        contentValues.put(Calls.NEW, false);
+        mContentResolver.update(uri, contentValues, null, null);
+    }
+
+    /**
+     * Sends an update command to the voicemail content provider for a list of voicemails. From the
+     * view of the provider, since the updater is the owner of the entry, a blank "update" means
+     * that the voicemail source is indicating that the server has up-to-date information on the
+     * voicemail. This flips the "dirty" bit to "0".
+     *
+     * @param voicemails The list of voicemails to update
+     * @return The number of voicemails updated
+     */
+    public int markCleanInDatabase(List<Voicemail> voicemails) {
+        int count = voicemails.size();
+        for (int i = 0; i < count; i++) {
+            markCleanInDatabase(voicemails.get(i));
+        }
+        return count;
+    }
+
+    /**
+     * Utility method to mark single message as clean.
+     */
+    public void markCleanInDatabase(Voicemail voicemail) {
+        Uri uri = ContentUris.withAppendedId(mSourceUri, voicemail.getId());
+        ContentValues contentValues = new ContentValues();
         mContentResolver.update(uri, contentValues, null, null);
     }
 
diff --git a/src/com/android/services/telephony/DisconnectCauseUtil.java b/src/com/android/services/telephony/DisconnectCauseUtil.java
index 48fc2a4..bcc22fd 100644
--- a/src/com/android/services/telephony/DisconnectCauseUtil.java
+++ b/src/com/android/services/telephony/DisconnectCauseUtil.java
@@ -126,6 +126,8 @@
             case android.telephony.DisconnectCause.DIAL_MODIFIED_TO_DIAL:
             case android.telephony.DisconnectCause.ERROR_UNSPECIFIED:
             case android.telephony.DisconnectCause.MAXIMUM_NUMBER_OF_CALLS_REACHED:
+            case android.telephony.DisconnectCause.DATA_DISABLED:
+            case android.telephony.DisconnectCause.DATA_LIMIT_REACHED:
                 return DisconnectCause.ERROR;
 
             case android.telephony.DisconnectCause.DIALED_MMI:
@@ -229,6 +231,14 @@
                 resourceId = R.string.callFailed_maximum_reached;
                 break;
 
+            case android.telephony.DisconnectCause.DATA_DISABLED:
+                resourceId = R.string.callFailed_data_disabled;
+                break;
+
+            case android.telephony.DisconnectCause.DATA_LIMIT_REACHED:
+                resourceId = R.string.callFailed_data_limit_reached;
+                break;
+
             default:
                 break;
         }
@@ -360,6 +370,16 @@
                 // either canceled by the user explicitly (end-call button pushed immediately)
                 // or some other app canceled the call and immediately issued a new CALL to
                 // replace it.
+                break;
+
+            case android.telephony.DisconnectCause.DATA_DISABLED:
+                resourceId = R.string.callFailed_data_disabled;
+                break;
+
+            case android.telephony.DisconnectCause.DATA_LIMIT_REACHED:
+                resourceId = R.string.callFailed_data_limit_reached;
+                break;
+
             default:
                 break;
         }
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index ec7a33c..3810699 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -404,6 +404,17 @@
         public void onHandoverToWifiFailed() {
             sendConnectionEvent(TelephonyManager.EVENT_HANDOVER_TO_WIFI_FAILED, null);
         }
+
+        /**
+         * Informs the {@link android.telecom.ConnectionService} of a connection event raised by the
+         * original connection.
+         * @param event The connection event.
+         * @param extras The extras.
+         */
+        @Override
+        public void onConnectionEvent(String event, Bundle extras) {
+            sendConnectionEvent(event, extras);
+        }
     };
 
     protected com.android.internal.telephony.Connection mOriginalConnection;
@@ -767,7 +778,7 @@
                 setAddress(address, presentation);
             }
 
-            String name = mOriginalConnection.getCnapName();
+            String name = filterCnapName(mOriginalConnection.getCnapName());
             int namePresentation = mOriginalConnection.getCnapNamePresentation();
             if (!Objects.equals(name, getCallerDisplayName()) ||
                     namePresentation != getCallerDisplayNamePresentation()) {
@@ -860,6 +871,33 @@
     }
 
     /**
+     * Filters the CNAP name to not include a list of names that are unhelpful to the user for
+     * Caller ID purposes.
+     */
+    private String filterCnapName(final String cnapName) {
+        if (cnapName == null) {
+            return null;
+        }
+        PersistableBundle carrierConfig = getCarrierConfig();
+        String[] filteredCnapNames = null;
+        if (carrierConfig != null) {
+            filteredCnapNames = carrierConfig.getStringArray(
+                    CarrierConfigManager.FILTERED_CNAP_NAMES_STRING_ARRAY);
+        }
+        if (filteredCnapNames != null) {
+            long cnapNameMatches = Arrays.asList(filteredCnapNames)
+                    .stream()
+                    .filter(filteredCnapName -> filteredCnapName.equals(cnapName.toUpperCase()))
+                    .count();
+            if (cnapNameMatches > 0) {
+                Log.i(this, "filterCnapName: Filtered CNAP Name: " + cnapName);
+                return "";
+            }
+        }
+        return cnapName;
+    }
+
+    /**
      * Sets the EXTRA_CALL_TECHNOLOGY_TYPE extra on the connection to report back to Telecom.
      */
     private void setTechnologyTypeExtra() {