Merge "Migrate Test Targets to New Android Ownership Model" into main
diff --git a/Android.bp b/Android.bp
index 2bc2fb0..95b2579 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,6 +12,7 @@
     certificate: "platform",
     libs: ["telephony-common"],
     static_libs: ["android-common", "telephonyprovider-protos"],
+    generate_product_characteristics_rro: true,
 }
 
 filegroup {
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..f3db20e
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,2 @@
+[Hook Scripts]
+checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
diff --git a/assets/latest_carrier_id/carrier_list.pb b/assets/latest_carrier_id/carrier_list.pb
index 528623f..f116087 100644
--- a/assets/latest_carrier_id/carrier_list.pb
+++ b/assets/latest_carrier_id/carrier_list.pb
Binary files differ
diff --git a/assets/latest_carrier_id/carrier_list.textpb b/assets/latest_carrier_id/carrier_list.textpb
index 29dba76..a71451f 100644
--- a/assets/latest_carrier_id/carrier_list.textpb
+++ b/assets/latest_carrier_id/carrier_list.textpb
@@ -4721,9 +4721,8 @@
   canonical_id: 1670
   carrier_name: "MEO"
   carrier_attribute {
-    mccmnc_tuple: "26802"
     mccmnc_tuple: "26806"
-    mccmnc_tuple: "26880"
+    mccmnc_tuple: "26808"
   }
 }
 carrier_id {
@@ -7857,7 +7856,9 @@
     gid1: "554D"
     gid1: "6132"
     gid1: "6303"
+    gid1: "6903"
     gid1: "756D"
+    gid1: "7601"
   }
 }
 carrier_id {
@@ -8458,11 +8459,13 @@
   carrier_name: "Visible"
   carrier_attribute {
     mccmnc_tuple: "311480"
+    mccmnc_tuple: "310590"
     gid1: "bae1000000000000"
     gid2: "1A00000000000000"
   }
   carrier_attribute {
     mccmnc_tuple: "311480"
+    mccmnc_tuple: "310590"
     gid1: "bae2000000000000"
     gid2: "1C00000000000000"
   }
@@ -11593,11 +11596,23 @@
 }
 carrier_id {
   canonical_id: 2575
-  carrier_name: "Reach"
+  carrier_name: "MVNO"
   carrier_attribute {
     mccmnc_tuple: "310280"
+    mccmnc_tuple: "310410"
     mccmnc_tuple: "310950"
-    gid1: "20FF"
+    mccmnc_tuple: "311180"
+    gid1: "20"
+    gid1: "21"
+    gid1: "22"
+    gid1: "23"
+    gid1: "24"
+    gid1: "25"
+    gid1: "26"
+    gid1: "27"
+    gid1: "28"
+    gid1: "29"
+    gid1: "30"
   }
 }
 carrier_id {
@@ -11685,86 +11700,6 @@
   }
 }
 carrier_id {
-  canonical_id: 2584
-  carrier_name: "MVNO #A1"
-  carrier_attribute {
-    mccmnc_tuple: "310280"
-    gid1: "21FF"
-  }
-}
-carrier_id {
-  canonical_id: 2585
-  carrier_name: "MVNO #B1"
-  carrier_attribute {
-    mccmnc_tuple: "310280"
-    gid1: "22FF"
-  }
-}
-carrier_id {
-  canonical_id: 2586
-  carrier_name: "MVNO #C1"
-  carrier_attribute {
-    mccmnc_tuple: "310280"
-    gid1: "23FF"
-  }
-}
-carrier_id {
-  canonical_id: 2587
-  carrier_name: "MVNO #D1"
-  carrier_attribute {
-    mccmnc_tuple: "310280"
-    gid1: "24FF"
-  }
-}
-carrier_id {
-  canonical_id: 2588
-  carrier_name: "MVNO #E1"
-  carrier_attribute {
-    mccmnc_tuple: "310280"
-    gid1: "25FF"
-  }
-}
-carrier_id {
-  canonical_id: 2589
-  carrier_name: "MVNO #F1"
-  carrier_attribute {
-    mccmnc_tuple: "310280"
-    gid1: "26FF"
-  }
-}
-carrier_id {
-  canonical_id: 2590
-  carrier_name: "MVNO #G1"
-  carrier_attribute {
-    mccmnc_tuple: "310280"
-    gid1: "27FF"
-  }
-}
-carrier_id {
-  canonical_id: 2591
-  carrier_name: "MVNO #H1"
-  carrier_attribute {
-    mccmnc_tuple: "310280"
-    gid1: "28FF"
-  }
-}
-carrier_id {
-  canonical_id: 2592
-  carrier_name: "MVNO #I1"
-  carrier_attribute {
-    mccmnc_tuple: "310280"
-    gid1: "29FF"
-  }
-}
-carrier_id {
-  canonical_id: 2593
-  carrier_name: "MVNO #J1"
-  carrier_attribute {
-    mccmnc_tuple: "310280"
-    gid1: "30FF"
-  }
-}
-carrier_id {
   canonical_id: 2594
   carrier_name: "Coriolis ESP"
   carrier_attribute {
@@ -12049,6 +11984,74 @@
   }
 }
 carrier_id {
+  canonical_id: 2623
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "344921"
+  }
+}
+carrier_id {
+  canonical_id: 2624
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "356110"
+  }
+}
+carrier_id {
+  canonical_id: 2625
+  carrier_name: "BTC"
+  carrier_attribute {
+    mccmnc_tuple: "364039"
+  }
+}
+carrier_id {
+  canonical_id: 2626
+  carrier_name: "Digi Portugal"
+  carrier_attribute {
+    mccmnc_tuple: "26802"
+  }
+}
+carrier_id {
+  canonical_id: 2627
+  carrier_name: "Boost"
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6434"
+  }
+}
+carrier_id {
+  canonical_id: 2628
+  carrier_name: "AT&T Private"
+  carrier_attribute {
+    mccmnc_tuple: "310090"
+    mccmnc_tuple: "310280"
+    mccmnc_tuple: "310410"
+    mccmnc_tuple: "310950"
+    mccmnc_tuple: "311180"
+    gid1: "80FF"
+  }
+}
+carrier_id {
+  canonical_id: 2629
+  carrier_name: "Nova Labs, Inc."
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    mccmnc_tuple: "315010"
+    spn: "Helium"
+    gid1: "6907"
+  }
+}
+carrier_id {
+  canonical_id: 2630
+  carrier_name: "Nexphone"
+  carrier_attribute {
+    mccmnc_tuple: "22865"
+    spn: "Nexphone"
+    gid1: "4E657870686F6E65"
+    gid2: "4E657870686F6E6532303234"
+  }
+}
+carrier_id {
   canonical_id: 10000
   carrier_name: "Tracfone-ATT"
   carrier_attribute {
@@ -12446,4 +12449,4 @@
   }
   parent_canonical_id: 2560
 }
-version: 117440545
+version: 117440547
diff --git a/assets/sdk28_carrier_id/carrier_list.pb b/assets/sdk28_carrier_id/carrier_list.pb
index dee957e..61f7174 100644
--- a/assets/sdk28_carrier_id/carrier_list.pb
+++ b/assets/sdk28_carrier_id/carrier_list.pb
Binary files differ
diff --git a/assets/sdk28_carrier_id/carrier_list.textpb b/assets/sdk28_carrier_id/carrier_list.textpb
index f5f5702..e43cd38 100644
--- a/assets/sdk28_carrier_id/carrier_list.textpb
+++ b/assets/sdk28_carrier_id/carrier_list.textpb
@@ -5243,6 +5243,9 @@
   carrier_attribute {
     mccmnc_tuple: "26880"
   }
+  carrier_attribute {
+    mccmnc_tuple: "26808"
+  }
 }
 carrier_id {
   canonical_id: 1671
@@ -8739,6 +8742,14 @@
     mccmnc_tuple: "310240"
     gid1: "756D"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6903"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "7601"
+  }
 }
 carrier_id {
   canonical_id: 2086
@@ -12514,7 +12525,7 @@
 }
 carrier_id {
   canonical_id: 2575
-  carrier_name: "Reach"
+  carrier_name: "MVNO"
   carrier_attribute {
     mccmnc_tuple: "310280"
     gid1: "20FF"
@@ -12523,6 +12534,94 @@
     mccmnc_tuple: "310950"
     gid1: "20FF"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "20"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "21"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "22"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "23"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "24"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "25"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "26"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "27"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "28"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "29"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "30"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "20"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "21"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "22"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "23"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "24"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "25"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "26"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "27"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "28"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "29"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "30"
+  }
 }
 carrier_id {
   canonical_id: 2576
@@ -12987,6 +13086,74 @@
   }
 }
 carrier_id {
+  canonical_id: 2623
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "344921"
+  }
+}
+carrier_id {
+  canonical_id: 2624
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "356110"
+  }
+}
+carrier_id {
+  canonical_id: 2625
+  carrier_name: "BTC"
+  carrier_attribute {
+    mccmnc_tuple: "364039"
+  }
+}
+carrier_id {
+  canonical_id: 2627
+  carrier_name: "Boost"
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6434"
+  }
+}
+carrier_id {
+  canonical_id: 2628
+  carrier_name: "AT&T Private"
+  carrier_attribute {
+    mccmnc_tuple: "310280"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310950"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "80FF"
+  }
+}
+carrier_id {
+  canonical_id: 2629
+  carrier_name: "Nova Labs, Inc."
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    spn: "Helium"
+    gid1: "6907"
+  }
+}
+carrier_id {
+  canonical_id: 2630
+  carrier_name: "Nexphone"
+  carrier_attribute {
+    mccmnc_tuple: "22865"
+    spn: "Nexphone"
+    gid1: "4E657870686F6E65"
+    gid2: "4E657870686F6E6532303234"
+  }
+}
+carrier_id {
   canonical_id: 10000
   carrier_name: "Tracfone-ATT"
   carrier_attribute {
@@ -13228,4 +13395,4 @@
   }
   parent_canonical_id: 2023
 }
-version: 41
+version: 43
diff --git a/assets/sdk29_carrier_id/carrier_list.pb b/assets/sdk29_carrier_id/carrier_list.pb
index 9ba0ca9..26bc66a 100644
--- a/assets/sdk29_carrier_id/carrier_list.pb
+++ b/assets/sdk29_carrier_id/carrier_list.pb
Binary files differ
diff --git a/assets/sdk29_carrier_id/carrier_list.textpb b/assets/sdk29_carrier_id/carrier_list.textpb
index 567d383..8db712d 100644
--- a/assets/sdk29_carrier_id/carrier_list.textpb
+++ b/assets/sdk29_carrier_id/carrier_list.textpb
@@ -5082,6 +5082,9 @@
   carrier_attribute {
     mccmnc_tuple: "26880"
   }
+  carrier_attribute {
+    mccmnc_tuple: "26808"
+  }
 }
 carrier_id {
   canonical_id: 1671
@@ -8478,6 +8481,14 @@
     mccmnc_tuple: "310240"
     gid1: "756D"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6903"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "7601"
+  }
 }
 carrier_id {
   canonical_id: 2086
@@ -12354,7 +12365,7 @@
 }
 carrier_id {
   canonical_id: 2575
-  carrier_name: "Reach"
+  carrier_name: "MVNO"
   carrier_attribute {
     mccmnc_tuple: "310280"
     gid1: "20FF"
@@ -12363,6 +12374,94 @@
     mccmnc_tuple: "310950"
     gid1: "20FF"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "20"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "21"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "22"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "23"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "24"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "25"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "26"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "27"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "28"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "29"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "30"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "20"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "21"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "22"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "23"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "24"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "25"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "26"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "27"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "28"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "29"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "30"
+  }
 }
 carrier_id {
   canonical_id: 2576
@@ -12901,6 +13000,74 @@
   }
 }
 carrier_id {
+  canonical_id: 2623
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "344921"
+  }
+}
+carrier_id {
+  canonical_id: 2624
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "356110"
+  }
+}
+carrier_id {
+  canonical_id: 2625
+  carrier_name: "BTC"
+  carrier_attribute {
+    mccmnc_tuple: "364039"
+  }
+}
+carrier_id {
+  canonical_id: 2627
+  carrier_name: "Boost"
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6434"
+  }
+}
+carrier_id {
+  canonical_id: 2628
+  carrier_name: "AT&T Private"
+  carrier_attribute {
+    mccmnc_tuple: "310280"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310950"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "80FF"
+  }
+}
+carrier_id {
+  canonical_id: 2629
+  carrier_name: "Nova Labs, Inc."
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    spn: "Helium"
+    gid1: "6907"
+  }
+}
+carrier_id {
+  canonical_id: 2630
+  carrier_name: "Nexphone"
+  carrier_attribute {
+    mccmnc_tuple: "22865"
+    spn: "Nexphone"
+    gid1: "4E657870686F6E65"
+    gid2: "4E657870686F6E6532303234"
+  }
+}
+carrier_id {
   canonical_id: 10000
   carrier_name: "Tracfone-ATT"
   carrier_attribute {
@@ -13141,4 +13308,4 @@
   }
   parent_canonical_id: 2023
 }
-version: 16777265
+version: 16777267
diff --git a/assets/sdk30_carrier_id/carrier_list.pb b/assets/sdk30_carrier_id/carrier_list.pb
index f0b5ec4..e1dae5b 100644
--- a/assets/sdk30_carrier_id/carrier_list.pb
+++ b/assets/sdk30_carrier_id/carrier_list.pb
Binary files differ
diff --git a/assets/sdk30_carrier_id/carrier_list.textpb b/assets/sdk30_carrier_id/carrier_list.textpb
index 2c00c6a..555064b 100644
--- a/assets/sdk30_carrier_id/carrier_list.textpb
+++ b/assets/sdk30_carrier_id/carrier_list.textpb
@@ -5080,6 +5080,9 @@
     mccmnc_tuple: "26806"
     mccmnc_tuple: "26880"
   }
+  carrier_attribute {
+    mccmnc_tuple: "26808"
+  }
 }
 carrier_id {
   canonical_id: 1671
@@ -8445,6 +8448,14 @@
     mccmnc_tuple: "310240"
     gid1: "756D"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6903"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "7601"
+  }
 }
 carrier_id {
   canonical_id: 2086
@@ -12332,7 +12343,7 @@
 }
 carrier_id {
   canonical_id: 2575
-  carrier_name: "Reach"
+  carrier_name: "MVNO"
   carrier_attribute {
     mccmnc_tuple: "310280"
     gid1: "20FF"
@@ -12341,6 +12352,94 @@
     mccmnc_tuple: "310950"
     gid1: "20FF"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "20"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "21"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "22"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "23"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "24"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "25"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "26"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "27"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "28"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "29"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "30"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "20"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "21"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "22"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "23"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "24"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "25"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "26"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "27"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "28"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "29"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "30"
+  }
 }
 carrier_id {
   canonical_id: 2576
@@ -12879,6 +12978,78 @@
   }
 }
 carrier_id {
+  canonical_id: 2623
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "344921"
+  }
+}
+carrier_id {
+  canonical_id: 2624
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "356110"
+  }
+}
+carrier_id {
+  canonical_id: 2625
+  carrier_name: "BTC"
+  carrier_attribute {
+    mccmnc_tuple: "364039"
+  }
+}
+carrier_id {
+  canonical_id: 2627
+  carrier_name: "Boost"
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6434"
+  }
+}
+carrier_id {
+  canonical_id: 2628
+  carrier_name: "AT&T Private"
+  carrier_attribute {
+    mccmnc_tuple: "310090"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310280"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310950"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "80FF"
+  }
+}
+carrier_id {
+  canonical_id: 2629
+  carrier_name: "Nova Labs, Inc."
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    spn: "Helium"
+    gid1: "6907"
+  }
+}
+carrier_id {
+  canonical_id: 2630
+  carrier_name: "Nexphone"
+  carrier_attribute {
+    mccmnc_tuple: "22865"
+    spn: "Nexphone"
+    gid1: "4E657870686F6E65"
+    gid2: "4E657870686F6E6532303234"
+  }
+}
+carrier_id {
   canonical_id: 10000
   carrier_name: "Tracfone-ATT"
   carrier_attribute {
@@ -13139,4 +13310,4 @@
   }
   parent_canonical_id: 2023
 }
-version: 33554499
+version: 33554501
diff --git a/assets/sdk31_carrier_id/carrier_list.pb b/assets/sdk31_carrier_id/carrier_list.pb
index 29a23e9..ff57589 100644
--- a/assets/sdk31_carrier_id/carrier_list.pb
+++ b/assets/sdk31_carrier_id/carrier_list.pb
Binary files differ
diff --git a/assets/sdk31_carrier_id/carrier_list.textpb b/assets/sdk31_carrier_id/carrier_list.textpb
index 119b654..f6a4429 100644
--- a/assets/sdk31_carrier_id/carrier_list.textpb
+++ b/assets/sdk31_carrier_id/carrier_list.textpb
@@ -4817,6 +4817,9 @@
     mccmnc_tuple: "26806"
     mccmnc_tuple: "26880"
   }
+  carrier_attribute {
+    mccmnc_tuple: "26808"
+  }
 }
 carrier_id {
   canonical_id: 1671
@@ -8174,6 +8177,14 @@
     mccmnc_tuple: "310240"
     gid1: "756D"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6903"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "7601"
+  }
 }
 carrier_id {
   canonical_id: 2086
@@ -8806,6 +8817,16 @@
     mccmnc_tuple: "311480"
     gid1: "bae2000000000000"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310590"
+    gid1: "bae1000000000000"
+    gid2: "1A00000000000000"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310590"
+    gid1: "bae2000000000000"
+    gid2: "1C00000000000000"
+  }
 }
 carrier_id {
   canonical_id: 2147
@@ -12017,7 +12038,7 @@
 }
 carrier_id {
   canonical_id: 2575
-  carrier_name: "Reach"
+  carrier_name: "MVNO"
   carrier_attribute {
     mccmnc_tuple: "310280"
     gid1: "20FF"
@@ -12026,6 +12047,94 @@
     mccmnc_tuple: "310950"
     gid1: "20FF"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "20"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "21"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "22"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "23"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "24"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "25"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "26"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "27"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "28"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "29"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "30"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "20"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "21"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "22"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "23"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "24"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "25"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "26"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "27"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "28"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "29"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "30"
+  }
 }
 carrier_id {
   canonical_id: 2576
@@ -12568,6 +12677,78 @@
   }
 }
 carrier_id {
+  canonical_id: 2623
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "344921"
+  }
+}
+carrier_id {
+  canonical_id: 2624
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "356110"
+  }
+}
+carrier_id {
+  canonical_id: 2625
+  carrier_name: "BTC"
+  carrier_attribute {
+    mccmnc_tuple: "364039"
+  }
+}
+carrier_id {
+  canonical_id: 2627
+  carrier_name: "Boost"
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6434"
+  }
+}
+carrier_id {
+  canonical_id: 2628
+  carrier_name: "AT&T Private"
+  carrier_attribute {
+    mccmnc_tuple: "310090"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310280"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310950"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "80FF"
+  }
+}
+carrier_id {
+  canonical_id: 2629
+  carrier_name: "Nova Labs, Inc."
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    spn: "Helium"
+    gid1: "6907"
+  }
+}
+carrier_id {
+  canonical_id: 2630
+  carrier_name: "Nexphone"
+  carrier_attribute {
+    mccmnc_tuple: "22865"
+    spn: "Nexphone"
+    gid1: "4E657870686F6E65"
+    gid2: "4E657870686F6E6532303234"
+  }
+}
+carrier_id {
   canonical_id: 10000
   carrier_name: "Tracfone-ATT"
   carrier_attribute {
@@ -12868,4 +13049,4 @@
   }
   parent_canonical_id: 1894
 }
-version: 50331691
+version: 50331693
diff --git a/assets/sdk33_carrier_id/carrier_list.pb b/assets/sdk33_carrier_id/carrier_list.pb
index e9b6524..9021753 100644
--- a/assets/sdk33_carrier_id/carrier_list.pb
+++ b/assets/sdk33_carrier_id/carrier_list.pb
Binary files differ
diff --git a/assets/sdk33_carrier_id/carrier_list.textpb b/assets/sdk33_carrier_id/carrier_list.textpb
index b1fe638..3cdd182 100644
--- a/assets/sdk33_carrier_id/carrier_list.textpb
+++ b/assets/sdk33_carrier_id/carrier_list.textpb
@@ -4760,6 +4760,9 @@
     mccmnc_tuple: "26806"
     mccmnc_tuple: "26880"
   }
+  carrier_attribute {
+    mccmnc_tuple: "26808"
+  }
 }
 carrier_id {
   canonical_id: 1671
@@ -7964,6 +7967,14 @@
     mccmnc_tuple: "310240"
     gid1: "756D"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6903"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "7601"
+  }
 }
 carrier_id {
   canonical_id: 2086
@@ -8571,6 +8582,16 @@
     gid1: "bae2000000000000"
     gid2: "1C00000000000000"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310590"
+    gid1: "bae1000000000000"
+    gid2: "1A00000000000000"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310590"
+    gid1: "bae2000000000000"
+    gid2: "1C00000000000000"
+  }
 }
 carrier_id {
   canonical_id: 2147
@@ -11712,7 +11733,7 @@
 }
 carrier_id {
   canonical_id: 2575
-  carrier_name: "Reach"
+  carrier_name: "MVNO"
   carrier_attribute {
     mccmnc_tuple: "310280"
     gid1: "20FF"
@@ -11721,6 +11742,94 @@
     mccmnc_tuple: "310950"
     gid1: "20FF"
   }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "20"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "21"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "22"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "23"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "24"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "25"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "26"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "27"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "28"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "29"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "30"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "20"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "21"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "22"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "23"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "24"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "25"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "26"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "27"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "28"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "29"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "30"
+  }
 }
 carrier_id {
   canonical_id: 2576
@@ -12303,6 +12412,83 @@
   }
 }
 carrier_id {
+  canonical_id: 2623
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "344921"
+  }
+}
+carrier_id {
+  canonical_id: 2624
+  carrier_name: "FLOW"
+  carrier_attribute {
+    mccmnc_tuple: "356110"
+  }
+}
+carrier_id {
+  canonical_id: 2625
+  carrier_name: "BTC"
+  carrier_attribute {
+    mccmnc_tuple: "364039"
+  }
+}
+carrier_id {
+  canonical_id: 2627
+  carrier_name: "Boost"
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    gid1: "6434"
+  }
+}
+carrier_id {
+  canonical_id: 2628
+  carrier_name: "AT&T Private"
+  carrier_attribute {
+    mccmnc_tuple: "310090"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310280"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310410"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "310950"
+    gid1: "80FF"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "311180"
+    gid1: "80FF"
+  }
+}
+carrier_id {
+  canonical_id: 2629
+  carrier_name: "Nova Labs, Inc."
+  carrier_attribute {
+    mccmnc_tuple: "310240"
+    spn: "Helium"
+    gid1: "6907"
+  }
+  carrier_attribute {
+    mccmnc_tuple: "315010"
+    spn: "Helium"
+    gid1: "6907"
+  }
+}
+carrier_id {
+  canonical_id: 2630
+  carrier_name: "Nexphone"
+  carrier_attribute {
+    mccmnc_tuple: "22865"
+    spn: "Nexphone"
+    gid1: "4E657870686F6E65"
+    gid2: "4E657870686F6E6532303234"
+  }
+}
+carrier_id {
   canonical_id: 10000
   carrier_name: "Tracfone-ATT"
   carrier_attribute {
@@ -12678,4 +12864,4 @@
   }
   parent_canonical_id: 2560
 }
-version: 100663329
+version: 100663331
diff --git a/src/com/android/providers/telephony/MmsProvider.java b/src/com/android/providers/telephony/MmsProvider.java
index 28c9074..c1358f0 100644
--- a/src/com/android/providers/telephony/MmsProvider.java
+++ b/src/com/android/providers/telephony/MmsProvider.java
@@ -56,7 +56,6 @@
 import android.util.Log;
 
 import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.telephony.TelephonyPermissions;
 import com.android.internal.telephony.util.TelephonyUtils;
 
 import com.google.android.mms.pdu.PduHeaders;
@@ -127,6 +126,7 @@
             String selection, String[] selectionArgs, String sortOrder) {
         final int callerUid = Binder.getCallingUid();
         final UserHandle callerUserHandle = Binder.getCallingUserHandle();
+        String callingPackage = getCallingPackage();
         // First check if a restricted view of the "pdu" table should be used based on the
         // caller's identity. Only system, phone or the default sms app can have full access
         // of mms data. For other apps, we present a restricted view which only contains sent
@@ -295,10 +295,17 @@
         Cursor ret;
         try {
             SQLiteDatabase db = mOpenHelper.getReadableDatabase();
+            if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+                ((MmsSmsDatabaseHelper) mOpenHelper).addDatabaseOpeningDebugLog(
+                        callingPackage + ";MmsProvider.query;" + uri, true);
+            }
             ret = qb.query(db, projection, selection,
                     selectionArgs, null, null, finalSortOrder);
         } catch (SQLiteException e) {
             Log.e(TAG, "returning NULL cursor, query: " + uri, e);
+            if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+                ((MmsSmsDatabaseHelper) mOpenHelper).printDatabaseOpeningDebugLog();
+            }
             return null;
         }
 
@@ -427,6 +434,10 @@
         }
 
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+        if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) mOpenHelper).addDatabaseOpeningDebugLog(
+                    callerPkg + ";MmsProvider.insert;" + uri, false);
+        }
         ContentValues finalValues;
         Uri res = Mms.CONTENT_URI;
         Uri caseSpecificUri = null;
@@ -445,7 +456,7 @@
         }
 
         if (table.equals(TABLE_PDU)) {
-            if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(getContext(), subId,
+            if (!ProviderUtil.allowInteractingWithEntryOfSubscription(getContext(), subId,
                     callerUserHandle)) {
                 TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(getContext(), subId,
                         callerUid, callerPkg);
@@ -495,6 +506,9 @@
 
             if ((rowId = db.insert(table, null, finalValues)) <= 0) {
                 Log.e(TAG, "MmsProvider.insert: failed!");
+                if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+                    ((MmsSmsDatabaseHelper) mOpenHelper).printDatabaseOpeningDebugLog();
+                }
                 return null;
             }
 
@@ -510,6 +524,9 @@
 
             if ((rowId = db.insert(table, null, finalValues)) <= 0) {
                 Log.e(TAG, "Failed to insert address");
+                if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+                    ((MmsSmsDatabaseHelper) mOpenHelper).printDatabaseOpeningDebugLog();
+                }
                 return null;
             }
 
@@ -622,6 +639,9 @@
 
             if ((rowId = db.insert(table, null, finalValues)) <= 0) {
                 Log.e(TAG, "MmsProvider.insert: failed!");
+                if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+                    ((MmsSmsDatabaseHelper) mOpenHelper).printDatabaseOpeningDebugLog();
+                }
                 return null;
             }
 
@@ -676,6 +696,9 @@
 
             if ((rowId = db.insert(table, null, finalValues)) <= 0) {
                 Log.e(TAG, "MmsProvider.insert: failed!");
+                if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+                    ((MmsSmsDatabaseHelper) mOpenHelper).printDatabaseOpeningDebugLog();
+                }
                 return null;
             }
             res = Uri.parse(res + "/drm/" + rowId);
@@ -713,6 +736,7 @@
             String[] selectionArgs) {
         final UserHandle callerUserHandle = Binder.getCallingUserHandle();
         int match = sURLMatcher.match(uri);
+        String callingPackage = getCallingPackage();
         if (LOCAL_LOGV) {
             Log.v(TAG, "Delete uri=" + uri + ", match=" + match);
         }
@@ -767,6 +791,10 @@
 
         String finalSelection = concatSelections(selection, extraSelection);
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+        if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) mOpenHelper).addDatabaseOpeningDebugLog(
+                    callingPackage + ";MmsProvider.insert;" + uri, false);
+        }
         int deletedRows = 0;
 
         final long token = Binder.clearCallingIdentity();
@@ -998,6 +1026,10 @@
 
         String finalSelection = concatSelections(selection, extraSelection);
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+        if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) mOpenHelper).addDatabaseOpeningDebugLog(
+                    callerPkg + ";MmsProvider.update;" + uri, false);
+        }
         int count = db.update(table, finalValues, finalSelection, selectionArgs);
         if (notify && (count > 0)) {
             notifyChange(uri, null);
diff --git a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
index dbbd138..f00618f 100644
--- a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
+++ b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
@@ -18,6 +18,7 @@
 
 import static com.android.providers.telephony.SmsProvider.NO_ERROR_CODE;
 
+import android.annotation.NonNull;
 import android.content.BroadcastReceiver;
 import android.content.ContentValues;
 import android.content.Context;
@@ -47,6 +48,7 @@
 import android.provider.Telephony.Threads;
 import android.telephony.AnomalyReporter;
 import android.telephony.SubscriptionManager;
+import android.text.format.DateFormat;
 import android.util.Log;
 
 import com.android.internal.annotations.VisibleForTesting;
@@ -63,6 +65,7 @@
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -269,6 +272,10 @@
 
     private final Context mContext;
     private LowStorageMonitor mLowStorageMonitor;
+    private final List<String> mDatabaseReadOpeningInfos = new ArrayList<>();
+    private final List<String> mDatabaseWriteOpeningInfos = new ArrayList<>();
+    private final Object mDatabaseOpeningInfoLock = new Object();
+    private static final int MAX_DATABASE_OPENING_INFO_STORED = 10;
 
     // SharedPref key used to check if initial create has been done (if onCreate has already been
     // called once)
@@ -278,6 +285,8 @@
 
     private static final UUID CREATE_CALLED_MULTIPLE_TIMES_UUID = UUID.fromString(
         "6ead002e-c001-4c05-9bca-67d7c4e29782");
+    private static final UUID DATABASE_OPENING_EXCEPTION_UUID = UUID.fromString(
+            "de3f61e1-ecd8-41ee-b059-9282b294b235");
 
     /**
      * The primary purpose of this DatabaseErrorHandler is to broadcast an intent on corruption and
@@ -2182,7 +2191,13 @@
 
     @Override
     public synchronized  SQLiteDatabase getReadableDatabase() {
-        SQLiteDatabase db = super.getWritableDatabase();
+        SQLiteDatabase db;
+        try {
+            db = super.getWritableDatabase();
+        } catch (SQLiteException ex) {
+            reportAnomalyForDatabaseOpeningException(ex);
+            throw ex;
+        }
 
         // getReadableDatabase gets or creates a database. So we know for sure that a database has
         // already been created at this point.
@@ -2195,7 +2210,13 @@
 
     @Override
     public synchronized SQLiteDatabase getWritableDatabase() {
-        SQLiteDatabase db = super.getWritableDatabase();
+        SQLiteDatabase db;
+        try {
+            db = super.getWritableDatabase();
+        } catch (SQLiteException ex) {
+            reportAnomalyForDatabaseOpeningException(ex);
+            throw ex;
+        }
 
         // getWritableDatabase gets or creates a database. So we know for sure that a database has
         // already been created at this point.
@@ -2540,4 +2561,70 @@
         Log.d(TAG, "tableName: " + table + " columnName: " + column + " isExists: " + isExists);
         return isExists;
     }
+
+    /**
+     * Add the MMS/SMS database opening info to the debug log.
+     */
+    public void addDatabaseOpeningDebugLog(@NonNull String databaseOpeningLog, boolean isQuery) {
+        if (!ProviderUtil.sFeatureFlag.logMmsSmsDatabaseAccessInfo()) {
+            return;
+        }
+        addDatabaseOpeningDebugLog(isQuery ? mDatabaseReadOpeningInfos : mDatabaseWriteOpeningInfos,
+                databaseOpeningLog);
+    }
+
+    /**
+     * Print the MMS/SMS database opening debug log to file.
+     */
+    public void printDatabaseOpeningDebugLog() {
+        if (!ProviderUtil.sFeatureFlag.logMmsSmsDatabaseAccessInfo()) {
+            return;
+        }
+        Log.e(TAG, "MMS/SMS database read opening info: "
+                + getDatabaseOpeningInfo(mDatabaseReadOpeningInfos));
+        Log.e(TAG, "MMS/SMS database write opening info: "
+                + getDatabaseOpeningInfo(mDatabaseWriteOpeningInfos));
+        ProviderUtil.logRunningTelephonyProviderProcesses(mContext);
+    }
+
+    private void addDatabaseOpeningDebugLog(List<String> databaseOpeningInfos,
+            @NonNull String callingPackage) {
+        synchronized (mDatabaseOpeningInfoLock) {
+            if (databaseOpeningInfos.size() >= MAX_DATABASE_OPENING_INFO_STORED) {
+                databaseOpeningInfos.remove(0);
+            }
+            databaseOpeningInfos.add(buildDatabaseOpeningInfoStr(callingPackage));
+        }
+    }
+
+    private String buildDatabaseOpeningInfoStr(@NonNull String databaseOpeningLog) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(DateFormat.format(
+                "MM-dd HH:mm:ss.mmm", System.currentTimeMillis()).toString());
+        sb.append(" ");
+        sb.append(databaseOpeningLog);
+        return sb.toString();
+    }
+
+    private String getDatabaseOpeningInfo(List<String> databaseOpeningInfos) {
+        synchronized (mDatabaseOpeningInfoLock) {
+            StringBuilder sb = new StringBuilder();
+            for (String databaseOpeningInfo : databaseOpeningInfos) {
+                sb.append("{");
+                sb.append(databaseOpeningInfo);
+                sb.append("}");
+            }
+            return sb.toString();
+        }
+    }
+
+    private void reportAnomalyForDatabaseOpeningException(@NonNull Exception ex) {
+        if (!ProviderUtil.sFeatureFlag.logMmsSmsDatabaseAccessInfo()) {
+            return;
+        }
+        Log.e(TAG, "DatabaseOpeningException=" + ex);
+        printDatabaseOpeningDebugLog();
+        AnomalyReporter.reportAnomaly(DATABASE_OPENING_EXCEPTION_UUID,
+                "MmsSmsDatabaseHelper: Got exception in opening SQLite database");
+    }
 }
diff --git a/src/com/android/providers/telephony/MmsSmsProvider.java b/src/com/android/providers/telephony/MmsSmsProvider.java
index 1d45803..c3af98a 100644
--- a/src/com/android/providers/telephony/MmsSmsProvider.java
+++ b/src/com/android/providers/telephony/MmsSmsProvider.java
@@ -46,7 +46,6 @@
 import android.text.TextUtils;
 import android.util.Log;
 
-import com.android.internal.telephony.TelephonyPermissions;
 import com.android.internal.telephony.TelephonyStatsLog;
 import com.android.internal.telephony.util.TelephonyUtils;
 
@@ -340,6 +339,7 @@
             String selection, String[] selectionArgs, String sortOrder) {
         final int callerUid = Binder.getCallingUid();
         final UserHandle callerUserHandle = Binder.getCallingUserHandle();
+        String callingPackage = getCallingPackage();
 
         // First check if restricted views of the "sms" and "pdu" tables should be used based on the
         // caller's identity. Only system, phone or the default sms app can have full access
@@ -370,6 +370,10 @@
         }
 
         SQLiteDatabase db = mOpenHelper.getReadableDatabase();
+        if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) mOpenHelper).addDatabaseOpeningDebugLog(
+                    callingPackage + ";MmsSmsProvider.query;" + uri, true);
+        }
         Cursor cursor = null;
         Cursor emptyCursor = new MatrixCursor((projection == null) ?
                 (new String[] {}) : projection);
@@ -847,6 +851,9 @@
             db.setTransactionSuccessful();
         } catch (Throwable ex) {
             Log.e(LOG_TAG, ex.getMessage(), ex);
+            if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+                ((MmsSmsDatabaseHelper) mOpenHelper).printDatabaseOpeningDebugLog();
+            }
             TelephonyStatsLog.write(
                 TelephonyStatsLog.MMS_SMS_PROVIDER_GET_THREAD_ID_FAILED,
                 FAILURE_FIND_OR_CREATE_THREAD_ID_SQL);
@@ -1371,6 +1378,10 @@
         }
 
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+        if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) mOpenHelper).addDatabaseOpeningDebugLog(
+                    getCallingPackage() + ";MmsSmsProvider.delete;" + uri, false);
+        }
         Context context = getContext();
         int affectedRows = 0;
 
@@ -1442,8 +1453,12 @@
         final UserHandle callerUserHandle = Binder.getCallingUserHandle();
         final int callerUid = Binder.getCallingUid();
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-        int matchIndex = URI_MATCHER.match(uri);
+        if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) mOpenHelper).addDatabaseOpeningDebugLog(
+                    getCallingPackage() + ";MmsSmsProvider.insert;" + uri, false);
+        }
 
+        int matchIndex = URI_MATCHER.match(uri);
         // TODO (b/256992531): Currently, one sim card is set as default sms subId in work
         //  profile. Default sms subId should be updated based on user pref.
         int defaultSmsSubId = SmsManager.getDefaultSmsSubscriptionId();
@@ -1458,8 +1473,9 @@
                 }
             }
 
-            if (!TelephonyPermissions
-                    .checkSubscriptionAssociatedWithUser(getContext(), subId, callerUserHandle)) {
+            if (!ProviderUtil
+                    .allowInteractingWithEntryOfSubscription(getContext(), subId,
+                            callerUserHandle)) {
                 TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(getContext(), subId,
                         callerUid, getCallingPackage());
                 return null;
@@ -1497,6 +1513,11 @@
         }
 
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+        if (mOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) mOpenHelper).addDatabaseOpeningDebugLog(
+                    callerPkg + ";MmsSmsProvider.update;" + uri, false);
+        }
+
         int affectedRows = 0;
         switch(URI_MATCHER.match(uri)) {
             case URI_CONVERSATIONS_MESSAGES:
diff --git a/src/com/android/providers/telephony/ProviderUtil.java b/src/com/android/providers/telephony/ProviderUtil.java
index fe3ba24..ac6e5f7 100644
--- a/src/com/android/providers/telephony/ProviderUtil.java
+++ b/src/com/android/providers/telephony/ProviderUtil.java
@@ -18,12 +18,12 @@
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
+import android.app.ActivityManager;
 import android.content.ComponentName;
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
-import android.os.Binder;
 import android.os.Process;
 import android.os.UserHandle;
 import android.os.UserManager;
@@ -36,8 +36,12 @@
 import android.util.Log;
 
 import com.android.internal.telephony.SmsApplication;
+import com.android.internal.telephony.TelephonyPermissions;
+import com.android.internal.telephony.flags.FeatureFlags;
+import com.android.internal.telephony.flags.FeatureFlagsImpl;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -47,6 +51,10 @@
  */
 public class ProviderUtil {
     private final static String TAG = "SmsProvider";
+    private static final String TELEPHONY_PROVIDER_PACKAGE = "com.android.providers.telephony";
+    private static final int PHONE_UID = 1001;
+    /** Feature flags for Provider features. */
+    public static final FeatureFlags sFeatureFlag = new FeatureFlagsImpl();
 
     /**
      * Check if a caller of the provider has restricted access,
@@ -149,23 +157,52 @@
      * or {@code null} if user is not associated with any subscription.
      */
     @Nullable
-    public static String getSelectionBySubIds(Context context, @NonNull UserHandle userHandle) {
+    public static String getSelectionBySubIds(Context context,
+            @NonNull final UserHandle userHandle) {
         List<SubscriptionInfo> associatedSubscriptionsList = new ArrayList<>();
         SubscriptionManager subManager = context.getSystemService(SubscriptionManager.class);
-        if (subManager != null) {
-            // Get list of subscriptions associated with this user.
-            associatedSubscriptionsList = subManager
-                    .getSubscriptionInfoListAssociatedWithUser(userHandle);
-        }
-
         UserManager userManager = context.getSystemService(UserManager.class);
-        if ((userManager != null) && (!userManager.isManagedProfile(userHandle.getIdentifier()))) {
-            // SMS/MMS restored from another device have sub_id=-1.
-            // To query/update/delete those messages, sub_id=-1 should be in the selection string.
-            SubscriptionInfo invalidSubInfo = new SubscriptionInfo.Builder()
-                    .setId(SubscriptionManager.INVALID_SUBSCRIPTION_ID)
-                    .build();
-            associatedSubscriptionsList.add(invalidSubInfo);
+
+        if (sFeatureFlag.workProfileApiSplit()) {
+            if (subManager != null) {
+                // Get list of subscriptions accessible to this user.
+                associatedSubscriptionsList = subManager
+                        .getSubscriptionInfoListAssociatedWithUser(userHandle);
+
+                if ((userManager != null)
+                        && userManager.isManagedProfile(userHandle.getIdentifier())) {
+                    // Work profile caller can only see subscriptions explicitly associated with it.
+                    associatedSubscriptionsList = associatedSubscriptionsList.stream()
+                            .filter(info -> userHandle.equals(subManager
+                                            .getSubscriptionUserHandle(info.getSubscriptionId())))
+                            .collect(Collectors.toList());
+                } else {
+                    // SMS/MMS restored from another device have sub_id=-1.
+                    // To query/update/delete those messages, sub_id=-1 should be in the selection
+                    // string.
+                    SubscriptionInfo invalidSubInfo = new SubscriptionInfo.Builder()
+                            .setId(SubscriptionManager.INVALID_SUBSCRIPTION_ID)
+                            .build();
+                    associatedSubscriptionsList.add(invalidSubInfo);
+                }
+            }
+        } else {
+            if (subManager != null) {
+                // Get list of subscriptions associated with this user.
+                associatedSubscriptionsList = subManager
+                        .getSubscriptionInfoListAssociatedWithUser(userHandle);
+            }
+
+            if ((userManager != null)
+                    && (!userManager.isManagedProfile(userHandle.getIdentifier()))) {
+                // SMS/MMS restored from another device have sub_id=-1.
+                // To query/update/delete those messages, sub_id=-1 should be in the selection
+                // string.
+                SubscriptionInfo invalidSubInfo = new SubscriptionInfo.Builder()
+                        .setId(SubscriptionManager.INVALID_SUBSCRIPTION_ID)
+                        .build();
+                associatedSubscriptionsList.add(invalidSubInfo);
+            }
         }
 
         if (associatedSubscriptionsList.isEmpty()) {
@@ -220,4 +257,54 @@
         }
         return selectionByEmergencyNumber;
     }
+
+    /**
+     * Check sub is either default value(for backup restore) or is accessible by the caller profile.
+     * @param ctx Context
+     * @param subId The sub Id associated with the entry
+     * @param callerUserHandle The user handle of the caller profile
+     * @return {@code true} if allow the caller to insert an entry that's associated with this sub.
+     */
+    public static boolean allowInteractingWithEntryOfSubscription(Context ctx,
+            int subId, UserHandle callerUserHandle) {
+        if (sFeatureFlag.rejectBadSubIdInteraction()) {
+            return TelephonyPermissions
+                    .checkSubscriptionAssociatedWithUser(ctx, subId, callerUserHandle)
+                    // INVALID_SUBSCRIPTION_ID represents backup restore.
+                    || subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+        } else {
+            return TelephonyPermissions.checkSubscriptionAssociatedWithUser(ctx, subId,
+                    callerUserHandle);
+        }
+    }
+
+    /**
+     * Log all running processes of the telephony provider package.
+     */
+    public static void logRunningTelephonyProviderProcesses(@NonNull Context context) {
+        if (!sFeatureFlag.logMmsSmsDatabaseAccessInfo()) {
+            return;
+        }
+
+        ActivityManager am = context.getSystemService(ActivityManager.class);
+        List<ActivityManager.RunningAppProcessInfo> processInfos = am.getRunningAppProcesses();
+        StringBuilder sb = new StringBuilder();
+        for (ActivityManager.RunningAppProcessInfo processInfo : processInfos) {
+            if (Arrays.asList(processInfo.pkgList).contains(TELEPHONY_PROVIDER_PACKAGE)
+                    || processInfo.uid == PHONE_UID) {
+                sb.append("{ProcessName=");
+                sb.append(processInfo.processName);
+                sb.append(";PID=");
+                sb.append(processInfo.pid);
+                sb.append(";UID=");
+                sb.append(processInfo.uid);
+                sb.append(";pkgList=");
+                for (String pkg : processInfo.pkgList) {
+                    sb.append(pkg + ";");
+                }
+                sb.append("}");
+            }
+        }
+        Log.d(TAG, "RunningTelephonyProviderProcesses:" + sb.toString());
+    }
 }
diff --git a/src/com/android/providers/telephony/SmsProvider.java b/src/com/android/providers/telephony/SmsProvider.java
index 579b59d..0819e29 100644
--- a/src/com/android/providers/telephony/SmsProvider.java
+++ b/src/com/android/providers/telephony/SmsProvider.java
@@ -132,6 +132,7 @@
     @Override
     public Cursor query(Uri url, String[] projectionIn, String selection,
             String[] selectionArgs, String sort) {
+        String callingPackage = getCallingPackage();
         final int callingUid = Binder.getCallingUid();
         final UserHandle callerUserHandle = Binder.getCallingUserHandle();
 
@@ -160,6 +161,11 @@
         // Generate the body of the query.
         int match = sURLMatcher.match(url);
         SQLiteDatabase db = getReadableDatabase(match);
+        SQLiteOpenHelper sqLiteOpenHelper = getDBOpenHelper(match);
+        if (sqLiteOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) sqLiteOpenHelper).addDatabaseOpeningDebugLog(
+                    callingPackage + ";SmsProvider.query;" + url, true);
+        }
         switch (match) {
             case SMS_ALL:
                 constructQueryForBox(qb, Sms.MESSAGE_TYPE_ALL, smsTable);
@@ -280,60 +286,58 @@
                 break;
 
             case SMS_ALL_ICC:
-            case SMS_ALL_ICC_SUBID:
-                {
-                    int subId;
-                    if (match == SMS_ALL_ICC) {
-                        subId = SmsManager.getDefaultSmsSubscriptionId();
-                    } else {
-                        try {
-                            subId = Integer.parseInt(url.getPathSegments().get(1));
-                        } catch (NumberFormatException e) {
-                            throw new IllegalArgumentException("Wrong path segements, uri= " + url);
-                        }
-                    }
-
-                    if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(getContext(),
-                            subId, callerUserHandle)) {
-                        // If subId is not associated with user, return empty cursor.
-                        return emptyCursor;
-                    }
-
-                    Cursor ret = getAllMessagesFromIcc(subId);
-                    ret.setNotificationUri(getContext().getContentResolver(),
-                            match == SMS_ALL_ICC ? ICC_URI : ICC_SUBID_URI);
-                    return ret;
-                }
-
-            case SMS_ICC:
-            case SMS_ICC_SUBID:
-                {
-                    int subId;
-                    int messageIndex;
+            case SMS_ALL_ICC_SUBID: {
+                int subId;
+                if (match == SMS_ALL_ICC) {
+                    subId = SmsManager.getDefaultSmsSubscriptionId();
+                } else {
                     try {
-                        if (match == SMS_ICC) {
-                            subId = SmsManager.getDefaultSmsSubscriptionId();
-                            messageIndex = Integer.parseInt(url.getPathSegments().get(1));
-                        } else {
-                            subId = Integer.parseInt(url.getPathSegments().get(1));
-                            messageIndex = Integer.parseInt(url.getPathSegments().get(2));
-                        }
+                        subId = Integer.parseInt(url.getPathSegments().get(1));
                     } catch (NumberFormatException e) {
                         throw new IllegalArgumentException("Wrong path segements, uri= " + url);
                     }
-
-                    if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(getContext(),
-                            subId, callerUserHandle)) {
-                        // If subId is not associated with user, return empty cursor.
-                        return emptyCursor;
-                    }
-
-                    Cursor ret = getSingleMessageFromIcc(subId, messageIndex);
-                    ret.setNotificationUri(getContext().getContentResolver(),
-                            match == SMS_ICC ? ICC_URI : ICC_SUBID_URI);
-                    return ret;
                 }
 
+                if (!ProviderUtil.allowInteractingWithEntryOfSubscription(getContext(),
+                        subId, callerUserHandle)) {
+                    // If subId is not associated with user, return empty cursor.
+                    return emptyCursor;
+                }
+
+                Cursor ret = getAllMessagesFromIcc(subId);
+                ret.setNotificationUri(getContext().getContentResolver(),
+                        match == SMS_ALL_ICC ? ICC_URI : ICC_SUBID_URI);
+                return ret;
+            }
+
+            case SMS_ICC:
+            case SMS_ICC_SUBID: {
+                int subId;
+                int messageIndex;
+                try {
+                    if (match == SMS_ICC) {
+                        subId = SmsManager.getDefaultSmsSubscriptionId();
+                        messageIndex = Integer.parseInt(url.getPathSegments().get(1));
+                    } else {
+                        subId = Integer.parseInt(url.getPathSegments().get(1));
+                        messageIndex = Integer.parseInt(url.getPathSegments().get(2));
+                    }
+                } catch (NumberFormatException e) {
+                    throw new IllegalArgumentException("Wrong path segements, uri= " + url);
+                }
+
+                if (!ProviderUtil.allowInteractingWithEntryOfSubscription(getContext(),
+                        subId, callerUserHandle)) {
+                    // If subId is not associated with user, return empty cursor.
+                    return emptyCursor;
+                }
+
+                Cursor ret = getSingleMessageFromIcc(subId, messageIndex);
+                ret.setNotificationUri(getContext().getContentResolver(),
+                        match == SMS_ICC ? ICC_URI : ICC_SUBID_URI);
+                return ret;
+            }
+
             default:
                 Log.e(TAG, "Invalid request: " + url);
                 return null;
@@ -703,7 +707,7 @@
                     }
                 }
 
-                if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(getContext(), subId,
+                if (!ProviderUtil.allowInteractingWithEntryOfSubscription(getContext(), subId,
                     callerUserHandle)) {
                     TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(getContext(),
                         subId, callerUid, callerPkg);
@@ -743,6 +747,11 @@
         }
 
         SQLiteDatabase db = getWritableDatabase(match);
+        SQLiteOpenHelper sqLiteOpenHelper = getDBOpenHelper(match);
+        if (sqLiteOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) sqLiteOpenHelper).addDatabaseOpeningDebugLog(
+                    callerPkg + ";SmsProvider.insert;" + url, false);
+        }
 
         if (table.equals(TABLE_SMS)) {
             boolean addDate = false;
@@ -857,8 +866,16 @@
                 address = values.getAsString(Sms.ADDRESS);
             }
 
-            if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(getContext(), subId,
-                    callerUserHandle, address)) {
+            if (ProviderUtil.sFeatureFlag.rejectBadSubIdInteraction()) {
+                if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
+                        && !TelephonyPermissions.checkSubscriptionAssociatedWithUser(getContext(),
+                        subId, callerUserHandle, address)) {
+                    TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(getContext(),
+                            subId, callerUid, callerPkg);
+                    return null;
+                }
+            } else if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(getContext(),
+                    subId, callerUserHandle, address)) {
                 TelephonyUtils.showSwitchToManagedProfileDialogIfAppropriate(getContext(), subId,
                         callerUid, callerPkg);
                 return null;
@@ -895,6 +912,9 @@
             return uri;
         } else {
             Log.e(TAG, "insert: failed!");
+            if (sqLiteOpenHelper instanceof MmsSmsDatabaseHelper) {
+                ((MmsSmsDatabaseHelper) sqLiteOpenHelper).printDatabaseOpeningDebugLog();
+            }
         }
 
         return null;
@@ -989,6 +1009,11 @@
         int count;
         int match = sURLMatcher.match(url);
         SQLiteDatabase db = getWritableDatabase(match);
+        SQLiteOpenHelper sqLiteOpenHelper = getDBOpenHelper(match);
+        if (sqLiteOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) sqLiteOpenHelper).addDatabaseOpeningDebugLog(
+                    getCallingPackage() + ";SmsProvider.delete;" + url, false);
+        }
         boolean notifyIfNotDefault = true;
         switch (match) {
             case SMS_ALL:
@@ -1064,76 +1089,74 @@
                 break;
 
             case SMS_ALL_ICC:
-            case SMS_ALL_ICC_SUBID:
-                {
-                    int subId;
-                    int deletedCnt;
-                    if (match == SMS_ALL_ICC) {
-                        subId = SmsManager.getDefaultSmsSubscriptionId();
-                    } else {
-                        try {
-                            subId = Integer.parseInt(url.getPathSegments().get(1));
-                        } catch (NumberFormatException e) {
-                            throw new IllegalArgumentException("Wrong path segements, uri= " + url);
-                        }
-                    }
-
-                    if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(getContext(),
-                            subId, callerUserHandle)) {
-                        // If subId is not associated with user, return 0.
-                        return 0;
-                    }
-
-                    deletedCnt = deleteAllMessagesFromIcc(subId);
-                    // Notify changes even failure case since there might be some changes should be
-                    // known.
-                    getContext()
-                            .getContentResolver()
-                            .notifyChange(
-                                    match == SMS_ALL_ICC ? ICC_URI : ICC_SUBID_URI,
-                                    null,
-                                    true,
-                                    UserHandle.USER_ALL);
-                    return deletedCnt;
-                }
-
-            case SMS_ICC:
-            case SMS_ICC_SUBID:
-                {
-                    int subId;
-                    int messageIndex;
-                    boolean success;
+            case SMS_ALL_ICC_SUBID: {
+                int subId;
+                int deletedCnt;
+                if (match == SMS_ALL_ICC) {
+                    subId = SmsManager.getDefaultSmsSubscriptionId();
+                } else {
                     try {
-                        if (match == SMS_ICC) {
-                            subId = SmsManager.getDefaultSmsSubscriptionId();
-                            messageIndex = Integer.parseInt(url.getPathSegments().get(1));
-                        } else {
-                            subId = Integer.parseInt(url.getPathSegments().get(1));
-                            messageIndex = Integer.parseInt(url.getPathSegments().get(2));
-                        }
+                        subId = Integer.parseInt(url.getPathSegments().get(1));
                     } catch (NumberFormatException e) {
                         throw new IllegalArgumentException("Wrong path segements, uri= " + url);
                     }
-
-                    if (!TelephonyPermissions.checkSubscriptionAssociatedWithUser(getContext(),
-                            subId, callerUserHandle)) {
-                        // If subId is not associated with user, return 0.
-                        return 0;
-                    }
-
-                    success = deleteMessageFromIcc(subId, messageIndex);
-                    // Notify changes even failure case since there might be some changes should be
-                    // known.
-                    getContext()
-                            .getContentResolver()
-                            .notifyChange(
-                                    match == SMS_ICC ? ICC_URI : ICC_SUBID_URI,
-                                    null,
-                                    true,
-                                    UserHandle.USER_ALL);
-                    return success ? 1 : 0; // return deleted count
                 }
 
+                if (!ProviderUtil.allowInteractingWithEntryOfSubscription(getContext(),
+                        subId, callerUserHandle)) {
+                    // If subId is not associated with user, return 0.
+                    return 0;
+                }
+
+                deletedCnt = deleteAllMessagesFromIcc(subId);
+                // Notify changes even failure case since there might be some changes should be
+                // known.
+                getContext()
+                        .getContentResolver()
+                        .notifyChange(
+                                match == SMS_ALL_ICC ? ICC_URI : ICC_SUBID_URI,
+                                null,
+                                true,
+                                UserHandle.USER_ALL);
+                return deletedCnt;
+            }
+
+            case SMS_ICC:
+            case SMS_ICC_SUBID: {
+                int subId;
+                int messageIndex;
+                boolean success;
+                try {
+                    if (match == SMS_ICC) {
+                        subId = SmsManager.getDefaultSmsSubscriptionId();
+                        messageIndex = Integer.parseInt(url.getPathSegments().get(1));
+                    } else {
+                        subId = Integer.parseInt(url.getPathSegments().get(1));
+                        messageIndex = Integer.parseInt(url.getPathSegments().get(2));
+                    }
+                } catch (NumberFormatException e) {
+                    throw new IllegalArgumentException("Wrong path segements, uri= " + url);
+                }
+
+                if (!ProviderUtil.allowInteractingWithEntryOfSubscription(getContext(),
+                        subId, callerUserHandle)) {
+                    // If subId is not associated with user, return 0.
+                    return 0;
+                }
+
+                success = deleteMessageFromIcc(subId, messageIndex);
+                // Notify changes even failure case since there might be some changes should be
+                // known.
+                getContext()
+                        .getContentResolver()
+                        .notifyChange(
+                                match == SMS_ICC ? ICC_URI : ICC_SUBID_URI,
+                                null,
+                                true,
+                                UserHandle.USER_ALL);
+                return success ? 1 : 0; // return deleted count
+            }
+
             default:
                 throw new IllegalArgumentException("Unknown URL");
         }
@@ -1209,6 +1232,11 @@
         boolean notifyIfNotDefault = true;
         int match = sURLMatcher.match(url);
         SQLiteDatabase db = getWritableDatabase(match);
+        SQLiteOpenHelper sqLiteOpenHelper = getDBOpenHelper(match);
+        if (sqLiteOpenHelper instanceof MmsSmsDatabaseHelper) {
+            ((MmsSmsDatabaseHelper) sqLiteOpenHelper).addDatabaseOpeningDebugLog(
+                    callerPkg + ";SmsProvider.update;" + url, false);
+        }
 
         switch (match) {
             case SMS_RAW_MESSAGE:
diff --git a/src/com/android/providers/telephony/TelephonyBackupAgent.java b/src/com/android/providers/telephony/TelephonyBackupAgent.java
index bc9b388..2f14238 100644
--- a/src/com/android/providers/telephony/TelephonyBackupAgent.java
+++ b/src/com/android/providers/telephony/TelephonyBackupAgent.java
@@ -304,7 +304,8 @@
 
         sDefaultValuesMms.put(Telephony.Mms.READ, 1);
         sDefaultValuesMms.put(Telephony.Mms.SEEN, 1);
-        sDefaultValuesMms.put(Telephony.Mms.SUBSCRIPTION_ID, -1);
+        sDefaultValuesMms.put(Telephony.Mms.SUBSCRIPTION_ID,
+                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
         sDefaultValuesMms.put(Telephony.Mms.MESSAGE_BOX, Telephony.Mms.MESSAGE_BOX_ALL);
         sDefaultValuesMms.put(Telephony.Mms.TEXT_ONLY, 1);
 
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 99daa52..4fbeed4 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -32,6 +32,8 @@
 import static android.provider.Telephony.Carriers.CURRENT;
 import static android.provider.Telephony.Carriers.DEFAULT_SORT_ORDER;
 import static android.provider.Telephony.Carriers.EDITED_STATUS;
+import static android.provider.Telephony.Carriers.INFRASTRUCTURE_BITMASK;
+import static android.provider.Telephony.Carriers.ESIM_BOOTSTRAP_PROVISIONING;
 import static android.provider.Telephony.Carriers.LINGERING_NETWORK_TYPE_BITMASK;
 import static android.provider.Telephony.Carriers.MAX_CONNECTIONS;
 import static android.provider.Telephony.Carriers.MCC;
@@ -162,7 +164,7 @@
     private static final boolean DBG = true;
     private static final boolean VDBG = false; // STOPSHIP if true
 
-    private static final int DATABASE_VERSION = 62 << 16;
+    private static final int DATABASE_VERSION = 67 << 16;
     private static final int URL_UNKNOWN = 0;
     private static final int URL_TELEPHONY = 1;
     private static final int URL_CURRENT = 2;
@@ -375,7 +377,7 @@
         // Columns not included in UNIQUE constraint: name, current, edited, user, server, password,
         // authtype, type, protocol, roaming_protocol, sub_id, modem_cognitive, max_conns,
         // wait_time, max_conns_time, mtu, mtu_v4, mtu_v6, bearer_bitmask, user_visible,
-        // network_type_bitmask, skip_464xlat, lingering_network_type_bitmask, always_on
+        // network_type_bitmask, skip_464xlat, lingering_network_type_bitmask, always_on.
         CARRIERS_UNIQUE_FIELDS_DEFAULTS.put(NUMERIC, "");
         CARRIERS_UNIQUE_FIELDS_DEFAULTS.put(MCC, "");
         CARRIERS_UNIQUE_FIELDS_DEFAULTS.put(MNC, "");
@@ -397,6 +399,10 @@
         CARRIERS_UNIQUE_FIELDS_DEFAULTS.put(APN_SET_ID, String.valueOf(NO_APN_SET_ID));
         CARRIERS_UNIQUE_FIELDS_DEFAULTS.put(CARRIER_ID,
                 String.valueOf(TelephonyManager.UNKNOWN_CARRIER_ID));
+        CARRIERS_UNIQUE_FIELDS_DEFAULTS.put(INFRASTRUCTURE_BITMASK,
+                String.valueOf(
+                        ApnSetting.INFRASTRUCTURE_CELLULAR | ApnSetting.INFRASTRUCTURE_SATELLITE));
+        CARRIERS_UNIQUE_FIELDS_DEFAULTS.put(ESIM_BOOTSTRAP_PROVISIONING, "0");
 
         CARRIERS_UNIQUE_FIELDS.addAll(CARRIERS_UNIQUE_FIELDS_DEFAULTS.keySet());
 
@@ -407,8 +413,9 @@
         CARRIERS_BOOLEAN_FIELDS.add(MODEM_PERSIST);
         CARRIERS_BOOLEAN_FIELDS.add(USER_VISIBLE);
         CARRIERS_BOOLEAN_FIELDS.add(USER_EDITABLE);
+        CARRIERS_BOOLEAN_FIELDS.add(ESIM_BOOTSTRAP_PROVISIONING);
 
-        MVNO_TYPE_STRING_MAP = new ArrayMap<String, Integer>();
+        MVNO_TYPE_STRING_MAP = new ArrayMap<>();
         MVNO_TYPE_STRING_MAP.put("spn", ApnSetting.MVNO_TYPE_SPN);
         MVNO_TYPE_STRING_MAP.put("imsi", ApnSetting.MVNO_TYPE_IMSI);
         MVNO_TYPE_STRING_MAP.put("gid", ApnSetting.MVNO_TYPE_GID);
@@ -450,6 +457,13 @@
                 Cursor.FIELD_TYPE_INTEGER);
         SIM_INFO_COLUMNS_TO_BACKUP.put(
                 Telephony.SimInfo.COLUMN_ENABLED_MOBILE_DATA_POLICIES, Cursor.FIELD_TYPE_STRING);
+        SIM_INFO_COLUMNS_TO_BACKUP.put(
+                Telephony.SimInfo.COLUMN_SATELLITE_ENABLED, Cursor.FIELD_TYPE_INTEGER);
+        SIM_INFO_COLUMNS_TO_BACKUP.put(
+                Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
+                Cursor.FIELD_TYPE_INTEGER);
+        SIM_INFO_COLUMNS_TO_BACKUP.put(
+                Telephony.SimInfo.COLUMN_IS_NTN, Cursor.FIELD_TYPE_INTEGER);
     }
 
     @VisibleForTesting
@@ -499,6 +513,8 @@
                 APN_SET_ID + " INTEGER DEFAULT " + NO_APN_SET_ID + "," +
                 SKIP_464XLAT + " INTEGER DEFAULT " + SKIP_464XLAT_DEFAULT + "," +
                 ALWAYS_ON + " INTEGER DEFAULT 0," +
+                INFRASTRUCTURE_BITMASK + " INTEGER DEFAULT 3," +
+                ESIM_BOOTSTRAP_PROVISIONING + " BOOLEAN DEFAULT 0," +
                 // Uniqueness collisions are used to trigger merge code so if a field is listed
                 // here it means we will accept both (user edited + new apn_conf definition)
                 // Columns not included in UNIQUE constraint: name, current, edited,
@@ -590,7 +606,10 @@
                 "  INTEGER DEFAULT -1,"
                 + Telephony.SimInfo.COLUMN_USER_HANDLE + " INTEGER DEFAULT "
                 + UserHandle.USER_NULL + ","
-                + Telephony.SimInfo.COLUMN_SATELLITE_ENABLED + " INTEGER DEFAULT -1"
+                + Telephony.SimInfo.COLUMN_SATELLITE_ENABLED + " INTEGER DEFAULT 0,"
+                + Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
+                + " INTEGER DEFAULT 0, "
+                + Telephony.SimInfo.COLUMN_IS_NTN + " INTEGER DEFAULT 0"
                 + ");";
     }
 
@@ -1900,7 +1919,7 @@
                     // Try to update the siminfo table with new columns.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
                             + Telephony.SimInfo.COLUMN_SATELLITE_ENABLED
-                            + "  INTEGER DEFAULT -1;");
+                            + "  INTEGER DEFAULT 0;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade failed to update " + SIMINFO_TABLE
@@ -1909,6 +1928,93 @@
                 }
                 oldVersion = 62 << 16 | 6;
             }
+
+            if (oldVersion < (63 << 16 | 6)) {
+                try {
+                    // Try to update the siminfo table with new columns.
+                    db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
+                            + Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
+                            + "  INTEGER DEFAULT 0;");
+                } catch (SQLiteException e) {
+                    if (DBG) {
+                        log("onUpgrade failed to update " + SIMINFO_TABLE
+                                + " to add satellite attach for carrier enabled by user. ");
+                    }
+                }
+                oldVersion = 63 << 16 | 6;
+            }
+
+            if (oldVersion < (64 << 16 | 6)) {
+                try {
+                    /* If default value of COLUMN_SATELLITE_ENABLED column is set to -1, then update
+                     it to 0 */
+                    db.execSQL("UPDATE " + SIMINFO_TABLE + " SET "
+                            + Telephony.SimInfo.COLUMN_SATELLITE_ENABLED + "=0"
+                            + "  WHERE " + Telephony.SimInfo.COLUMN_SATELLITE_ENABLED + "=-1;");
+                    /* If default value of COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER column is set
+                     to -1, then update it to 0 */
+                    db.execSQL("UPDATE " + SIMINFO_TABLE + " SET "
+                            + Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER + "=0"
+                            + "  WHERE "
+                            + Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
+                            + "=-1;");
+
+                    // Try to update the siminfo table with new columns.
+                    db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
+                            + Telephony.SimInfo.COLUMN_IS_NTN
+                            + "  INTEGER DEFAULT 0;");
+                } catch (SQLiteException e) {
+                    if (DBG) {
+                        log("onUpgrade failed to update " + SIMINFO_TABLE
+                                + " to add satellite is ntn. ");
+                    }
+                }
+                oldVersion = 64 << 16 | 6;
+            }
+
+            if (oldVersion < (65 << 16 | 6)) {
+                try {
+                    db.execSQL("ALTER TABLE " + CARRIERS_TABLE + " ADD COLUMN "
+                            + INFRASTRUCTURE_BITMASK + " INTEGER DEFAULT 1;");
+                } catch (SQLiteException e) {
+                    if (DBG) {
+                        log("onUpgrade failed to update " + CARRIERS_TABLE
+                                + " to add infrastructure bitmask value.");
+                    }
+                }
+                oldVersion = 65 << 16 | 6;
+            }
+
+            if (oldVersion < (66 << 16 | 6)) {
+                try {
+                    // Try to add new field ESIM_BOOTSTRAP_PROVISIONING
+                    db.execSQL("ALTER TABLE " + CARRIERS_TABLE + " ADD COLUMN "
+                            + ESIM_BOOTSTRAP_PROVISIONING + " INTEGER DEFAULT 0;");
+                } catch (SQLiteException e) {
+                    if (DBG) {
+                        log("onUpgrade failed to update " + CARRIERS_TABLE
+                                    + " to add esim bootstrap provisioning flag");
+                    }
+
+                }
+                oldVersion = 66 << 16 | 6;
+            }
+
+            if (oldVersion < (67 << 16 | 6)) {
+                try {
+                    // If default value of infrastructure_bitmask column is set to 1, then update
+                    // it to 3
+                    db.execSQL("UPDATE " + CARRIERS_TABLE + " SET " + INFRASTRUCTURE_BITMASK + "=3"
+                            + "  WHERE " + INFRASTRUCTURE_BITMASK + "=1;");
+                } catch (SQLiteException e) {
+                    if (DBG) {
+                        log("onUpgrade failed to update " + CARRIERS_TABLE
+                                + " to add infrastructure bitmask value.");
+                    }
+                }
+                oldVersion = 67 << 16 | 6;
+            }
+
             if (DBG) {
                 log("dbh.onUpgrade:- db=" + db + " oldV=" + oldVersion + " newV=" + newVersion);
             }
@@ -2357,6 +2463,8 @@
             getIntValueFromCursor(cv, c, APN_SET_ID);
             getIntValueFromCursor(cv, c, SKIP_464XLAT);
             getIntValueFromCursor(cv, c, ALWAYS_ON);
+            getIntValueFromCursor(cv, c, INFRASTRUCTURE_BITMASK);
+            getIntValueFromCursor(cv, c, ESIM_BOOTSTRAP_PROVISIONING);
         }
 
         private void copyPreservedApnsToNewTable(SQLiteDatabase db, Cursor c) {
@@ -2581,6 +2689,16 @@
             addBoolAttribute(parser, "user_visible", map, USER_VISIBLE);
             addBoolAttribute(parser, "user_editable", map, USER_EDITABLE);
             addBoolAttribute(parser, "always_on", map, ALWAYS_ON);
+            addBoolAttribute(parser, "esim_bootstrap_provisioning", map,
+                    ESIM_BOOTSTRAP_PROVISIONING);
+
+            int infrastructureBitmask =
+                    ApnSetting.INFRASTRUCTURE_CELLULAR | ApnSetting.INFRASTRUCTURE_SATELLITE;
+            String infrastructureList = parser.getAttributeValue(null, "infrastructure_bitmask");
+            if (infrastructureList != null) {
+                infrastructureBitmask = getInfrastructureListFromString(infrastructureList);
+            }
+            map.put(INFRASTRUCTURE_BITMASK, infrastructureBitmask);
 
             int networkTypeBitmask = 0;
             String networkTypeList = parser.getAttributeValue(null, "network_type_bitmask");
@@ -3166,8 +3284,8 @@
                 Context.MODE_PRIVATE);
         mManagedApnEnforced = spEnforcedFile.getBoolean(ENFORCED_KEY, false);
 
+        ProviderUtil.logRunningTelephonyProviderProcesses(getContext());
         if (VDBG) log("onCreate:- ret true");
-
         return true;
     }
 
@@ -3770,7 +3888,7 @@
                 PersistableBundle backedUpSimInfoEntry, int backupDataFormatVersion,
                 String isoCountryCodeFromDb,
                 List<String> wfcRestoreBlockedCountries) {
-            if (DATABASE_VERSION != 62 << 16) {
+            if (DATABASE_VERSION != 67 << 16) {
                 throw new AssertionError("The database schema has been updated which might make "
                     + "the format of #BACKED_UP_SIM_SPECIFIC_SETTINGS_FILE outdated. Make sure to "
                     + "1) review whether any of the columns in #SIM_INFO_COLUMNS_TO_BACKUP have "
@@ -3812,6 +3930,23 @@
              * Also make sure to add necessary removal of sensitive settings in
              * polishContentValues(ContentValues contentValues).
              */
+            if (backupDataFormatVersion >= 64 << 16) {
+                contentValues.put(Telephony.SimInfo.COLUMN_IS_NTN,
+                        backedUpSimInfoEntry.getInt(Telephony.SimInfo.COLUMN_IS_NTN,
+                                DEFAULT_INT_COLUMN_VALUE));
+            }
+            if (backupDataFormatVersion >= 63 << 16) {
+                contentValues.put(Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
+                        backedUpSimInfoEntry.getInt(
+                                Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
+                                DEFAULT_INT_COLUMN_VALUE));
+            }
+            if (backupDataFormatVersion >= 62 << 16) {
+                contentValues.put(Telephony.SimInfo.COLUMN_SATELLITE_ENABLED,
+                        backedUpSimInfoEntry.getInt(
+                                Telephony.SimInfo.COLUMN_SATELLITE_ENABLED,
+                                DEFAULT_INT_COLUMN_VALUE));
+            }
             if (backupDataFormatVersion >= 60 << 16) {
                 contentValues.put(Telephony.SimInfo.COLUMN_ENABLED_MOBILE_DATA_POLICIES,
                         backedUpSimInfoEntry.getString(
@@ -3822,7 +3957,7 @@
                 contentValues.put(Telephony.SimInfo.COLUMN_USAGE_SETTING,
                         backedUpSimInfoEntry.getInt(
                                 Telephony.SimInfo.COLUMN_USAGE_SETTING,
-                                SubscriptionManager.USAGE_SETTING_UNKNOWN));
+                                DEFAULT_INT_COLUMN_VALUE));
             }
             if (backupDataFormatVersion >= 52 << 16) {
                 contentValues.put(Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED,
@@ -5426,7 +5561,7 @@
     private static int getMvnoTypeIntFromString(String mvnoType) {
         String mvnoTypeString = TextUtils.isEmpty(mvnoType) ? mvnoType : mvnoType.toLowerCase(Locale.ROOT);
         Integer mvnoTypeInt = MVNO_TYPE_STRING_MAP.get(mvnoTypeString);
-        return  mvnoTypeInt == null ? 0 : mvnoTypeInt;
+        return  mvnoTypeInt == null ? ApnSetting.MVNO_TYPE_UNKNOWN : mvnoTypeInt;
     }
 
     private static int getBitmaskFromString(String bearerList) {
@@ -5449,6 +5584,30 @@
     }
 
     /**
+     * Get the infrastructure bitmask from string
+     *
+     * @param infrastructureString The infrastructure list in string format. For example
+     * {@code "cellular|satellite"}.
+     *
+     * @return The infrastructure bitmask.
+     */
+    private static int getInfrastructureListFromString(@NonNull String infrastructureString) {
+        String[] infras = infrastructureString.split("\\|");
+        int infrastructureBitmask = 0;
+        for (String infrastructure : infras) {
+            switch (infrastructure.toLowerCase(Locale.ROOT)) {
+                case "cellular":
+                    infrastructureBitmask |= ApnSetting.INFRASTRUCTURE_CELLULAR;
+                    break;
+                case "satellite":
+                    infrastructureBitmask |= ApnSetting.INFRASTRUCTURE_SATELLITE;
+                    break;
+            }
+        }
+        return infrastructureBitmask;
+    }
+
+    /**
      * Transform RIL radio technology value to Network
      * type bitmask{@link android.telephony.TelephonyManager.NetworkTypeBitMask}.
      *
diff --git a/tests/src/com/android/providers/telephony/ProviderUtilTest.java b/tests/src/com/android/providers/telephony/ProviderUtilTest.java
index 1e3020c..d031c13 100644
--- a/tests/src/com/android/providers/telephony/ProviderUtilTest.java
+++ b/tests/src/com/android/providers/telephony/ProviderUtilTest.java
@@ -17,10 +17,8 @@
 package com.android.providers.telephony;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.any;
-import static org.mockito.ArgumentMatchers.eq;
+
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
@@ -33,12 +31,15 @@
 
 import androidx.test.core.app.ApplicationProvider;
 
+import com.android.internal.telephony.flags.FeatureFlags;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
+import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -51,8 +52,11 @@
     private SubscriptionManager mSubscriptionManager;
     @Mock
     private TelephonyManager mTelephonyManager;
+    @Mock
+    private FeatureFlags mMockFeatureFlag;
 
     private Map<Integer, List<EmergencyNumber>> mEmergencyNumberList;
+    private FeatureFlags mRealFeatureFlagToBeRestored;
 
     @Before
     public void setUp() throws Exception {
@@ -61,10 +65,16 @@
 
         when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
         when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
+        replaceFeatureFlag(mMockFeatureFlag);
+
+        doReturn(true).when(mMockFeatureFlag).workProfileApiSplit();
     }
 
     @After
     public void tearDown() throws Exception {
+        replaceFeatureFlag(mRealFeatureFlagToBeRestored);
+        mEmergencyNumberList = null;
+        mRealFeatureFlagToBeRestored = null;
     }
 
     @Test
@@ -146,4 +156,21 @@
         assertThat(ProviderUtil.getSelectionByEmergencyNumbers(mContext))
                 .isEqualTo("address IN ('911','112')");
     }
-}
\ No newline at end of file
+
+    @Test
+    public void allowInteractWithEntryOfSubId_flag_enabled() {
+        doReturn(true).when(mMockFeatureFlag).rejectBadSubIdInteraction();
+
+        assertThat(ProviderUtil.allowInteractingWithEntryOfSubscription(mContext,
+                SubscriptionManager.INVALID_SUBSCRIPTION_ID, UserHandle.SYSTEM)).isTrue();
+    }
+
+    private synchronized void replaceFeatureFlag(final FeatureFlags newValue)
+            throws Exception {
+        Field field = ProviderUtil.class.getDeclaredField("sFeatureFlag");
+        field.setAccessible(true);
+
+        mRealFeatureFlagToBeRestored = ProviderUtil.sFeatureFlag;
+        field.set(null, newValue);
+    }
+}
diff --git a/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java b/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
index 26a3a46..8ca3cd5 100644
--- a/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
@@ -31,6 +31,7 @@
 import android.os.UserHandle;
 import android.provider.Telephony;
 import android.telephony.SubscriptionManager;
+import android.telephony.data.ApnSetting;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -476,6 +477,122 @@
                 Telephony.SimInfo.COLUMN_SATELLITE_ENABLED));
     }
 
+    @Test
+    public void databaseHelperOnUpgrade_hasSatelliteAttachEnabledForCarrierField() {
+        Log.d(TAG, "databaseHelperOnUpgrade_hasSatelliteAttachEnabledForCarrierField");
+        // (5 << 16 | 6) is the first upgrade trigger in onUpgrade
+        SQLiteDatabase db = mInMemoryDbHelper.getWritableDatabase();
+        mHelper.onUpgrade(db, (4 << 16), TelephonyProvider.getVersion(mContext));
+
+        // the upgraded db must have
+        // Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
+        Cursor cursor = db.query("siminfo", null, null, null, null, null, null);
+        String[] upgradedColumns = cursor.getColumnNames();
+        Log.d(TAG, "siminfo columns: " + Arrays.toString(upgradedColumns));
+
+        assertTrue(Arrays.asList(upgradedColumns).contains(
+                Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER));
+    }
+
+    @Test
+    public void databaseHelperOnUpgrade_hasSatelliteIsNtnField() {
+        Log.d(TAG, "databaseHelperOnUpgrade_hasSatelliteIsNtnField");
+        // (5 << 16 | 6) is the first upgrade trigger in onUpgrade
+        SQLiteDatabase db = mInMemoryDbHelper.getWritableDatabase();
+        mHelper.onUpgrade(db, (4 << 16), TelephonyProvider.getVersion(mContext));
+
+        // the upgraded db must have
+        // Telephony.SimInfo.IS_NTN
+        Cursor cursor = db.query("siminfo", null, null, null, null, null, null);
+        String[] upgradedColumns = cursor.getColumnNames();
+        Log.d(TAG, "siminfo columns: " + Arrays.toString(upgradedColumns));
+
+        assertTrue(Arrays.asList(upgradedColumns).contains(
+                Telephony.SimInfo.COLUMN_IS_NTN));
+    }
+
+    @Test
+    public void databaseHelperOnUpgrade_hasInfrastructureFields() {
+        Log.d(TAG, "databaseHelperOnUpgrade_hasInfrastructureFields");
+        // (5 << 16 | 6) is the first upgrade trigger in onUpgrade
+        SQLiteDatabase db = mInMemoryDbHelper.getWritableDatabase();
+        mHelper.onUpgrade(db, (4 << 16), TelephonyProvider.getVersion(mContext));
+
+        // The upgraded db must have the fields Telephony.Carrier.INFRASTRUCTURE_BITMASK
+        Cursor cursor = db.query("carriers", null, null, null, null, null, null);
+        String[] columns = cursor.getColumnNames();
+        Log.d(TAG, "carriers columns: " + Arrays.toString(columns));
+
+        assertTrue(Arrays.asList(columns).contains(Carriers.INFRASTRUCTURE_BITMASK));
+    }
+
+    @Test
+    public void databaseHelperOnUpgrade_hasEsimBootstrapProvisioningFields() {
+        Log.d(TAG, "databaseHelperOnUpgrade_hasEsimBootstrapProvisioningFields");
+        // (5 << 16 | 6) is the first upgrade trigger in onUpgrade
+        SQLiteDatabase db = mInMemoryDbHelper.getWritableDatabase();
+        mHelper.onUpgrade(db, (4 << 16), TelephonyProvider.getVersion(mContext));
+
+        // The upgraded db must have the fields Telephony.Carrier.ESIM_BOOTSTRAP_PROVISIONING.
+        Cursor cursor = db.query("carriers", null, null, null, null, null, null);
+        String[] columns = cursor.getColumnNames();
+        Log.d(TAG, "carriers columns: " + Arrays.toString(columns));
+
+        assertTrue(Arrays.asList(columns).contains(Carriers.ESIM_BOOTSTRAP_PROVISIONING));
+    }
+
+    @Test
+    public void databaseHelperOnUpgrade_hasInfrastructureFields_updateInfrastructureValue() {
+        Log.d(TAG, "databaseHelperOnUpgrade_hasInfrastructureFields_updateInfrastructureValue");
+        // (5 << 16 | 6) is the first upgrade trigger in onUpgrade
+        SQLiteDatabase db = mInMemoryDbHelper.getWritableDatabase();
+        // UserHandle column is added in version 65.
+        mHelper.onUpgrade(db, (4 << 16), 65);
+
+        // The upgraded db must have the field Telephony.Carrier.INFRASTRUCTURE_BITMASK.
+        Cursor cursor = db.query("carriers", null, null, null, null, null, null);
+        String[] columns = cursor.getColumnNames();
+        Log.d(TAG, "carriers columns: " + Arrays.toString(columns));
+        assertTrue(Arrays.asList(columns).contains(Carriers.INFRASTRUCTURE_BITMASK));
+
+        // Insert test contentValues into db.
+        final int insertId = 1;
+        final String IdKey = "_id";
+        ContentValues contentValues = new ContentValues();
+        // Set INFRASTRUCTURE_BITMASK to 1ApnSetting.INFRASTRUCTURE_CELLULAR.
+        contentValues.put(Carriers.INFRASTRUCTURE_BITMASK, ApnSetting.INFRASTRUCTURE_CELLULAR);
+        contentValues.put(IdKey, insertId);
+        db.insert("carriers", null, contentValues);
+
+        // Query INFRASTRUCTURE_BITMASK value from db which should be equal to ApnSetting
+        // .INFRASTRUCTURE_CELLULAR.
+        final String[] testProjection = {Carriers.INFRASTRUCTURE_BITMASK};
+        final String selection = IdKey + "=?";
+        String[] selectionArgs = {Integer.toString(insertId)};
+        cursor = db.query("carriers", testProjection, selection, selectionArgs,
+                null, null, null);
+        assertNotNull(cursor);
+        assertEquals(1, cursor.getCount());
+        cursor.moveToFirst();
+        int infrastructureBitmask = cursor.getInt(0);
+        assertEquals(ApnSetting.INFRASTRUCTURE_CELLULAR, infrastructureBitmask);
+
+        // Upgrade db from version 65 to version 67.
+        mHelper.onUpgrade(db, (65 << 16), 67);
+
+        // Query INFRASTRUCTURE_BITMASK value from db which should be equal to (ApnSetting
+        // .INFRASTRUCTURE_CELLULAR | ApnSetting.INFRASTRUCTURE_SATELLITE) after db upgrade.
+        int expectedInfrastructureBitmask =
+                ApnSetting.INFRASTRUCTURE_CELLULAR | ApnSetting.INFRASTRUCTURE_SATELLITE;
+        cursor = db.query("carriers", testProjection, selection, selectionArgs,
+                null, null, null);
+        assertNotNull(cursor);
+        assertEquals(1, cursor.getCount());
+        cursor.moveToFirst();
+        infrastructureBitmask = cursor.getInt(0);
+        assertEquals(expectedInfrastructureBitmask, infrastructureBitmask);
+    }
+
     /**
      * Helper for an in memory DB used to test the TelephonyProvider#DatabaseHelper.
      *
diff --git a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
index de4c6c5..9ec340b 100644
--- a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
@@ -53,7 +53,6 @@
 
 import junit.framework.TestCase;
 
-import org.junit.Ignore;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;
 import org.mockito.Mock;
@@ -220,6 +219,10 @@
         contentValues.put(Telephony.SimInfo.COLUMN_USAGE_SETTING, arbitraryIntVal);
         contentValues.put(Telephony.SimInfo.COLUMN_ENABLED_MOBILE_DATA_POLICIES,
                 arbitraryStringVal);
+        contentValues.put(Telephony.SimInfo.COLUMN_SATELLITE_ENABLED, arbitraryIntVal);
+        contentValues.put(Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
+                arbitraryIntVal);
+        contentValues.put(SimInfo.COLUMN_IS_NTN, arbitraryIntVal);
         if (isoCountryCode != null) {
             contentValues.put(Telephony.SimInfo.COLUMN_ISO_COUNTRY_CODE, isoCountryCode);
         }
@@ -718,6 +721,8 @@
         final int insertPortIndex = 1;
         final int insertUserHandle = 0;
         final int insertSatelliteEnabled = 1;
+        final int insertSatelliteAttachEnabledForCarrier = 1;
+        final int insertSatelliteIsNtn = 1;
         contentValues.put(SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID, insertSubId);
         contentValues.put(SubscriptionManager.DISPLAY_NAME, insertDisplayName);
         contentValues.put(SubscriptionManager.CARRIER_NAME, insertCarrierName);
@@ -727,6 +732,9 @@
         contentValues.put(SubscriptionManager.PORT_INDEX, insertPortIndex);
         contentValues.put(SubscriptionManager.USER_HANDLE, insertUserHandle);
         contentValues.put(SubscriptionManager.SATELLITE_ENABLED, insertSatelliteEnabled);
+        contentValues.put(SubscriptionManager.SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
+                insertSatelliteAttachEnabledForCarrier);
+        contentValues.put(SubscriptionManager.IS_NTN, insertSatelliteIsNtn);
 
         Log.d(TAG, "testSimTable Inserting contentValues: " + contentValues);
         mContentResolver.insert(SimInfo.CONTENT_URI, contentValues);
@@ -741,6 +749,8 @@
             SubscriptionManager.PORT_INDEX,
             SubscriptionManager.USER_HANDLE,
             SubscriptionManager.SATELLITE_ENABLED,
+            SubscriptionManager.SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
+            SubscriptionManager.IS_NTN,
         };
         final String selection = SubscriptionManager.DISPLAY_NAME + "=?";
         String[] selectionArgs = { insertDisplayName };
@@ -760,12 +770,17 @@
         final int resultPortIndex = cursor.getInt(4);
         final int resultUserHandle = cursor.getInt(5);
         final int resultSatelliteEnabled = cursor.getInt(6);
+        final int resultCarrierHandoverToSatelliteEnabledByUser = cursor.getInt(7);
+        final int resultSatelliteIsNtn = cursor.getInt(8);
         assertEquals(insertSubId, resultSubId);
         assertEquals(insertCarrierName, resultCarrierName);
         assertEquals(insertCardId, resultCardId);
         assertEquals(insertPortIndex, resultPortIndex);
         assertEquals(insertUserHandle, resultUserHandle);
         assertEquals(insertSatelliteEnabled, resultSatelliteEnabled);
+        assertEquals(insertSatelliteAttachEnabledForCarrier,
+                resultCarrierHandoverToSatelliteEnabledByUser);
+        assertEquals(insertSatelliteIsNtn, resultSatelliteIsNtn);
 
         // delete test content
         final String selectionToDelete = SubscriptionManager.DISPLAY_NAME + "=?";
@@ -827,6 +842,13 @@
         assertEquals(ARBITRARY_SIMINFO_DB_TEST_STRING_VALUE_1,
                 getStringValueFromCursor(cursor,
                         Telephony.SimInfo.COLUMN_ENABLED_MOBILE_DATA_POLICIES));
+        assertEquals(ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_1,
+                getIntValueFromCursor(cursor, Telephony.SimInfo.COLUMN_SATELLITE_ENABLED));
+        assertEquals(ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_1,
+                getIntValueFromCursor(cursor,
+                        Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER));
+        assertEquals(ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_1,
+                getIntValueFromCursor(cursor, SimInfo.COLUMN_IS_NTN));
         assertRestoredSubIdIsRemembered();
     }