0

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.

  • Does this answer your question? [Static way to get 'Context' in Android?](https://stackoverflow.com/questions/2002288/static-way-to-get-context-in-android) – Botje Oct 05 '21 at 07:58
  • Hello its java and my requirement is ndk jni. But i have try this by making apk and pass context of current app and system both but its still fail to execute possible reason i think this cant be done without root or i am still missing correct way for context. – rockymaster Oct 06 '21 at 08:07
  • Have you found a solution? Half a year later I am struggling with exactly the same problem. Have you tried NativeActivity? – Flot2011 Mar 30 '22 at 11:44
  • i found no way, no way to get context which application need. without application context can not access this class. – rockymaster Mar 31 '22 at 13:23

0 Answers0