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

Commit a5e58006 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Check CPU time_in_state from one place" into sc-dev am: e2d93d3e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13554286

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1b6977945a98743db537c4ce5772c0ddd2826e42
parents 1df0ae0f e2d93d3e
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.os;

/** CPU tracking using eBPF. */
public final class KernelCpuBpfTracking {
    private KernelCpuBpfTracking() {
    }

    /** Returns whether CPU tracking using eBPF is supported. */
    public static native boolean isSupported();
}
+0 −3
Original line number Diff line number Diff line
@@ -23,9 +23,6 @@ public final class KernelCpuTotalBpfMapReader {
    private KernelCpuTotalBpfMapReader() {
    }

    /** Returns whether total CPU time is measured. */
    public static native boolean isSupported();

    /** Reads total CPU time from bpf map. */
    public static native boolean read(Callback callback);

+1 −0
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ cc_library_shared {
                "com_android_internal_net_NetworkUtilsInternal.cpp",
                "com_android_internal_os_ClassLoaderFactory.cpp",
                "com_android_internal_os_FuseAppLoop.cpp",
                "com_android_internal_os_KernelCpuBpfTracking.cpp",
                "com_android_internal_os_KernelCpuTotalBpfMapReader.cpp",
                "com_android_internal_os_KernelCpuUidBpfMapReader.cpp",
                "com_android_internal_os_KernelSingleProcessCpuThreadReader.cpp",
+2 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ extern int register_com_android_internal_content_om_OverlayConfig(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);
extern int register_com_android_internal_os_KernelCpuBpfTracking(JNIEnv* env);
extern int register_com_android_internal_os_KernelCpuTotalBpfMapReader(JNIEnv* env);
extern int register_com_android_internal_os_KernelCpuUidBpfMapReader(JNIEnv *env);
extern int register_com_android_internal_os_KernelSingleProcessCpuThreadReader(JNIEnv* env);
@@ -1586,6 +1587,7 @@ static const RegJNIRec gRegJNI[] = {
        REG_JNI(register_android_security_Scrypt),
        REG_JNI(register_com_android_internal_content_NativeLibraryHelper),
        REG_JNI(register_com_android_internal_os_FuseAppLoop),
        REG_JNI(register_com_android_internal_os_KernelCpuBpfTracking),
        REG_JNI(register_com_android_internal_os_KernelCpuTotalBpfMapReader),
        REG_JNI(register_com_android_internal_os_KernelCpuUidBpfMapReader),
        REG_JNI(register_com_android_internal_os_KernelSingleProcessCpuThreadReader),
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.
 */

#include "core_jni_helpers.h"

#include <cputimeinstate.h>

namespace android {

static jboolean KernelCpuBpfTracking_isSupported(JNIEnv *, jobject) {
    return android::bpf::isTrackingUidTimesSupported() ? JNI_TRUE : JNI_FALSE;
}

static const JNINativeMethod methods[] = {
        {"isSupported", "()Z", (void *)KernelCpuBpfTracking_isSupported},
};

int register_com_android_internal_os_KernelCpuBpfTracking(JNIEnv *env) {
    return RegisterMethodsOrDie(env, "com/android/internal/os/KernelCpuBpfTracking", methods,
                                NELEM(methods));
}

} // namespace android
Loading