Merge "Merge changes from topic "stats-migration" into tm-dev am: 23ed66f130 am: 4ce5244ff6" into tm-d1-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
30ca563b63
@@ -52,6 +52,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.net.ProtocolException;
|
import java.net.ProtocolException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -161,9 +162,12 @@ public class NetworkStatsDataMigrationUtils {
|
|||||||
@NonNull
|
@NonNull
|
||||||
private static ArrayList<File> getPlatformFileListForPrefix(@NonNull @Prefix String prefix) {
|
private static ArrayList<File> getPlatformFileListForPrefix(@NonNull @Prefix String prefix) {
|
||||||
final ArrayList<File> list = new ArrayList<>();
|
final ArrayList<File> list = new ArrayList<>();
|
||||||
final File platformFiles = new File(getPlatformBaseDir(), "netstats");
|
final File platformFiles = getPlatformBaseDir();
|
||||||
if (platformFiles.exists()) {
|
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.
|
// Skip when prefix doesn't match.
|
||||||
if (!name.startsWith(prefix + ".")) continue;
|
if (!name.startsWith(prefix + ".")) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.internal.util;
|
package com.android.internal.util;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.os.FileUtils;
|
import android.os.FileUtils;
|
||||||
import android.util.Log;
|
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.
|
* Read any rotated data that overlap the requested time range.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user