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

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

Merge "Reroute surfaceflinger atoms through system server" into sc-dev am: d07ae7b4

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

Change-Id: I9b27a61226d601ac5b242fd98ed5c3856e711ecc
parents 70ddc230 d07ae7b4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 * Copyright 2020 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.
@@ -432,6 +432,7 @@ public class StatsPullAtomService extends SystemService {
        mContext = context;
    }

    private native void initializeNativePullers();
    /**
     * Use of this StatsPullAtomCallbackImpl means we avoid one class per tagId, which we would
     * get if we used lambdas.
@@ -713,6 +714,7 @@ public class StatsPullAtomService extends SystemService {
        super.onBootPhase(phase);
        if (phase == PHASE_SYSTEM_SERVICES_READY) {
            BackgroundThread.getHandler().post(() -> {
                initializeNativePullers(); // Initialize pullers that need JNI.
                initializePullersState();
                registerPullers();
                registerEventListeners();
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ cc_library_static {
        "gnss/GnssMeasurement.cpp",
        "gnss/GnssMeasurementCallback.cpp",
        "gnss/Utils.cpp",
        "stats/SurfaceFlingerPuller.cpp",
        "com_android_server_adb_AdbDebuggingManager.cpp",
        "com_android_server_am_BatteryStatsService.cpp",
        "com_android_server_biometrics_SurfaceToNativeHandleConverter.cpp",
@@ -53,6 +54,7 @@ cc_library_static {
        "com_android_server_SerialService.cpp",
        "com_android_server_soundtrigger_middleware_AudioSessionProviderImpl.cpp",
        "com_android_server_soundtrigger_middleware_ExternalCaptureStateTracker.cpp",
        "com_android_server_stats_pull_StatsPullAtomService.cpp",
        "com_android_server_storage_AppFuseBridge.cpp",
        "com_android_server_SystemServer.cpp",
        "com_android_server_tv_TvUinputBridge.cpp",
@@ -127,6 +129,7 @@ cc_defaults {
        "libsensorservice",
        "libsensorservicehidl",
        "libgui",
        "libtimestats_atoms_proto",
        "libusbhost",
        "libtinyalsa",
        "libEGL",
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright 2020 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_TAG "StatsPullAtomService"

#include <jni.h>
#include <log/log.h>
#include <nativehelper/JNIHelp.h>
#include <stats_event.h>
#include <stats_pull_atom_callback.h>
#include <statslog.h>

#include "stats/SurfaceFlingerPuller.h"

namespace android {

static server::stats::SurfaceFlingerPuller gSurfaceFlingerPuller;

static AStatsManager_PullAtomCallbackReturn onSurfaceFlingerPullCallback(int32_t atom_tag,
                                                                         AStatsEventList* data,
                                                                         void* cookie) {
    return gSurfaceFlingerPuller.pull(atom_tag, data);
}

static void initializeNativePullers(JNIEnv* env, jobject javaObject) {
    // Surface flinger layer & global info.
    gSurfaceFlingerPuller = server::stats::SurfaceFlingerPuller();
    AStatsManager_setPullAtomCallback(android::util::SURFACEFLINGER_STATS_GLOBAL_INFO,
                                      /* metadata= */ nullptr, onSurfaceFlingerPullCallback,
                                      /* cookie= */ nullptr);
    AStatsManager_setPullAtomCallback(android::util::SURFACEFLINGER_STATS_LAYER_INFO,
                                      /* metadata= */ nullptr, onSurfaceFlingerPullCallback,
                                      /* cookie= */ nullptr);
}

static const JNINativeMethod sMethods[] = {
        {"initializeNativePullers", "()V", (void*)initializeNativePullers}};

int register_android_server_stats_pull_StatsPullAtomService(JNIEnv* env) {
    int res = jniRegisterNativeMethods(env, "com/android/server/stats/pull/StatsPullAtomService",
                                       sMethods, NELEM(sMethods));
    if (res < 0) {
        ALOGE("failed to register native methods");
    }
    return res;
}

} // namespace android
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ int register_android_server_com_android_server_pm_PackageManagerShellCommandData
int register_android_server_AdbDebuggingManager(JNIEnv* env);
int register_android_server_FaceService(JNIEnv* env);
int register_android_server_GpuService(JNIEnv* env);
int register_android_server_stats_pull_StatsPullAtomService(JNIEnv* env);
};

using namespace android;
@@ -115,5 +116,6 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */)
    register_android_server_AdbDebuggingManager(env);
    register_android_server_FaceService(env);
    register_android_server_GpuService(env);
    register_android_server_stats_pull_StatsPullAtomService(env);
    return JNI_VERSION_1_4;
}
+8 −0
Original line number Diff line number Diff line
jeffreyhuang@google.com
jtnguyen@google.com
muhammadq@google.com
sharaieko@google.com
singhtejinder@google.com
tsaichristine@google.com
yaochen@google.com
yro@google.com
Loading