HIDL interface inheritance

676 Views Asked by At

I am trying to extend the implementation of HAL functionality. It seems that once HAL interface is published, we cannot made any changes in that version. So I tried to do interface inheritance by referring here https://source.android.com/devices/architecture/hidl-java#extensions.

IA.HAL File

interface IA{
Amethod();
};

ClientService.Java file

IA ia = IA.getService(true);
//ia is not null. Working fine

For extension, I created a new HAL file which involves interface inheritance as below.

IB.HAL file

import IA;
interface IB extends IA{
Bmethod()
};

ClientService.Java file

IA ia = IA.getService(true);
//ia is not null. Working fine
IB ib = IB.castFrom(ia);
**// ib is null. Issue**

Any idea what I am doing wrong. Thanks in advance.

1

There are 1 best solutions below

0
On

A HAL server is identified by its interface name and its instance name. Could it be that the server providing IA is still running?

You might have the following setup at the moment:

Binary Interface Instance
/system/bin/ia-service IA "default"
/vendor/bin/ib-service IB "default"

The default for getService is to use "default" as instance.

Solutions:

  1. Make sure ia-service is not started.
  2. Provide your HAL with a new instance name (e.g. "new") by calling registerAsService("new") in ib-service and get the instance with ```getService("new", true)````in your client.