Use write_buffer_to_statsd within StatsLog_write

This CL is a partial cherrypick of ag/9686088. This is needed because new
changes to libstatssocket (that need to be cherrypicked into AOSP) wrap
#write_to_statsd() with #write_buffer_to_statsd().

Bug: 143978873
Test: m -j
Test: flashes successfully
Test: DocumentsUI(a Mainline module) is able to successfully log to statsd
Change-Id: I886331f728ccaa3d281b5683eb89179aa73596b6
Merged-In: I9cdc6151d8feb29a712532e50f143af9d52c8d94
This commit is contained in:
Muhammad Qureshi
2019-11-06 15:26:08 -08:00
committed by Ruchir Rastogi
parent f5b6267d93
commit bc1002d520
2 changed files with 21 additions and 14 deletions

View File

@@ -224,12 +224,25 @@ public final class StatsLog extends StatsLogInternal {
/**
* Write an event to stats log using the raw format.
*
* @param buffer The encoded buffer of data to write..
* @param buffer The encoded buffer of data to write.
* @param size The number of bytes from the buffer to write.
* @hide
*/
// TODO(b/144935988): Mark deprecated.
@SystemApi
public static native void writeRaw(@NonNull byte[] buffer, int size);
public static void writeRaw(@NonNull byte[] buffer, int size) {
// TODO(b/144935988): make this no-op once clients have migrated to StatsEvent.
writeImpl(buffer, size, 0);
}
/**
* Write an event to stats log using the raw format.
*
* @param buffer The encoded buffer of data to write.
* @param size The number of bytes from the buffer to write.
* @param atomId The id of the atom to which the event belongs.
*/
private static native void writeImpl(@NonNull byte[] buffer, int size, int atomId);
private static void enforceDumpCallingPermission(Context context) {
context.enforceCallingPermission(android.Manifest.permission.DUMP, "Need DUMP permission.");