[MS82.2] Add a rewriteSingle method that takes two timestamps
This CL provides a public method in FileRotator to allow caller to write data to a specified standalone file. This CL also fix a file name generatign error in platform tools. Test: NetworkStatsServiceTest NetworkStatsCollectionTest Bug: 230289468 Change-Id: I17558f349cb2a33062972fe1af96a19356798692 Merged-In: I17558f349cb2a33062972fe1af96a19356798692 (pure cherry-picked from ag/18408306)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user