Skip to content
Snippets Groups Projects
Commit cf0cc726 authored by KH Shi's avatar KH Shi Committed by Gerrit Code Review
Browse files

Merge "Fix bug for failing to init Offload AIDL HAL service" into main

parents 09b1ef0a 32ef13d7
No related branches found
No related tags found
No related merge requests found
...@@ -283,13 +283,16 @@ public class OffloadHardwareInterface { ...@@ -283,13 +283,16 @@ public class OffloadHardwareInterface {
private int initWithHandles(NativeHandle h1, NativeHandle h2) { private int initWithHandles(NativeHandle h1, NativeHandle h2) {
if (h1 == null || h2 == null) { if (h1 == null || h2 == null) {
// Set mIOffload to null has two purposes:
// 1. NativeHandles can be closed after initWithHandles() fails
// 2. Prevent mIOffload.stopOffload() to be called in stopOffload()
mIOffload = null;
mLog.e("Failed to create socket."); mLog.e("Failed to create socket.");
return OFFLOAD_HAL_VERSION_NONE; return OFFLOAD_HAL_VERSION_NONE;
} }
requestSocketDump(h1); requestSocketDump(h1);
if (!mIOffload.initOffload(h1, h2, mOffloadHalCallback)) { if (!mIOffload.initOffload(h1, h2, mOffloadHalCallback)) {
mIOffload.stopOffload();
mLog.e("Failed to initialize offload."); mLog.e("Failed to initialize offload.");
return OFFLOAD_HAL_VERSION_NONE; return OFFLOAD_HAL_VERSION_NONE;
} }
...@@ -329,9 +332,9 @@ public class OffloadHardwareInterface { ...@@ -329,9 +332,9 @@ public class OffloadHardwareInterface {
mOffloadHalCallback = offloadCb; mOffloadHalCallback = offloadCb;
final int version = initWithHandles(h1, h2); final int version = initWithHandles(h1, h2);
// Explicitly close FDs for HIDL. AIDL will pass the original FDs to the service, // Explicitly close FDs for HIDL or when mIOffload is null (cleared in initWithHandles).
// they shouldn't be closed here. // AIDL will pass the original FDs to the service, they shouldn't be closed here.
if (version < OFFLOAD_HAL_VERSION_AIDL) { if (mIOffload == null || mIOffload.getVersion() < OFFLOAD_HAL_VERSION_AIDL) {
maybeCloseFdInNativeHandles(h1, h2); maybeCloseFdInNativeHandles(h1, h2);
} }
return version; return version;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment