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

Commit babb9220 authored by Carlos Galo's avatar Carlos Galo
Browse files

servicestest: add jni dependency



Test: atest all tests under servicestests/../server/am
Bug: 244232958
Change-Id: I8827995a54e2fb3da3b5c5bd6b9401ef8a5508be
Signed-off-by: default avatarCarlos Galo <carlosgalo@google.com>
Merged-In: I8827995a54e2fb3da3b5c5bd6b9401ef8a5508be
parent 0187756c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2,6 +2,13 @@
// Build FrameworksServicesTests package
//########################################################################

java_defaults {
    name: "FrameworksServicesTests-jni-defaults",
    jni_libs: [
        "libservicestestjni",
    ],
}

package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
@@ -13,6 +20,9 @@ package {

android_test {
    name: "FrameworksServicesTests",
    defaults: [
        "FrameworksServicesTests-jni-defaults",
    ],

    // Include all test java files.
    srcs: [
+58 −0
Original line number Diff line number Diff line
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_base_license"],
}

cc_library_shared {
    name: "libservicestestjni",

    defaults: ["android.hardware.graphics.common-ndk_shared"],

    cflags: [
        "-Wall",
        "-Werror",
        "-Wno-unused-parameter",
        "-Wthread-safety",
    ],

    srcs: [
        ":lib_cachedAppOptimizer_native",
        ":lib_gameManagerService_native",
        ":lib_oomConnection_native",
        "onload.cpp",
    ],

    include_dirs: [
        "frameworks/base/libs",
        "frameworks/native/services",
        "frameworks/native/libs/math/include",
        "frameworks/native/libs/ui/include",
        "system/memory/libmeminfo/include",
    ],

    shared_libs: [
        "libandroid",
        "libandroid_runtime",
        "libbase",
        "libbinder",
        "libgralloctypes",
        "libgui",
        "libhidlbase",
        "liblog",
        "libmeminfo",
        "libmemevents",
        "libnativehelper",
        "libprocessgroup",
        "libutils",
        "libcutils",
        "android.hardware.graphics.bufferqueue@1.0",
        "android.hardware.graphics.bufferqueue@2.0",
        "android.hardware.graphics.common@1.2",
        "android.hardware.graphics.mapper@4.0",
        "android.hidl.token@1.0-utils",
    ],
}
 No newline at end of file
+48 −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.
 */

/*
 * this is a mini native libaray for cached app optimizer tests to run properly. It
 * loads all the native methods necessary.
 */
#include <nativehelper/JNIHelp.h>
#include "jni.h"
#include "utils/Log.h"
#include "utils/misc.h"

namespace android {
int register_android_server_am_CachedAppOptimizer(JNIEnv* env);
int register_android_server_app_GameManagerService(JNIEnv* env);
int register_android_server_am_OomConnection(JNIEnv* env);
};

using namespace android;

extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */)
{
    JNIEnv* env = NULL;
    jint result = -1;

    if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
        ALOGE("GetEnv failed!");
        return result;
    }
    ALOG_ASSERT(env, "Could not retrieve the env!");
    register_android_server_am_CachedAppOptimizer(env);
    register_android_server_app_GameManagerService(env);
    register_android_server_am_OomConnection(env);
    return JNI_VERSION_1_4;
}
+5 −0
Original line number Diff line number Diff line
@@ -172,4 +172,9 @@ public class AnrHelperTest {
                anyString(), any(), any(), any(), anyBoolean(), any(), eq(mAuxExecutorService),
                anyBoolean(), anyBoolean(), any());
    }

    // TODO: [b/302724778] Remove manual JNI load
    static {
        System.loadLibrary("servicestestjni");
    }
}