android binder parcel issue with multiple arguments

i am having issue with binder and parcel multiple arguments.
i am using linux android ndk 21d latest.
coding in c++

function i am using with transaction code have this sign in java

    int somefunction(byte[] input,byte[] reply,int method) {
    
    v0_1 = this.process(input);
    if(v0_1 != null) {
       if(v0_1.length == 1 && v0_1[0] == v4) {
        goto label_27;
    }
        System.arraycopy(((byte[])v0_1), 0, reply, 0, v0_1[0] + 2);
        v0 = 0;
}
}

Method i used is following.

sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> phone = sm->getService(String16("someservice")); 
Parcel data;
Parcel reply;
data.writeInterfaceToken(String16("someinterface"));
char buffer1[256];
int method = 1;
memset(buffer1,'{$content}',sizeof(buffer1));
char outbuffer[256];
memset(outbuffer,'{$content}',sizeof(outbuffer));
data.writeInt32(sizeof(buffer1));
data.write(buffer1, sizeof(buffer1));
data.writeInt32(sizeof(outbuffer));
data.write(outbuffer, sizeof(outbuffer));
data.writeInt32(method);
int status = phone->transact("transaction code",data,&reply,0);

function execute fine but i get following error.

01-01 19:58:57.208  7465  7465 E AndroidRuntime: FATAL EXCEPTION: main
01-01 19:58:57.208  7465  7465 E AndroidRuntime: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0

i am not sure what i am missing any one can help ?

Source: Windows Questions C++

LEAVE A COMMENT