Fixed that video calling data usage was not counted under phone app

The default dialer uid was not initialized correctly in telephony.
Added another check to ensure the uid is set correctly at the time
when we calculate data usage.

Test: Manual
bug: 65644451
Change-Id: I870d0a253c6df46dcbafa834d73123536e36e45f
(cherry picked from commit c1a30c1a5f0e3b8fee03790b0a1bfc087f22075c)
diff --git a/src/java/com/android/internal/telephony/imsphone/ b/src/java/com/android/internal/telephony/imsphone/
index 3b29516..8e3773c 100644
--- a/src/java/com/android/internal/telephony/imsphone/
+++ b/src/java/com/android/internal/telephony/imsphone/
@@ -683,6 +683,8 @@
             return NetworkStats.UID_ALL;
+        // Initialize to UID_ALL so at least it can be counted to overall data usage if
+        // the dialer's package uid is not available.
         int uid = NetworkStats.UID_ALL;
         try {
             uid = context.getPackageManager().getPackageUid(pkg, 0);
@@ -2878,6 +2880,17 @@
         // a separate entry if uid is different from the previous snapshot.
         NetworkStats vtDataUsageUidSnapshot = new NetworkStats(currentTime, 1);
+        // The dialer uid might not be initialized correctly during boot up due to telecom service
+        // not ready or its default dialer cache not ready. So we double check again here to see if
+        // default dialer uid is really not available.
+        if (mDefaultDialerUid.get() == NetworkStats.UID_ALL) {
+            final TelecomManager telecomManager =
+                    (TelecomManager) mPhone.getContext().getSystemService(Context.TELECOM_SERVICE);
+            mDefaultDialerUid.set(
+                    getPackageUid(mPhone.getContext(), telecomManager.getDefaultDialerPackage()));
+        }
         // Since the modem only reports the total vt data usage rather than rx/tx separately,
         // the only thing we can do here is splitting the usage into half rx and half tx.
         vtDataUsageUidSnapshot.combineValues(new NetworkStats.Entry(