File tree Expand file tree Collapse file tree 3 files changed +26
-5
lines changed
Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,13 @@ android {
2626 }
2727
2828 buildFeatures {
29+ prefab true
2930 viewBinding true
3031 }
3132}
3233
3334dependencies {
35+ implementation project(" :base" )
3436 implementation libs. appcompat
3537 implementation libs. material
3638 implementation libs. androidx. constraintlayout
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.22.1)
22project (OrderfileDemo CXX)
33
44include (AppLibrary)
5+ find_package (base CONFIG REQUIRED)
56
67# We have setup build variables that you can just comment or uncomment to use.
78# Make sure to have only one build variable uncommented at a time.
@@ -13,7 +14,7 @@ set(GENERATE_PROFILES ON)
1314#set(USE_PROFILE "${CMAKE_SOURCE_DIR}/demo.orderfile")
1415
1516add_app_library(orderfiledemo SHARED orderfile.cpp)
16- target_link_libraries (orderfiledemo log )
17+ target_link_libraries (orderfiledemo PRIVATE base::base log )
1718
1819if (GENERATE_PROFILES)
1920 # Generating profiles requires any optimization flag aside from -O0.
Original file line number Diff line number Diff line change 11#include < android/log.h>
2+ #include < base/macros.h>
23#include < errno.h>
34#include < jni.h>
45#include < linux/limits.h>
@@ -46,9 +47,26 @@ void DumpProfileDataIfNeeded(const char* temp_dir) {
4647#endif
4748}
4849
49- extern " C" JNIEXPORT void JNICALL
50- Java_com_example_orderfiledemo_MainActivity_runWorkload (JNIEnv* env,
51- jobject /* this */ ,
52- jstring temp_dir) {
50+ void RunWorkload (JNIEnv* env, jobject /* this */ , jstring temp_dir) {
5351 DumpProfileDataIfNeeded (env->GetStringUTFChars (temp_dir, 0 ));
5452}
53+
54+ extern " C" JNIEXPORT jint JNICALL JNI_OnLoad (JavaVM* _Nonnull vm,
55+ void * _Nullable) {
56+ JNIEnv* env;
57+ if (vm->GetEnv (reinterpret_cast <void **>(&env), JNI_VERSION_1_6) != JNI_OK) {
58+ return JNI_ERR;
59+ }
60+
61+ jclass c = env->FindClass (" com/example/orderfiledemo/MainActivity" );
62+ if (c == nullptr ) return JNI_ERR;
63+
64+ static const JNINativeMethod methods[] = {
65+ {" runWorkload" , " (Ljava/lang/String;)V" ,
66+ reinterpret_cast <void *>(RunWorkload)},
67+ };
68+ int rc = env->RegisterNatives (c, methods, arraysize (methods));
69+ if (rc != JNI_OK) return rc;
70+
71+ return JNI_VERSION_1_6;
72+ }
You can’t perform that action at this time.
0 commit comments