I have Android java service which will interact with HAL
service using HIDL
calls.
I have below scenario, I'm not sure to treat it as critical.
+----------+ (AIDL) +--------------+
|App thread|-------->|Java Service | (HIDL) +-----------+
+----------+ |(SendFunction)|------->|CPP service|
+--------------+ +-----------+
^
+--------------+ |
|AnotherThread |-----|
+--------------+
Definition of SendFunction
is as below.
private void SendFunction(int status, DiagCommandDesc response) {
try {
server.executeCommandResponse(status, response);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Response sent to HAL.");
}
} catch (Exception e) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "HAL Server error.");
}
}
}
SendFunction
is being called from two different threads.
Where server
is an instance to CPP Server
using HIDL
.
MY question.
server.executeCommandResponse(status, response);
Do I need to treat above call
as critical and synchronize it? as server
object will be accessed from two different threads.