I have searched around StackOverflow and found several related issues, but none that answers my direct problems.
I want to open a serial port on a specific Android device through an Android app.
The device contained an original apk with some functionality for the serial port.
I have reversed engineered the apk, found the correct .so file in system/lib64 folder on the device so I know how the old app uses this project.
What i know:
- The serial port uses Uart for communication
- The .so file is used in another application so it has the correct functionality.
- Reverse engineering let me see the basic functionality and names used for the functions.
- The device runs Android 10
- It runs a arm64-v8a processor
- The old .so library is added to folder jniLibs, found and loaded.
I do not have the orginal .c file and .h file used in the jni setup for the library.
I do not have any documentation of the serial device or the original device since the manufactorer did not provide this, so building a new native library could be hard.
The reversed engineered liboldnativelibrary.so files method is this: (jobject i have put in myself from gidhra)
jobject Java_com_the_old_serialportApp_SerialPort_open
(JNIEnv *penv,undefined8 param_2,jstring inputString,speed_t baudRate,
uint hiddenParam)
I have written this code
package com.myself.serialporttesting
companion object {
init {
try {
Log.i("Library", "Loading library")
System.loadLibrary("oldnativelibrary")
Log.i("Library", "Library loaded successfully")
} catch (e: UnsatisfiedLinkError) {
Log.i("Library", "Library not loaded")
}
}
private external fun open(
fileName: String,
baudRate: Int,
hiddenValue: Int
): FileDescriptor
}
I get the error message: No implementation found for java.io.FileDescriptor com.hfad.serialporttesting.SerialPort$Companion.open(java.lang.String, int, int)
I believe it is a naming issue since my package is called something else. Is this true, and is it possible to work around that?