我有 Android java 服务,它将HAL
使用HIDL
调用与服务交互。
我有以下情况,我不确定将其视为关键。
+----------+ (AIDL) +--------------+
|App thread|-------->|Java Service | (HIDL) +-----------+
+----------+ |(SendFunction)|------->|CPP service|
+--------------+ +-----------+
^
+--------------+ |
|AnotherThread |-----|
+--------------+
的定义SendFunction
如下。
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
正在从两个不同的线程调用。使用server
的实例在哪里。CPP Server
HIDL
我的问题。
server.executeCommandResponse(status, response);
我是否需要将上述call
视为关键并同步它?asserver
对象将从两个不同的线程访问。