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

Commit 302b41e4 authored by Junyu Lai's avatar Junyu Lai Committed by Automerger Merge Worker
Browse files

Merge changes from topic "stats-migration" into tm-dev am: 23ed66f1 am: 4ce5244f am: a0bc85de

parents a4a18303 a0bc85de
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.ProtocolException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@@ -161,9 +162,12 @@ public class NetworkStatsDataMigrationUtils {
    @NonNull
    private static ArrayList<File> getPlatformFileListForPrefix(@NonNull @Prefix String prefix) {
        final ArrayList<File> list = new ArrayList<>();
        final File platformFiles = new File(getPlatformBaseDir(), "netstats");
        final File platformFiles = getPlatformBaseDir();
        if (platformFiles.exists()) {
            for (String name : platformFiles.list()) {
            final String[] files = platformFiles.list();
            if (files == null) return list;
            Arrays.sort(files);
            for (String name : files) {
                // Skip when prefix doesn't match.
                if (!name.startsWith(prefix + ".")) continue;

+15 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.util;

import android.annotation.NonNull;
import android.os.FileUtils;
import android.util.Log;

@@ -281,6 +282,20 @@ public class FileRotator {
        }
    }

    /**
     * Process a single file atomically, with the given start and end timestamps.
     * If a file with these exact start and end timestamps does not exist, a new
     * empty file will be written.
     */
    public void rewriteSingle(@NonNull Rewriter rewriter, long startTimeMillis, long endTimeMillis)
            throws IOException {
        final FileInfo info = new FileInfo(mPrefix);

        info.startMillis = startTimeMillis;
        info.endMillis = endTimeMillis;
        rewriteSingle(rewriter, info.build());
    }

    /**
     * Read any rotated data that overlap the requested time range.
     */