Merge "wificond: Move wifi keystore HAL service to wificond" am: 0a851bfbc6
am: 311251a3ca
Change-Id: I84932255c618cb884d139e608859a87ec5adafa1
diff --git a/Android.bp b/Android.bp
index d4a928e..147461c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -30,7 +30,11 @@
name: "wificond",
defaults: ["wificond_defaults"],
init_rc: ["wificond.rc"],
- srcs: ["main.cpp"],
+ srcs: [
+ "main.cpp",
+ "wifi_keystore_hal_connector.cpp"
+ ],
+ include_dirs: ["system/security/keystore/include"],
shared_libs: [
"android.hardware.wifi.offload@1.0",
@@ -39,11 +43,18 @@
"libcutils",
"libhidlbase",
"libhidltransport",
+ "libkeystore_aidl",
+ "libkeystore_binder",
+ "libkeystore_parcelables",
"libminijail",
"libutils",
"libwifi-system-iface",
+ "android.system.wifi.keystore@1.0",
],
- static_libs: ["libwificond"],
+ static_libs: [
+ "libwificond", // Wificond daemon
+ "libwifikeystorehal" // Wifi Keystore HAL service
+ ],
}
//
diff --git a/main.cpp b/main.cpp
index 4e8586f..bd87c20 100644
--- a/main.cpp
+++ b/main.cpp
@@ -37,10 +37,12 @@
#include "wificond/net/netlink_utils.h"
#include "wificond/scanning/scan_utils.h"
#include "wificond/server.h"
+#include "wifi_keystore_hal_connector.h"
using android::net::wifi::IWificond;
using android::wifi_system::InterfaceTool;
using android::wificond::ipc_constants::kServiceName;
+using android::wificond::WifiKeystoreHalConnector;
using std::unique_ptr;
namespace {
@@ -146,6 +148,9 @@
&scan_utils));
RegisterServiceOrCrash(server.get());
+ WifiKeystoreHalConnector keystore_connector;
+ keystore_connector.start();
+
event_dispatcher->Poll();
LOG(INFO) << "wificond is about to exit";
return 0;
diff --git a/wifi_keystore_hal_connector.cpp b/wifi_keystore_hal_connector.cpp
new file mode 100644
index 0000000..271e444
--- /dev/null
+++ b/wifi_keystore_hal_connector.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+#include <sys/capability.h>
+
+#include <android-base/logging.h>
+#include <android-base/macros.h>
+#include <android/hidl/manager/1.2/IServiceManager.h>
+#include <android/system/wifi/keystore/1.0/IKeystore.h>
+#include <hidl/HidlTransportSupport.h>
+
+#include <wifikeystorehal/keystore.h>
+
+#include "wifi_keystore_hal_connector.h"
+
+using android::hardware::configureRpcThreadpool;
+using android::system::wifi::keystore::V1_0::IKeystore;
+using android::system::wifi::keystore::V1_0::implementation::Keystore;
+
+namespace android {
+namespace wificond {
+
+void WifiKeystoreHalConnector::start() {
+ /**
+ * Register the wifi keystore HAL service to run in passthrough mode.
+ * This will spawn off a new thread which will service the HIDL
+ * transactions.
+ */
+ configureRpcThreadpool(1, false /* callerWillJoin */);
+ android::sp<IKeystore> wifiKeystoreHalService = new Keystore();
+ android::status_t err = wifiKeystoreHalService->registerAsService();
+ CHECK(err == android::OK) << "Cannot register wifi keystore HAL service: " << err;
+}
+} // namespace wificond
+} // namespace android
+
diff --git a/wifi_keystore_hal_connector.h b/wifi_keystore_hal_connector.h
new file mode 100644
index 0000000..58c026e
--- /dev/null
+++ b/wifi_keystore_hal_connector.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WIFICOND_WIFI_KEYSTORE_HAL_CONNECTOR_H_
+#define WIFICOND_WIFI_KEYSTORE_HAL_CONNECTOR_H_
+
+namespace android {
+namespace wificond {
+
+// Class for loading the wifi keystore HAL service.
+class WifiKeystoreHalConnector {
+ public:
+ WifiKeystoreHalConnector() = default;
+ ~WifiKeystoreHalConnector() = default;
+
+ void start();
+
+ DISALLOW_COPY_AND_ASSIGN(WifiKeystoreHalConnector);
+};
+
+} // namespace wificond
+} // namespace android
+
+#endif // WIFICOND_WIFI_KEYSTORE_HAL_CONNECTOR_H_