Merge "Pivot network statistics to use DataInput/Output." into sc-dev
This commit is contained in:
@@ -54,6 +54,8 @@ import android.util.proto.ProtoOutputStream;
|
|||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.util.ArrayUtils;
|
import com.android.internal.util.ArrayUtils;
|
||||||
|
import com.android.internal.util.FastDataInput;
|
||||||
|
import com.android.internal.util.FastDataOutput;
|
||||||
import com.android.internal.util.FileRotator;
|
import com.android.internal.util.FileRotator;
|
||||||
import com.android.internal.util.IndentingPrintWriter;
|
import com.android.internal.util.IndentingPrintWriter;
|
||||||
|
|
||||||
@@ -89,6 +91,9 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W
|
|||||||
/** File header magic number: "ANET" */
|
/** File header magic number: "ANET" */
|
||||||
private static final int FILE_MAGIC = 0x414E4554;
|
private static final int FILE_MAGIC = 0x414E4554;
|
||||||
|
|
||||||
|
/** Default buffer size from BufferedInputStream */
|
||||||
|
private static final int BUFFER_SIZE = 8192;
|
||||||
|
|
||||||
private static final int VERSION_NETWORK_INIT = 1;
|
private static final int VERSION_NETWORK_INIT = 1;
|
||||||
|
|
||||||
private static final int VERSION_UID_INIT = 1;
|
private static final int VERSION_UID_INIT = 1;
|
||||||
@@ -434,7 +439,8 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(InputStream in) throws IOException {
|
public void read(InputStream in) throws IOException {
|
||||||
read((DataInput) new DataInputStream(in));
|
final FastDataInput dataIn = new FastDataInput(in, BUFFER_SIZE);
|
||||||
|
read(dataIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void read(DataInput in) throws IOException {
|
private void read(DataInput in) throws IOException {
|
||||||
@@ -473,8 +479,9 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(OutputStream out) throws IOException {
|
public void write(OutputStream out) throws IOException {
|
||||||
write((DataOutput) new DataOutputStream(out));
|
final FastDataOutput dataOut = new FastDataOutput(out, BUFFER_SIZE);
|
||||||
out.flush();
|
write(dataOut);
|
||||||
|
dataOut.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void write(DataOutput out) throws IOException {
|
private void write(DataOutput out) throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user