Loading api/system-current.txt +4 −0 Original line number Diff line number Diff line Loading @@ -7777,6 +7777,10 @@ package android.util { method public int getUid(); } public final class StatsLog { method public static void writeRaw(@NonNull byte[], int); } } package android.view { core/java/android/util/StatsLog.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.util; import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.IStatsManager; import android.os.RemoteException; import android.os.ServiceManager; Loading Loading @@ -113,4 +115,14 @@ public final class StatsLog extends StatsLogInternal { sService = IStatsManager.Stub.asInterface(ServiceManager.getService("stats")); return sService; } /** * 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. * @hide */ @SystemApi public static native void writeRaw(@NonNull byte[] buffer, int size); } core/jni/Android.bp +5 −4 Original line number Diff line number Diff line genrule { name: "android_util_StatsLog.cpp", name: "android_util_StatsLogInternal.cpp", tools: ["stats-log-api-gen"], cmd: "$(location stats-log-api-gen) --jni $(genDir)/android_util_StatsLog.cpp", cmd: "$(location stats-log-api-gen) --jni $(genDir)/android_util_StatsLogInternal.cpp", out: [ "android_util_StatsLog.cpp", "android_util_StatsLogInternal.cpp", ], } Loading Loading @@ -112,6 +112,7 @@ cc_library_shared { "android_util_Binder.cpp", "android_util_EventLog.cpp", "android_util_Log.cpp", "android_util_StatsLog.cpp", "android_util_MemoryIntArray.cpp", "android_util_PathParser.cpp", "android_util_Process.cpp", Loading Loading @@ -292,7 +293,7 @@ cc_library_shared { "server_configurable_flags", ], generated_sources: ["android_util_StatsLog.cpp"], generated_sources: ["android_util_StatsLogInternal.cpp"], local_include_dirs: ["android/graphics"], export_include_dirs: [ Loading core/jni/AndroidRuntime.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ extern int register_android_app_admin_SecurityLog(JNIEnv* env); extern int register_android_content_AssetManager(JNIEnv* env); extern int register_android_util_EventLog(JNIEnv* env); extern int register_android_util_StatsLog(JNIEnv* env); extern int register_android_util_StatsLogInternal(JNIEnv* env); extern int register_android_util_Log(JNIEnv* env); extern int register_android_util_MemoryIntArray(JNIEnv* env); extern int register_android_util_PathParser(JNIEnv* env); Loading Loading @@ -1396,6 +1397,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_util_MemoryIntArray), REG_JNI(register_android_util_PathParser), REG_JNI(register_android_util_StatsLog), REG_JNI(register_android_util_StatsLogInternal), REG_JNI(register_android_app_admin_SecurityLog), REG_JNI(register_android_content_AssetManager), REG_JNI(register_android_content_StringBlock), Loading core/jni/android_util_StatsLog.cpp 0 → 100644 +69 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_NAMESPACE "StatsLog.tag." #define LOG_TAG "StatsLog_println" #include <assert.h> #include <cutils/properties.h> #include "jni.h" #include <nativehelper/JNIHelp.h> #include "utils/misc.h" #include "core_jni_helpers.h" #include "stats_event_list.h" namespace android { static void android_util_StatsLog_writeRaw(JNIEnv* env, jobject clazz, jbyteArray buf, jint size) { if (buf == NULL) { return; } jint actualSize = env->GetArrayLength(buf); if (actualSize < size) { return; } jbyte* bufferArray = env->GetByteArrayElements(buf, NULL); if (bufferArray == NULL) { return; } const uint32_t statsEventTag = 1937006964; struct iovec vec[2]; 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); } /* * JNI registration. */ static const JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ { "writeRaw", "([BI)V", (void*) android_util_StatsLog_writeRaw }, }; int register_android_util_StatsLog(JNIEnv* env) { return RegisterMethodsOrDie(env, "android/util/StatsLog", gMethods, NELEM(gMethods)); } }; // namespace android Loading
api/system-current.txt +4 −0 Original line number Diff line number Diff line Loading @@ -7777,6 +7777,10 @@ package android.util { method public int getUid(); } public final class StatsLog { method public static void writeRaw(@NonNull byte[], int); } } package android.view {
core/java/android/util/StatsLog.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.util; import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.IStatsManager; import android.os.RemoteException; import android.os.ServiceManager; Loading Loading @@ -113,4 +115,14 @@ public final class StatsLog extends StatsLogInternal { sService = IStatsManager.Stub.asInterface(ServiceManager.getService("stats")); return sService; } /** * 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. * @hide */ @SystemApi public static native void writeRaw(@NonNull byte[] buffer, int size); }
core/jni/Android.bp +5 −4 Original line number Diff line number Diff line genrule { name: "android_util_StatsLog.cpp", name: "android_util_StatsLogInternal.cpp", tools: ["stats-log-api-gen"], cmd: "$(location stats-log-api-gen) --jni $(genDir)/android_util_StatsLog.cpp", cmd: "$(location stats-log-api-gen) --jni $(genDir)/android_util_StatsLogInternal.cpp", out: [ "android_util_StatsLog.cpp", "android_util_StatsLogInternal.cpp", ], } Loading Loading @@ -112,6 +112,7 @@ cc_library_shared { "android_util_Binder.cpp", "android_util_EventLog.cpp", "android_util_Log.cpp", "android_util_StatsLog.cpp", "android_util_MemoryIntArray.cpp", "android_util_PathParser.cpp", "android_util_Process.cpp", Loading Loading @@ -292,7 +293,7 @@ cc_library_shared { "server_configurable_flags", ], generated_sources: ["android_util_StatsLog.cpp"], generated_sources: ["android_util_StatsLogInternal.cpp"], local_include_dirs: ["android/graphics"], export_include_dirs: [ Loading
core/jni/AndroidRuntime.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ extern int register_android_app_admin_SecurityLog(JNIEnv* env); extern int register_android_content_AssetManager(JNIEnv* env); extern int register_android_util_EventLog(JNIEnv* env); extern int register_android_util_StatsLog(JNIEnv* env); extern int register_android_util_StatsLogInternal(JNIEnv* env); extern int register_android_util_Log(JNIEnv* env); extern int register_android_util_MemoryIntArray(JNIEnv* env); extern int register_android_util_PathParser(JNIEnv* env); Loading Loading @@ -1396,6 +1397,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_util_MemoryIntArray), REG_JNI(register_android_util_PathParser), REG_JNI(register_android_util_StatsLog), REG_JNI(register_android_util_StatsLogInternal), REG_JNI(register_android_app_admin_SecurityLog), REG_JNI(register_android_content_AssetManager), REG_JNI(register_android_content_StringBlock), Loading
core/jni/android_util_StatsLog.cpp 0 → 100644 +69 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_NAMESPACE "StatsLog.tag." #define LOG_TAG "StatsLog_println" #include <assert.h> #include <cutils/properties.h> #include "jni.h" #include <nativehelper/JNIHelp.h> #include "utils/misc.h" #include "core_jni_helpers.h" #include "stats_event_list.h" namespace android { static void android_util_StatsLog_writeRaw(JNIEnv* env, jobject clazz, jbyteArray buf, jint size) { if (buf == NULL) { return; } jint actualSize = env->GetArrayLength(buf); if (actualSize < size) { return; } jbyte* bufferArray = env->GetByteArrayElements(buf, NULL); if (bufferArray == NULL) { return; } const uint32_t statsEventTag = 1937006964; struct iovec vec[2]; 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); } /* * JNI registration. */ static const JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ { "writeRaw", "([BI)V", (void*) android_util_StatsLog_writeRaw }, }; int register_android_util_StatsLog(JNIEnv* env) { return RegisterMethodsOrDie(env, "android/util/StatsLog", gMethods, NELEM(gMethods)); } }; // namespace android