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

Commit 8b3b5463 authored by junyulai's avatar junyulai Committed by Automerger Merge Worker
Browse files

[MS82.2] Add a rewriteSingle method that takes two timestamps am: 807a7f37

parents bb92e9b1 807a7f37
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ 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()) {
                // Skip when prefix doesn't match.
+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.
     */