Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 667a49fe authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "[TeX] Extracted Utils API for Telemetry Express Logging APIs"

parents 7c053765 af823de2
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 * Copyright (C) 2023 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.
@@ -39,9 +39,7 @@ public final class Counter {
     * @hide
     */
    public static void logIncrement(@NonNull String metricId, long amount) {
        final long metricIdHash = hashString(metricId);
        final long metricIdHash = Utils.hashString(metricId);
        FrameworkStatsLog.write(FrameworkStatsLog.EXPRESS_EVENT_REPORTED, metricIdHash, amount);
    }

    private static native long hashString(String stringToHash);
}
+21 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.
 */

package com.android.internal.expresslog;

final class Utils {
    static native long hashString(String stringToHash);
}
+1 −1
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ cc_library_shared {
                "android_content_res_Configuration.cpp",
                "android_security_Scrypt.cpp",
                "com_android_internal_content_om_OverlayConfig.cpp",
                "com_android_internal_expresslog_Counter.cpp",
                "com_android_internal_expresslog_Utils.cpp",
                "com_android_internal_net_NetworkUtilsInternal.cpp",
                "com_android_internal_os_ClassLoaderFactory.cpp",
                "com_android_internal_os_FuseAppLoop.cpp",
+2 −2
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ extern int register_android_security_Scrypt(JNIEnv *env);
extern int register_com_android_internal_content_F2fsUtils(JNIEnv* env);
extern int register_com_android_internal_content_NativeLibraryHelper(JNIEnv *env);
extern int register_com_android_internal_content_om_OverlayConfig(JNIEnv *env);
extern int register_com_android_internal_expresslog_Counter(JNIEnv* env);
extern int register_com_android_internal_expresslog_Utils(JNIEnv* env);
extern int register_com_android_internal_net_NetworkUtilsInternal(JNIEnv* env);
extern int register_com_android_internal_os_ClassLoaderFactory(JNIEnv* env);
extern int register_com_android_internal_os_FuseAppLoop(JNIEnv* env);
@@ -1591,7 +1591,7 @@ static const RegJNIRec gRegJNI[] = {
        REG_JNI(register_android_os_SharedMemory),
        REG_JNI(register_android_os_incremental_IncrementalManager),
        REG_JNI(register_com_android_internal_content_om_OverlayConfig),
        REG_JNI(register_com_android_internal_expresslog_Counter),
        REG_JNI(register_com_android_internal_expresslog_Utils),
        REG_JNI(register_com_android_internal_net_NetworkUtilsInternal),
        REG_JNI(register_com_android_internal_os_ClassLoaderFactory),
        REG_JNI(register_com_android_internal_os_LongArrayMultiStateCounter),
+4 −4
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
static jclass g_stringClass = nullptr;

/**
 * Class:     com_android_internal_expresslog_Counter
 * Class:     com_android_internal_expresslog_Utils
 * Method:    hashString
 * Signature: (Ljava/lang/String;)J
 */
@@ -43,15 +43,15 @@ static const JNINativeMethod g_methods[] = {
        {"hashString", "(Ljava/lang/String;)J", (void*)hashString},
};

static const char* const kCounterPathName = "com/android/internal/expresslog/Counter";
static const char* const kUtilsPathName = "com/android/internal/expresslog/Utils";

namespace android {

int register_com_android_internal_expresslog_Counter(JNIEnv* env) {
int register_com_android_internal_expresslog_Utils(JNIEnv* env) {
    jclass stringClass = FindClassOrDie(env, "java/lang/String");
    g_stringClass = MakeGlobalRefOrDie(env, stringClass);

    return RegisterMethodsOrDie(env, kCounterPathName, g_methods, NELEM(g_methods));
    return RegisterMethodsOrDie(env, kUtilsPathName, g_methods, NELEM(g_methods));
}

} // namespace android