system/hardware/interfaces-mnstshlylh
Revision | bb7ef971703f239e8440d2a009cd75597a6b60ba (tree) |
---|---|
Time | 2019-04-19 08:12:00 |
Author | Branden Archer <brarcher@goog...> |
Commiter | Branden Archer |
Access Wifi Keystore HAL via binder
The test originally linked against the HAL directly, as well as the
generated stub to access the HAL.. This "worked", however if both the
32-bit and 64-bit versions of the generated stub library were
not present the test would fail. It turned out that on AOSP builds
this was the case, as a 32-bit version of android.system.wifi.keystore
was not present as it was never used at runtime.
To avoid this issue, the stub is now linked statically. Further, the
HAL under test is accessed over binder.
Bug: 130207625
Test: On an AOSP build:
Change-Id: I02cac1e89c8bed45a4b9b98820c86500327891b6
Merged-In: I138f3e7809a337cec81dccbc52c7a9170acd1d3d
@@ -27,15 +27,18 @@ cc_test { | ||
27 | 27 | "libhidltransport", |
28 | 28 | "libnativehelper", |
29 | 29 | "libutils", |
30 | - "android.system.wifi.keystore@1.0", | |
31 | - "libwifikeystorehal", | |
32 | 30 | "libkeystore_binder", |
33 | 31 | "libbinder", |
34 | 32 | "libkeystore_aidl", |
35 | 33 | "libkeystore_parcelables", |
36 | 34 | "libkeymaster4support", |
35 | + "libbinderthreadstate", | |
36 | + "libhwbinder", | |
37 | + ], | |
38 | + static_libs: [ | |
39 | + "VtsHalHidlTargetTestBase", | |
40 | + "android.system.wifi.keystore@1.0", | |
37 | 41 | ], |
38 | - static_libs: ["VtsHalHidlTargetTestBase"], | |
39 | 42 | cflags: [ |
40 | 43 | "-O0", |
41 | 44 | "-g", |
@@ -17,12 +17,14 @@ | ||
17 | 17 | #include <android-base/logging.h> |
18 | 18 | |
19 | 19 | #include <VtsHalHidlTargetTestBase.h> |
20 | +#include <android/security/keystore/IKeystoreService.h> | |
21 | +#include <android/system/wifi/keystore/1.0/IKeystore.h> | |
22 | +#include <binder/IServiceManager.h> | |
20 | 23 | #include <binder/ProcessState.h> |
21 | 24 | #include <keymasterV4_0/authorization_set.h> |
22 | 25 | #include <keystore/keystore_promises.h> |
23 | 26 | #include <private/android_filesystem_config.h> |
24 | 27 | #include <utils/String16.h> |
25 | -#include <wifikeystorehal/keystore.h> | |
26 | 28 | |
27 | 29 | using namespace std; |
28 | 30 | using namespace ::testing; |
@@ -30,7 +32,8 @@ using namespace android; | ||
30 | 32 | using namespace android::binder; |
31 | 33 | using namespace android::security::keystore; |
32 | 34 | using namespace android::security::keymaster; |
33 | -using namespace android::system::wifi::keystore::V1_0; | |
35 | +using android::security::keystore::IKeystoreService; | |
36 | +using android::system::wifi::keystore::V1_0::IKeystore; | |
34 | 37 | |
35 | 38 | int main(int argc, char** argv) { |
36 | 39 | // Start thread pool for Binder |
@@ -52,7 +55,8 @@ enum KeyPurpose { | ||
52 | 55 | class WifiKeystoreHalTest : public Test { |
53 | 56 | protected: |
54 | 57 | void SetUp() override { |
55 | - keystore = implementation::HIDL_FETCH_IKeystore(nullptr); | |
58 | + keystore = IKeystore::getService(); | |
59 | + ASSERT_TRUE(keystore); | |
56 | 60 | |
57 | 61 | sp<android::IServiceManager> service_manager = android::defaultServiceManager(); |
58 | 62 | sp<android::IBinder> keystore_binder = |
@@ -198,7 +202,7 @@ class WifiKeystoreHalTest : public Test { | ||
198 | 202 | constexpr static const char kTestKeyName[] = "TestKeyName"; |
199 | 203 | constexpr static const int32_t UID_SELF = -1; |
200 | 204 | |
201 | - IKeystore* keystore = nullptr; | |
205 | + sp<IKeystore> keystore; | |
202 | 206 | sp<IKeystoreService> service; |
203 | 207 | }; |
204 | 208 |
@@ -206,7 +210,7 @@ class WifiKeystoreHalTest : public Test { | ||
206 | 210 | * Test for the Wifi Keystore HAL's sign() call. |
207 | 211 | */ |
208 | 212 | TEST_F(WifiKeystoreHalTest, Sign) { |
209 | - IKeystore::KeystoreStatusCode statusCode; | |
213 | + ::android::system::wifi::keystore::V1_0::IKeystore::KeystoreStatusCode statusCode; | |
210 | 214 | |
211 | 215 | auto callback = [&statusCode](IKeystore::KeystoreStatusCode status, |
212 | 216 | const ::android::hardware::hidl_vec<uint8_t>& /*value*/) { |