Android jni framework internal class init and use help need

i am using c++ for target to build android internal framework api.
api is accessible i tested with frida hooking methods.
for reference link https://github.com/frida/frida/issues/1867

java code here.

public x3Client(Context arg2) {
        super();
        this.mLock = new Object();
        this.mConnection = new com.x1.android.x2.client.x3Client$1(this);
        this.mContext = arg2;
        this.mBound = false;
        this.mSuccess = false;
}

public void bindService() {
        Object v0 = this.mLock;
        __monitor_enter(v0);
        try {
            if(!this.mBound) {
                Intent v1_1 = new Intent();
                v1_1.setComponent(new ComponentName("com.x1.android.x2", "com.x1.android.x2.x3Service"));
                if(this.mContext.bindService(v1_1, this.mConnection, 1)) {
                    this.mSuccess = true;
                    Log.d("x3Client", "Bind service successfully");
                }
                else {
                    this.mSuccess = false;
                    Log.e("x3Client", "Bind service fail!!");
                }
            }

            __monitor_exit(v0);
            return;
        label_29:
            __monitor_exit(v0);
        }
        catch(Throwable v1) {
            goto label_29;
        }

        throw v1;
}

public String getFactoryVersion() {
        Response v1 = this.request(4011, new byte[30]);
        if(v1 == null) {
            return "";
        }
        return new String(v1.data, 0, v1.length);
}

My issue is how to get context for this init ?

with jni

myclass =env->FindClass("com/x1/android/x2/client/x3Client") 
and 
method_buildx1 = env->GetStaticMethodID(myclass,"<init>","(Landroid/content/Context;)V")

How do i get Context for jni ? i have to build apk and pass this to my lib or i have any other way ?

Without calling init or building constructor & context i can’t use bindService function its return error or crash on this.mLock not accessible or valid.

Is there any way around for get this server in JNI C++ only ?
Please note that this service is not accessible on normal shell "sm-getService(String16("")) not working" only created on demand by bindService.

Source: Windows Questions C++

LEAVE A COMMENT