Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android binder generator fails

I have defined an AIDL file with my interface. Something like this:

interface IResPlugin {
    int discoverType();
    Map onClick( in int id, in Map state );
    int getLayoutId(in int option);
    int getMeasures();
    String getName();
}

Automatically, Eclipse generates the IResplugin.java in gen folder, but it does it wrong. This is the code Eclipse generates:

public java.util.Map onClick(int id, java.util.Map state) throws android.os.RemoteException
{
    android.os.Parcel _data = android.os.Parcel.obtain();
    android.os.Parcel _reply = android.os.Parcel.obtain();
    java.util.Map _result;
    try {
        _data.writeInterfaceToken(DESCRIPTOR);
        _data.writeInt(id);
        _data.writeMap(state);
        mRemote.transact(Stub.TRANSACTION_onClick, _data, _reply, 0);
        _reply.readException();
        _result = _reply.readHashMap(cl);
    }
    finally {
        _reply.recycle();
        _data.recycle();
    }
    return _result;
}

The line _result = _replu.readHashMap(cl) crashes because the cl object doesn't exist. If I add this line manually (a classloader is missing), Eclipse replaces my version for a generated one by itself (and again, wrong).

Any ideas?

like image 278
hilbert Avatar asked Nov 14 '22 15:11

hilbert


1 Answers

It looks like a bug an aidl, that would be worth filing a bug in the bug tracker for.

As a work-around, you could use Bundle instead of Map.

Or another approach you could take is to implement your own Parcelable class that contains the Map<> instead, and use that as the return type.

like image 143
hackbod Avatar answered Jan 07 '23 20:01

hackbod