Merge changes I3375fe14,Ib11ca441,I540c9e3d,I42c12f3f

* changes:
  Updating Dialer v17 licenses.
  Add a BatchSpamChecker for InAppSpam.
  Implemented missed call/voicemail notifications in NUI.
  Fullly disable VVM if carrier VVM app is installed.
diff --git a/java/com/android/dialer/about/res/raw/third_party_license_metadata b/java/com/android/dialer/about/res/raw/third_party_license_metadata
index 73b3443..f1ef939 100755
--- a/java/com/android/dialer/about/res/raw/third_party_license_metadata
+++ b/java/com/android/dialer/about/res/raw/third_party_license_metadata
@@ -30,14 +30,15 @@
 321603:11358 OpenCensus
 332972:11358 Volley
 344341:10695 bubble
-355050:11358 gRPC Java
-366426:12847 jibercsclient
-379292:10173 libphonenumber
-389476:18982 mime4j
-408475:12847 rcsclientlib
-421341:10699 shortcutbadger
-432056:16013 Android SDK
-448079:4771 Glide
-452869:1096 Animal Sniffer
-453987:22655 Checker Framework
-476654:1602 JSR 305
+355056:12847 carrierservices
+367915:11358 flexbox
+379287:11358 gRPC Java
+390663:12847 jibercsclient
+403529:10173 libphonenumber
+413713:18982 mime4j
+432714:10699 shortcutbadger
+443429:16013 Android SDK
+459452:4771 Glide
+464242:1096 Animal Sniffer
+465360:22655 Checker Framework
+488027:1602 JSR 305
diff --git a/java/com/android/dialer/about/res/raw/third_party_licenses b/java/com/android/dialer/about/res/raw/third_party_licenses
index 8fb021a..f99315f 100755
--- a/java/com/android/dialer/about/res/raw/third_party_licenses
+++ b/java/com/android/dialer/about/res/raw/third_party_licenses
@@ -6419,6 +6419,451 @@
 
 
 
+carrierservices:
+
+These components
+  com.google.android.rcs.core,
+  com.google.android.rcs.core.utils.CaseInsensitiveMap,
+  com.google.android.rcs.core.utils.DateTime,
+  com.google.android.rcs.core.utils.InetAddresses,
+  com.google.android.rcs.core.network.ConnectivityMonitor,
+  com.google.android.rcs.client.PrivateDataStorage,
+  com.google.android.rcs.client.utils.FastXmlSerializer,
+  com.google.android.rcs.client.utils.XmlUtils,
+  com.google.android.rcs.client.utils.QueuedWork
+are licensed under Apache v2.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+===============================================================================
+
+These components
+  com.google.android.rcs.core.utils.FastBase64,
+  com.google.android.rcs.core.utils.LibraryLoaderHelper
+are licensed under BSD.
+
+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 Google Inc. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE 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.
+
+
+flexbox:
+
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+
 gRPC Java:
 
 
@@ -7409,245 +7854,6 @@
  
  
 
-rcsclientlib:
-
-These components
-  com.google.android.rcs.core,
-  com.google.android.rcs.core.utils.CaseInsensitiveMap,
-  com.google.android.rcs.core.utils.DateTime,
-  com.google.android.rcs.core.utils.InetAddresses,
-  com.google.android.rcs.core.network.ConnectivityMonitor,
-  com.google.android.rcs.client.PrivateDataStorage,
-  com.google.android.rcs.client.utils.FastXmlSerializer,
-  com.google.android.rcs.client.utils.XmlUtils,
-  com.google.android.rcs.client.utils.QueuedWork
-are licensed under Apache v2.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-===============================================================================
-
-These components
-  com.google.android.rcs.core.utils.FastBase64,
-  com.google.android.rcs.core.utils.LibraryLoaderHelper
-are licensed under BSD.
-
-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 Google Inc. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE 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.
-
-
 shortcutbadger:
 
 Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java
index 9e1d4a7..b8ec168 100644
--- a/java/com/android/dialer/app/calllog/CallLogAdapter.java
+++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java
@@ -54,8 +54,8 @@
 import com.android.contacts.common.ContactsUtils;
 import com.android.contacts.common.compat.PhoneNumberUtilsCompat;
 import com.android.contacts.common.preference.ContactsPreferences;
-import com.android.dialer.app.DialtactsActivity;
 import com.android.dialer.app.R;
+import com.android.dialer.app.calllog.CallLogFragment.CallLogFragmentListener;
 import com.android.dialer.app.calllog.CallLogGroupBuilder.GroupCreator;
 import com.android.dialer.app.calllog.calllogcache.CallLogCache;
 import com.android.dialer.app.contactinfo.ContactInfoCache;
@@ -68,6 +68,7 @@
 import com.android.dialer.calllogutils.CallbackActionHelper.CallbackAction;
 import com.android.dialer.calllogutils.PhoneCallDetails;
 import com.android.dialer.common.Assert;
+import com.android.dialer.common.FragmentUtils.FragmentUtilListener;
 import com.android.dialer.common.LogUtil;
 import com.android.dialer.common.concurrent.AsyncTaskExecutor;
 import com.android.dialer.common.concurrent.AsyncTaskExecutors;
@@ -379,7 +380,18 @@
             if (viewHolder.callType == CallLog.Calls.MISSED_TYPE) {
               CallLogAsyncTaskUtil.markCallAsRead(activity, viewHolder.callIds);
               if (activityType == ACTIVITY_TYPE_DIALTACTS) {
-                ((DialtactsActivity) v.getContext()).updateTabUnreadCounts();
+                if (v.getContext() instanceof CallLogFragmentListener) {
+                  ((CallLogFragmentListener) v.getContext()).updateTabUnreadCounts();
+                } else if (v.getContext() instanceof FragmentUtilListener) {
+                  // This is really bad, but we must do this to prevent a dependency cycle, enforce
+                  // best practices in new code, and avoid refactoring DialtactsActivity.
+                  ((FragmentUtilListener) v.getContext())
+                      .getImpl(CallLogFragmentListener.class)
+                      .updateTabUnreadCounts();
+                } else {
+                  throw Assert.createIllegalStateFailException(
+                      "View parent does not implement CallLogFragmentListener");
+                }
               }
             }
             expandViewHolderActions(viewHolder);
diff --git a/java/com/android/dialer/main/impl/BottomNavBar.java b/java/com/android/dialer/main/impl/BottomNavBar.java
index a4ddc06..6d43ee2 100644
--- a/java/com/android/dialer/main/impl/BottomNavBar.java
+++ b/java/com/android/dialer/main/impl/BottomNavBar.java
@@ -22,8 +22,11 @@
 import android.util.AttributeSet;
 import android.view.View;
 import android.widget.LinearLayout;
+import com.android.dialer.common.Assert;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
+import java.util.List;
 
 /** Dialer Bottom Nav Bar for {@link MainActivity}. */
 final class BottomNavBar extends LinearLayout {
@@ -32,22 +35,23 @@
   @Retention(RetentionPolicy.SOURCE)
   @IntDef({
     TabIndex.SPEED_DIAL,
-    TabIndex.HISTORY,
+    TabIndex.CALL_LOG,
     TabIndex.CONTACTS,
     TabIndex.VOICEMAIL,
   })
   public @interface TabIndex {
     int SPEED_DIAL = 0;
-    int HISTORY = 1;
+    int CALL_LOG = 1;
     int CONTACTS = 2;
     int VOICEMAIL = 3;
   }
 
+  private final List<OnBottomNavTabSelectedListener> listeners = new ArrayList<>();
+
   private BottomNavItem speedDial;
   private BottomNavItem callLog;
   private BottomNavItem contacts;
   private BottomNavItem voicemail;
-  private OnBottomNavTabSelectedListener listener;
   private @TabIndex int selectedTab;
 
   public BottomNavBar(Context context, @Nullable AttributeSet attrs) {
@@ -71,25 +75,25 @@
         v -> {
           selectedTab = TabIndex.SPEED_DIAL;
           setSelected(speedDial);
-          listener.onSpeedDialSelected();
+          updateListeners(selectedTab);
         });
     callLog.setOnClickListener(
         v -> {
-          selectedTab = TabIndex.HISTORY;
+          selectedTab = TabIndex.CALL_LOG;
           setSelected(callLog);
-          listener.onCallLogSelected();
+          updateListeners(selectedTab);
         });
     contacts.setOnClickListener(
         v -> {
           selectedTab = TabIndex.CONTACTS;
           setSelected(contacts);
-          listener.onContactsSelected();
+          updateListeners(selectedTab);
         });
     voicemail.setOnClickListener(
         v -> {
           selectedTab = TabIndex.VOICEMAIL;
           setSelected(voicemail);
-          listener.onVoicemailSelected();
+          updateListeners(selectedTab);
         });
   }
 
@@ -108,7 +112,7 @@
   void selectTab(@TabIndex int tab) {
     if (tab == TabIndex.SPEED_DIAL) {
       speedDial.performClick();
-    } else if (tab == TabIndex.HISTORY) {
+    } else if (tab == TabIndex.CALL_LOG) {
       callLog.performClick();
     } else if (tab == TabIndex.CONTACTS) {
       contacts.performClick();
@@ -122,7 +126,7 @@
   void setNotificationCount(@TabIndex int tab, int count) {
     if (tab == TabIndex.SPEED_DIAL) {
       speedDial.setNotificationCount(count);
-    } else if (tab == TabIndex.HISTORY) {
+    } else if (tab == TabIndex.CALL_LOG) {
       callLog.setNotificationCount(count);
     } else if (tab == TabIndex.CONTACTS) {
       contacts.setNotificationCount(count);
@@ -133,8 +137,29 @@
     }
   }
 
-  void setOnTabSelectedListener(OnBottomNavTabSelectedListener listener) {
-    this.listener = listener;
+  void addOnTabSelectedListener(OnBottomNavTabSelectedListener listener) {
+    listeners.add(listener);
+  }
+
+  private void updateListeners(@TabIndex int tabIndex) {
+    for (OnBottomNavTabSelectedListener listener : listeners) {
+      switch (tabIndex) {
+        case TabIndex.SPEED_DIAL:
+          listener.onSpeedDialSelected();
+          break;
+        case TabIndex.CALL_LOG:
+          listener.onCallLogSelected();
+          break;
+        case TabIndex.CONTACTS:
+          listener.onContactsSelected();
+          break;
+        case TabIndex.VOICEMAIL:
+          listener.onVoicemailSelected();
+          break;
+        default:
+          throw Assert.createIllegalStateFailException("Invalid tab: " + tabIndex);
+      }
+    }
   }
 
   public int getSelectedTab() {
diff --git a/java/com/android/dialer/main/impl/MainActivity.java b/java/com/android/dialer/main/impl/MainActivity.java
index 57cc684..b94f075 100644
--- a/java/com/android/dialer/main/impl/MainActivity.java
+++ b/java/com/android/dialer/main/impl/MainActivity.java
@@ -16,10 +16,14 @@
 
 package com.android.dialer.main.impl;
 
+import android.app.Activity;
 import android.app.Fragment;
 import android.app.FragmentManager;
+import android.app.KeyguardManager;
+import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
+import android.database.Cursor;
 import android.net.Uri;
 import android.os.Bundle;
 import android.provider.CallLog.Calls;
@@ -33,6 +37,7 @@
 import com.android.dialer.app.calllog.CallLogAdapter;
 import com.android.dialer.app.calllog.CallLogFragment;
 import com.android.dialer.app.calllog.CallLogFragment.CallLogFragmentListener;
+import com.android.dialer.app.calllog.CallLogNotificationsService;
 import com.android.dialer.app.list.DragDropController;
 import com.android.dialer.app.list.OldSpeedDialFragment;
 import com.android.dialer.app.list.OnDragDropListener;
@@ -52,6 +57,7 @@
 import com.android.dialer.contactsfragment.ContactsFragment;
 import com.android.dialer.contactsfragment.ContactsFragment.Header;
 import com.android.dialer.contactsfragment.ContactsFragment.OnContactSelectedListener;
+import com.android.dialer.database.CallLogQueryHandler;
 import com.android.dialer.database.Database;
 import com.android.dialer.dialpadview.DialpadFragment;
 import com.android.dialer.dialpadview.DialpadFragment.DialpadListener;
@@ -62,6 +68,7 @@
 import com.android.dialer.interactions.PhoneNumberInteraction.InteractionErrorCode;
 import com.android.dialer.interactions.PhoneNumberInteraction.InteractionErrorListener;
 import com.android.dialer.main.impl.BottomNavBar.OnBottomNavTabSelectedListener;
+import com.android.dialer.main.impl.BottomNavBar.TabIndex;
 import com.android.dialer.main.impl.toolbar.MainToolbar;
 import com.android.dialer.postcall.PostCall;
 import com.android.dialer.precall.PreCall;
@@ -73,6 +80,7 @@
 import com.android.dialer.util.TransactionSafeActivity;
 import com.android.dialer.voicemail.listui.NewVoicemailFragment;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.TimeUnit;
 
 /** This is the main activity for dialer. It hosts favorites, call log, search, dialpad, etc... */
 // TODO(calderwoodra): Do not extend TransactionSafeActivity after new SpeedDial is launched
@@ -147,7 +155,11 @@
     MainBottomNavBarBottomNavTabListener bottomNavTabListener =
         new MainBottomNavBarBottomNavTabListener(
             this, getFragmentManager(), getSupportFragmentManager());
-    bottomNav.setOnTabSelectedListener(bottomNavTabListener);
+    bottomNav.addOnTabSelectedListener(bottomNavTabListener);
+
+    callLogFragmentListener =
+        new MainCallLogFragmentListener(this, getContentResolver(), bottomNav);
+    bottomNav.addOnTabSelectedListener(callLogFragmentListener);
 
     searchController = new MainSearchController(this, bottomNav, fab, toolbar);
     toolbar.setSearchBarListener(searchController);
@@ -158,7 +170,7 @@
     callLogAdapterOnActionModeStateChangedListener =
         new MainCallLogAdapterOnActionModeStateChangedListener();
     callLogHostInterface = new MainCallLogHost(searchController, fab);
-    callLogFragmentListener = new MainCallLogFragmentListener();
+
     onListFragmentScrolledListener = new MainOnListFragmentScrolledListener(snackbarContainer);
     onPhoneNumberPickerActionListener = new MainOnPhoneNumberPickerActionListener(this);
     oldSpeedDialFragmentHostInterface =
@@ -179,6 +191,7 @@
   @Override
   protected void onResume() {
     super.onResume();
+    callLogFragmentListener.onActivityResume();
     // Start the thread that updates the smart dial database if the activity is recreated with a
     // language change.
     boolean forceUpdate = !CompatUtils.getLocale(this).getISO3Language().equals(savedLanguageCode);
@@ -186,6 +199,13 @@
     showPostCallPrompt();
   }
 
+  @Override
+  protected void onStop() {
+    super.onStop();
+    callLogFragmentListener.onActivityStop(
+        isChangingConfigurations(), getSystemService(KeyguardManager.class).isKeyguardLocked());
+  }
+
   private void showPostCallPrompt() {
     if (TelecomUtil.isInManagedCall(this)) {
       // No prompt to show if the user is in a call
@@ -417,18 +437,147 @@
     }
   }
 
-  /** @see CallLogFragmentListener */
-  private static final class MainCallLogFragmentListener implements CallLogFragmentListener {
+  /**
+   * Handles the logic for callbacks from:
+   *
+   * <ul>
+   *   <li>{@link CallLogFragment}
+   *   <li>{@link CallLogQueryHandler}
+   *   <li>{@link BottomNavBar}
+   * </ul>
+   *
+   * This mainly entails:
+   *
+   * <ul>
+   *   <li>Handling querying for missed calls/unread voicemails.
+   *   <li>Displaying a badge to the user in the bottom nav when there are missed calls/unread
+   *       voicemails present.
+   *   <li>Marking missed calls as read when appropriate. See {@link
+   *       #markMissedCallsAsReadAndRemoveNotification()}
+   *   <li>TODO(calderwoodra): multiselect
+   *   <li>TODO(calderwoodra): voicemail status
+   * </ul>
+   *
+   * @see CallLogFragmentListener
+   * @see CallLogQueryHandler.Listener
+   * @see OnBottomNavTabSelectedListener
+   */
+  private static final class MainCallLogFragmentListener
+      implements CallLogFragmentListener,
+          CallLogQueryHandler.Listener,
+          OnBottomNavTabSelectedListener {
+
+    private final CallLogQueryHandler callLogQueryHandler;
+    private final BottomNavBar bottomNavBar;
+    private final Context context;
+
+    private @TabIndex int currentTab = TabIndex.SPEED_DIAL;
+    private long timeSelected = -1;
+    private boolean activityIsAlive;
+
+    MainCallLogFragmentListener(
+        Context context, ContentResolver contentResolver, BottomNavBar bottomNavBar) {
+      callLogQueryHandler = new CallLogQueryHandler(context, contentResolver, this);
+      this.bottomNavBar = bottomNavBar;
+      this.context = context;
+    }
 
     @Override
     public void updateTabUnreadCounts() {
-      // TODO(a bug): implement unread counts
+      callLogQueryHandler.fetchMissedCallsUnreadCount();
+      callLogQueryHandler.fetchVoicemailUnreadCount();
     }
 
     @Override
     public void showMultiSelectRemoveView(boolean show) {
       // TODO(a bug): handle multiselect mode
     }
+
+    @Override
+    public void onVoicemailStatusFetched(Cursor statusCursor) {
+      // TODO(calderwoodra): handle this when voicemail is implemented
+    }
+
+    @Override
+    public void onVoicemailUnreadCountFetched(Cursor cursor) {
+      if (activityIsAlive) {
+        bottomNavBar.setNotificationCount(TabIndex.VOICEMAIL, cursor.getCount());
+      }
+      cursor.close();
+    }
+
+    @Override
+    public void onMissedCallsUnreadCountFetched(Cursor cursor) {
+      if (activityIsAlive) {
+        bottomNavBar.setNotificationCount(TabIndex.CALL_LOG, cursor.getCount());
+      }
+      cursor.close();
+    }
+
+    @Override
+    public boolean onCallsFetched(Cursor combinedCursor) {
+      // Return false; did not take ownership of cursor
+      return false;
+    }
+
+    @Override
+    public void onSpeedDialSelected() {
+      setCurrentTab(TabIndex.SPEED_DIAL);
+    }
+
+    @Override
+    public void onCallLogSelected() {
+      setCurrentTab(TabIndex.CALL_LOG);
+    }
+
+    @Override
+    public void onContactsSelected() {
+      setCurrentTab(TabIndex.CONTACTS);
+    }
+
+    @Override
+    public void onVoicemailSelected() {
+      setCurrentTab(TabIndex.VOICEMAIL);
+    }
+
+    private void markMissedCallsAsReadAndRemoveNotification() {
+      callLogQueryHandler.markMissedCallsAsRead();
+      CallLogNotificationsService.cancelAllMissedCalls(context);
+    }
+
+    private void setCurrentTab(@TabIndex int tabIndex) {
+      if (currentTab == TabIndex.CALL_LOG && tabIndex != TabIndex.CALL_LOG) {
+        markMissedCallsAsReadAndRemoveNotification();
+      }
+      currentTab = tabIndex;
+      timeSelected = System.currentTimeMillis();
+    }
+
+    public void onActivityResume() {
+      activityIsAlive = true;
+      callLogQueryHandler.fetchVoicemailStatus();
+      callLogQueryHandler.fetchMissedCallsUnreadCount();
+      // Reset the tab on resume to restart the timer
+      setCurrentTab(bottomNavBar.getSelectedTab());
+    }
+
+    /** Should be called when {@link Activity#onStop()} is called. */
+    public void onActivityStop(boolean changingConfigurations, boolean keyguardLocked) {
+      activityIsAlive = false;
+      if (viewedCallLogTabPastTimeThreshold() && !changingConfigurations && !keyguardLocked) {
+        markMissedCallsAsReadAndRemoveNotification();
+      }
+    }
+
+    /**
+     * Returns true if the user has been (and still is) on the history tab for long than the
+     * threshold.
+     */
+    private boolean viewedCallLogTabPastTimeThreshold() {
+      return currentTab == TabIndex.CALL_LOG
+          && timeSelected != -1
+          && System.currentTimeMillis() - timeSelected > TimeUnit.SECONDS.toMillis(3);
+    }
   }
 
   /** @see OnListFragmentScrolledListener */
diff --git a/java/com/android/dialer/spam/Spam.java b/java/com/android/dialer/spam/Spam.java
index ea1ea13..a79205b 100644
--- a/java/com/android/dialer/spam/Spam.java
+++ b/java/com/android/dialer/spam/Spam.java
@@ -22,8 +22,8 @@
 import com.android.dialer.logging.ContactLookupResult;
 import com.android.dialer.logging.ContactSource;
 import com.android.dialer.logging.ReportingLocation;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.ListenableFuture;
 
 /** Allows the container application to mark calls as spam. */
@@ -45,12 +45,12 @@
   /**
    * Checks if each of numbers in the given list is suspected of being a spam.
    *
-   * @param dialerPhoneNumbers A list of {@link DialerPhoneNumber}.
+   * @param dialerPhoneNumbers A set of {@link DialerPhoneNumber}.
    * @return A {@link ListenableFuture} of a map that maps each number to its spam status
    *     (true/false).
    */
   ListenableFuture<ImmutableMap<DialerPhoneNumber, Boolean>> batchCheckSpamStatus(
-      ImmutableList<DialerPhoneNumber> dialerPhoneNumbers);
+      ImmutableSet<DialerPhoneNumber> dialerPhoneNumbers);
 
   /**
    * Checks if the given number is suspected of being a spam.
diff --git a/java/com/android/dialer/spam/SpamStub.java b/java/com/android/dialer/spam/SpamStub.java
index ac2e943..91a56e8 100644
--- a/java/com/android/dialer/spam/SpamStub.java
+++ b/java/com/android/dialer/spam/SpamStub.java
@@ -21,8 +21,8 @@
 import com.android.dialer.logging.ContactLookupResult;
 import com.android.dialer.logging.ContactSource;
 import com.android.dialer.logging.ReportingLocation;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
@@ -70,7 +70,7 @@
 
   @Override
   public ListenableFuture<ImmutableMap<DialerPhoneNumber, Boolean>> batchCheckSpamStatus(
-      ImmutableList<DialerPhoneNumber> dialerPhoneNumbers) {
+      ImmutableSet<DialerPhoneNumber> dialerPhoneNumbers) {
     return backgroundExecutorService.submit(
         () -> {
           ImmutableMap.Builder<DialerPhoneNumber, Boolean> resultBuilder =
diff --git a/java/com/android/voicemail/impl/CarrierVvmPackageInstalledReceiver.java b/java/com/android/voicemail/impl/CarrierVvmPackageInstalledReceiver.java
index 1b5391d..c9c09b3 100644
--- a/java/com/android/voicemail/impl/CarrierVvmPackageInstalledReceiver.java
+++ b/java/com/android/voicemail/impl/CarrierVvmPackageInstalledReceiver.java
@@ -31,6 +31,6 @@
   public void onReceive(Context context, Intent intent) {
     String packageName = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME);
     VvmLog.i("CarrierVvmPackageInstalledReceiver.onReceive", "package installed: " + packageName);
-    VvmPackageInstallHandler.handlePackageInstalled(context, packageName);
+    VvmPackageInstallHandler.handlePackageInstalled(context);
   }
 }
diff --git a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
index d5cde72..ef62d2a 100644
--- a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
+++ b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java
@@ -178,9 +178,6 @@
     if (protocol == null) {
       return false;
     }
-    if (isCarrierAppPreloaded()) {
-      return false;
-    }
     return true;
   }
 
@@ -248,20 +245,7 @@
     if (!isValid()) {
       return false;
     }
-
-    Set<String> carrierPackages = getCarrierVvmPackageNames();
-    if (carrierPackages == null) {
-      return true;
-    }
-    for (String packageName : carrierPackages) {
-      try {
-        context.getPackageManager().getPackageInfo(packageName, 0);
-        return false;
-      } catch (NameNotFoundException e) {
-        // Do nothing.
-      }
-    }
-    return true;
+    return !isCarrierAppInstalled();
   }
 
   public boolean isCellularDataRequired() {
@@ -511,7 +495,8 @@
     overrideConfigForTest = config;
   }
 
-  private boolean isCarrierAppPreloaded() {
+  /** Checks if the carrier VVM app is installed. */
+  public boolean isCarrierAppInstalled() {
     Set<String> carrierPackages = getCarrierVvmPackageNamesWithoutValidation();
     if (carrierPackages == null) {
       return false;
@@ -522,12 +507,7 @@
         if (!info.enabled) {
           continue;
         }
-        if ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0
-            || (info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
-          VvmLog.i(TAG, packageName + " preloaded, force disabling dialer vvm");
-          return true;
-        }
-
+        return true;
       } catch (NameNotFoundException e) {
         continue;
       }
diff --git a/java/com/android/voicemail/impl/VoicemailClientImpl.java b/java/com/android/voicemail/impl/VoicemailClientImpl.java
index 75d6dfc..993594e 100644
--- a/java/com/android/voicemail/impl/VoicemailClientImpl.java
+++ b/java/com/android/voicemail/impl/VoicemailClientImpl.java
@@ -78,7 +78,8 @@
 
   @Override
   public boolean hasCarrierSupport(Context context, PhoneAccountHandle phoneAccountHandle) {
-    return new OmtpVvmCarrierConfigHelper(context, phoneAccountHandle).isValid();
+    OmtpVvmCarrierConfigHelper config = new OmtpVvmCarrierConfigHelper(context, phoneAccountHandle);
+    return config.isValid() && !config.isCarrierAppInstalled();
   }
 
   @Override
diff --git a/java/com/android/voicemail/impl/VvmPackageInstallHandler.java b/java/com/android/voicemail/impl/VvmPackageInstallHandler.java
index 07900c2..276b788 100644
--- a/java/com/android/voicemail/impl/VvmPackageInstallHandler.java
+++ b/java/com/android/voicemail/impl/VvmPackageInstallHandler.java
@@ -42,7 +42,7 @@
    * Iterates through all phone account and disable VVM on a account if {@code packageName} is
    * listed as a carrier VVM package.
    */
-  public static void handlePackageInstalled(Context context, String packageName) {
+  public static void handlePackageInstalled(Context context) {
     // This get called every time an app is installed and will be noisy. Don't log until the app
     // is identified as a carrier VVM app.
     for (PhoneAccountHandle phoneAccount :
@@ -52,25 +52,11 @@
       if (!carrierConfigHelper.isValid()) {
         continue;
       }
-      if (carrierConfigHelper.getCarrierVvmPackageNames() == null) {
-        continue;
-      }
-      if (!carrierConfigHelper.getCarrierVvmPackageNames().contains(packageName)) {
+      if (!carrierConfigHelper.isCarrierAppInstalled()) {
         continue;
       }
 
-      VvmLog.i("VvmPackageInstallHandler.handlePackageInstalled", "Carrier app installed");
-      if (VisualVoicemailSettingsUtil.isEnabledUserSet(context, phoneAccount)) {
-        // Skip the check if this voicemail source's setting is overridden by the user.
-        VvmLog.i(
-            "VvmPackageInstallHandler.handlePackageInstalled",
-            "VVM enabled by user, not disabling");
-        continue;
-      }
-
-      // Force deactivate the client. The user can re-enable it in the settings.
-      // There is no need to update the settings for deactivation. At this point, if the
-      // default value is used it should be false because a carrier package is present.
+      // Force deactivate the client.
       VvmLog.i(
           "VvmPackageInstallHandler.handlePackageInstalled",
           "Carrier VVM package installed, disabling system VVM client");