Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5cb33537 authored by Jack Yu's avatar Jack Yu
Browse files

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
Merged-In: I870d0a253c6df46dcbafa834d73123536e36e45f
Change-Id: I870d0a253c6df46dcbafa834d73123536e36e45f
(cherry picked from commit c1a30c1a)
parent d6ed1211
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -704,6 +704,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            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);
@@ -2959,6 +2961,17 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        // a separate entry if uid is different from the previous snapshot.
        NetworkStats vtDataUsageUidSnapshot = new NetworkStats(currentTime, 1);
        vtDataUsageUidSnapshot.combineAllValues(mVtDataUsageUidSnapshot);

        // 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(