Merge "Use write_buffer_to_statsd within StatsLog_write"
This commit is contained in:
@@ -224,12 +224,25 @@ public final class StatsLog extends StatsLogInternal {
|
|||||||
/**
|
/**
|
||||||
* Write an event to stats log using the raw format.
|
* 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.
|
* @param size The number of bytes from the buffer to write.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
// TODO(b/144935988): Mark deprecated.
|
||||||
@SystemApi
|
@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) {
|
private static void enforceDumpCallingPermission(Context context) {
|
||||||
context.enforceCallingPermission(android.Manifest.permission.DUMP, "Need DUMP permission.");
|
context.enforceCallingPermission(android.Manifest.permission.DUMP, "Need DUMP permission.");
|
||||||
|
|||||||
@@ -18,18 +18,17 @@
|
|||||||
#define LOG_TAG "StatsLog_println"
|
#define LOG_TAG "StatsLog_println"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <cutils/properties.h>
|
|
||||||
|
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include <nativehelper/JNIHelp.h>
|
#include <nativehelper/JNIHelp.h>
|
||||||
#include "utils/misc.h"
|
#include "utils/misc.h"
|
||||||
#include "core_jni_helpers.h"
|
#include "core_jni_helpers.h"
|
||||||
#include "stats_event_list.h"
|
#include "stats_buffer_writer.h"
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
static void android_util_StatsLog_writeRaw(JNIEnv* env, jobject clazz, jbyteArray buf, jint size)
|
static void android_util_StatsLog_write(JNIEnv* env, jobject clazz, jbyteArray buf, jint size,
|
||||||
{
|
jint atomId) {
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -42,13 +41,8 @@ static void android_util_StatsLog_writeRaw(JNIEnv* env, jobject clazz, jbyteArra
|
|||||||
if (bufferArray == NULL) {
|
if (bufferArray == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const uint32_t statsEventTag = 1937006964;
|
|
||||||
struct iovec vec[2];
|
write_buffer_to_statsd((void*) bufferArray, size, atomId);
|
||||||
vec[0].iov_base = (void*) &statsEventTag;
|
|
||||||
vec[0].iov_len = sizeof(statsEventTag);
|
|
||||||
vec[1].iov_base = (void*) bufferArray;
|
|
||||||
vec[1].iov_len = size;
|
|
||||||
write_to_statsd(vec, 2);
|
|
||||||
|
|
||||||
env->ReleaseByteArrayElements(buf, bufferArray, 0);
|
env->ReleaseByteArrayElements(buf, bufferArray, 0);
|
||||||
}
|
}
|
||||||
@@ -58,7 +52,7 @@ static void android_util_StatsLog_writeRaw(JNIEnv* env, jobject clazz, jbyteArra
|
|||||||
*/
|
*/
|
||||||
static const JNINativeMethod gMethods[] = {
|
static const JNINativeMethod gMethods[] = {
|
||||||
/* name, signature, funcPtr */
|
/* name, signature, funcPtr */
|
||||||
{ "writeRaw", "([BI)V", (void*) android_util_StatsLog_writeRaw },
|
{ "writeImpl", "([BII)V", (void*) android_util_StatsLog_write },
|
||||||
};
|
};
|
||||||
|
|
||||||
int register_android_util_StatsLog(JNIEnv* env)
|
int register_android_util_StatsLog(JNIEnv* env)
|
||||||
|
|||||||
Reference in New Issue
Block a user