NDK on android frameworks

63 views
Skip to first unread message

Zacchaeus Liang

unread,
Aug 15, 2020, 5:57:34 AM8/15/20
to android-ndk

Hello i've been trying to call a JNI library in Android Keyguard (frameworks/base/packages/SystemUI). I was able to do it in Android Settings but now I need it to be called in Keyguard. Currently, the Shared object is being built. It's located in the /system/lib64 (my one used in android settings is also located in the 32 bit lib) location. It's not being called when I'm supposed to use it. No errors are shown on logcat saying that the jni is missing.

My Android.mk File in the /jni folder.

LOCAL_PATH := $(call my-dir)
include $
(CLEAR_VARS)
LOCAL_MULTILIB := both
LOCAL_MODULE := liblock-jni
LOCAL_SRC_FILES := lock-jni.c
LOCAL_C_INCLUDES +=$(JNI_H_INCLUDE)
LOCAL_CFLAGS += -O0 -g3
include $(BUILD_SHARED_LIBRARY)

This is the declaration in my function for the java class.

JNIEXPORT jstring JNICALL Java_com_android_keyguard_LockJni_stringFromJNI(JNIEnv *env, jobject thisObj , jstring inJNIStr) {

I've got a method defined like this to call it in my jni class. This is located in SystemUI/Keygard.

package com.android.keyguard;


import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;
import android.util.Log;



public class LockJni
{

    public native String  stringFromJNI(String param);

    static {
           Log.d( "library loaded:", "hello");


        System.loadLibrary("lock-jni");
    }
                public LockJni(){

                }
}

Thanks for the help!!

Reply all
Reply to author
Forward
0 new messages