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

Commit b98c9511 authored by Nagendra Prasad Nagarle Basavaraju's avatar Nagendra Prasad Nagarle Basavaraju Committed by Android (Google) Code Review
Browse files

Merge "Avoid storing non-positive satellite data usage" into main

parents 47d59b98 80e7c3f0
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -498,19 +498,20 @@ public class CarrierRoamingSatelliteSessionStats {
        for (Map.Entry<String, Long> entry : map2.entrySet()) {
            String key = entry.getKey();
            Long currentDataUsageBytes = entry.getValue();
            long dataUsageDuringSession;

            // Check if the key from Map2 exists in Map1
            // Check if the package exists in the session-start map
            if (mPerAppDataUsageOnSessionStartMap.containsKey(key)) {
                Long initialDataUsageBytes =
                        mPerAppDataUsageOnSessionStartMap.get(key);
                // If available, find the difference (Map2 - Map1)
                satelliteSessionUsageMap.put(key,
                        currentDataUsageBytes
                                - initialDataUsageBytes);
                long initialDataUsageBytes = mPerAppDataUsageOnSessionStartMap.get(key);
                dataUsageDuringSession = currentDataUsageBytes - initialDataUsageBytes;
            } else {
                // If Map2 key is not found in Map1,
                // add Map2 key and its corresponding value to the new map
                satelliteSessionUsageMap.put(key, currentDataUsageBytes);
                // If not in the start map, usage is the current value
                dataUsageDuringSession = currentDataUsageBytes;
            }

            // Only store positive data usage values
            if (dataUsageDuringSession > 0) {
                satelliteSessionUsageMap.put(key, dataUsageDuringSession);
            }
        }
        return satelliteSessionUsageMap;