system/hardware/interfaces
Revision | 2ec2d55c1243cb4c2e835397f63870f18683454c (tree) |
---|---|
Time | 2017-08-01 03:56:12 |
Author | Steven Moreland <smoreland@goog...> |
Commiter | android-build-merger |
Reland "create minimal HAL for NETD"
am: 7e3a96d729
Change-Id: I5c860bdcf3e0ce210c3b7171b568f4c28f46da33
@@ -1,5 +1,7 @@ | ||
1 | 1 | // This is an autogenerated file, do not edit. |
2 | 2 | subdirs = [ |
3 | + "net/netd/1.0", | |
4 | + "net/netd/1.0/vts/functional", | |
3 | 5 | "wifi/keystore/1.0", |
4 | 6 | "wifi/keystore/1.0/vts/functional", |
5 | 7 | ] |
@@ -0,0 +1,59 @@ | ||
1 | +// This file is autogenerated by hidl-gen. Do not edit manually. | |
2 | + | |
3 | +filegroup { | |
4 | + name: "android.system.net.netd@1.0_hal", | |
5 | + srcs: [ | |
6 | + "INetd.hal", | |
7 | + ], | |
8 | +} | |
9 | + | |
10 | +genrule { | |
11 | + name: "android.system.net.netd@1.0_genc++", | |
12 | + tools: ["hidl-gen"], | |
13 | + cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hidl:system/libhidl/transport -randroid.system:system/hardware/interfaces android.system.net.netd@1.0", | |
14 | + srcs: [ | |
15 | + ":android.system.net.netd@1.0_hal", | |
16 | + ], | |
17 | + out: [ | |
18 | + "android/system/net/netd/1.0/NetdAll.cpp", | |
19 | + ], | |
20 | +} | |
21 | + | |
22 | +genrule { | |
23 | + name: "android.system.net.netd@1.0_genc++_headers", | |
24 | + tools: ["hidl-gen"], | |
25 | + cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hidl:system/libhidl/transport -randroid.system:system/hardware/interfaces android.system.net.netd@1.0", | |
26 | + srcs: [ | |
27 | + ":android.system.net.netd@1.0_hal", | |
28 | + ], | |
29 | + out: [ | |
30 | + "android/system/net/netd/1.0/INetd.h", | |
31 | + "android/system/net/netd/1.0/IHwNetd.h", | |
32 | + "android/system/net/netd/1.0/BnHwNetd.h", | |
33 | + "android/system/net/netd/1.0/BpHwNetd.h", | |
34 | + "android/system/net/netd/1.0/BsNetd.h", | |
35 | + ], | |
36 | +} | |
37 | + | |
38 | +cc_library_shared { | |
39 | + name: "android.system.net.netd@1.0", | |
40 | + defaults: ["hidl-module-defaults"], | |
41 | + generated_sources: ["android.system.net.netd@1.0_genc++"], | |
42 | + generated_headers: ["android.system.net.netd@1.0_genc++_headers"], | |
43 | + export_generated_headers: ["android.system.net.netd@1.0_genc++_headers"], | |
44 | + vendor_available: true, | |
45 | + shared_libs: [ | |
46 | + "libhidlbase", | |
47 | + "libhidltransport", | |
48 | + "libhwbinder", | |
49 | + "liblog", | |
50 | + "libutils", | |
51 | + "libcutils", | |
52 | + ], | |
53 | + export_shared_lib_headers: [ | |
54 | + "libhidlbase", | |
55 | + "libhidltransport", | |
56 | + "libhwbinder", | |
57 | + "libutils", | |
58 | + ], | |
59 | +} |
@@ -0,0 +1,58 @@ | ||
1 | +/* | |
2 | + * Copyright 2017 The Android Open Source Project | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | + * See the License for the specific language governing permissions and | |
14 | + * limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +package android.system.net.netd@1.0; | |
18 | + | |
19 | +/** | |
20 | + * This is the root of the HAL module and is the interface returned when | |
21 | + * loading an implementation of the INetd HAL. | |
22 | + */ | |
23 | +interface INetd { | |
24 | + /** | |
25 | + * Return values for INetd requests | |
26 | + */ | |
27 | + enum StatusCode : int32_t { | |
28 | + OK, | |
29 | + INVALID_ARGUMENTS, | |
30 | + NO_NETWORK, | |
31 | + ALREADY_EXISTS, | |
32 | + PERMISSION_DENIED, | |
33 | + UNKNOWN_ERROR | |
34 | + }; | |
35 | + | |
36 | + /** | |
37 | + * Creates a physical network to be used for interfaces managed by the OEM | |
38 | + * | |
39 | + * @return networkHandle a handle to the OEM network. Zero implies | |
40 | + * no networks are available and created | |
41 | + * @return packetMark The packet mark that vendor network stack configuration code must use when | |
42 | + * routing packets to this network. No applications may use this mark. They must | |
43 | + * instead pass the networkHandle to the android_set*network LL-NDK APIs. | |
44 | + * @return status operation status | |
45 | + */ | |
46 | + @entry | |
47 | + @callflow(next={"*"}) | |
48 | + createOemNetwork() generates (uint64_t networkHandle, uint32_t packetMark, StatusCode status); | |
49 | + | |
50 | + /** | |
51 | + * Destroys the specified network previously created using createOemNetwork() | |
52 | + * | |
53 | + * @return status operation status | |
54 | + */ | |
55 | + @exit | |
56 | + @callflow(next="createOemNetwork") | |
57 | + destroyOemNetwork(uint64_t networkHandle) generates (StatusCode status); | |
58 | +}; |
@@ -0,0 +1,18 @@ | ||
1 | +cc_test { | |
2 | + name: "VtsHalNetNetdV1_0TargetTest", | |
3 | + srcs: [ | |
4 | + "VtsHalNetNetdV1_0TargetTest.cpp", | |
5 | + ], | |
6 | + shared_libs: [ | |
7 | + "liblog", | |
8 | + "libhidlbase", | |
9 | + "libhidltransport", | |
10 | + "libutils", | |
11 | + "android.system.net.netd@1.0", | |
12 | + ], | |
13 | + static_libs: ["VtsHalHidlTargetTestBase"], | |
14 | + cflags: [ | |
15 | + "-O0", | |
16 | + "-g", | |
17 | + ], | |
18 | +} |
@@ -0,0 +1,65 @@ | ||
1 | +/* | |
2 | + * Copyright 2017 The Android Open Source Project | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | + * See the License for the specific language governing permissions and | |
14 | + * limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +#define LOG_TAG "netd_hidl_test" | |
18 | + | |
19 | +#include <VtsHalHidlTargetTestBase.h> | |
20 | +#include <android/system/net/netd/1.0/INetd.h> | |
21 | +#include <log/log.h> | |
22 | + | |
23 | +using ::android::system::net::netd::V1_0::INetd; | |
24 | +using ::android::hardware::Return; | |
25 | +using ::android::sp; | |
26 | + | |
27 | +class NetdHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |
28 | + public: | |
29 | + virtual void SetUp() override { | |
30 | + netd = ::testing::VtsHalHidlTargetTestBase::getService<INetd>(); | |
31 | + ASSERT_NE(nullptr, netd.get()) << "Could not get HIDL instance"; | |
32 | + } | |
33 | + | |
34 | + sp<INetd> netd; | |
35 | +}; | |
36 | + | |
37 | +// positive test. Ensure netd creates an oem network and returns valid netHandle, and destroys it. | |
38 | +TEST_F(NetdHidlTest, TestCreateAndDestroyOemNetworkOk) { | |
39 | + auto cb = [this](uint64_t netHandle, uint32_t packetMark, INetd::StatusCode status) { | |
40 | + ASSERT_EQ(INetd::StatusCode::OK, status); | |
41 | + ASSERT_NE((uint64_t)0, netHandle); | |
42 | + ASSERT_NE((uint32_t)0, packetMark); | |
43 | + | |
44 | + Return<INetd::StatusCode> retStatus = netd->destroyOemNetwork(netHandle); | |
45 | + ASSERT_EQ(INetd::StatusCode::OK, retStatus); | |
46 | + }; | |
47 | + | |
48 | + Return<void> ret = netd->createOemNetwork(cb); | |
49 | + ASSERT_TRUE(ret.isOk()); | |
50 | +} | |
51 | + | |
52 | +// negative test. Ensure destroy for invalid OEM network fails appropriately | |
53 | +TEST_F(NetdHidlTest, TestDestroyOemNetworkInvalid) { | |
54 | + const uint64_t nh = 0x6600FACADE; | |
55 | + | |
56 | + Return<INetd::StatusCode> retStatus = netd->destroyOemNetwork(nh); | |
57 | + ASSERT_EQ(INetd::StatusCode::INVALID_ARGUMENTS, retStatus); | |
58 | +} | |
59 | + | |
60 | +int main(int argc, char** argv) { | |
61 | + ::testing::InitGoogleTest(&argc, argv); | |
62 | + int status = RUN_ALL_TESTS(); | |
63 | + ALOGE("Test result with status=%d", status); | |
64 | + return status; | |
65 | +} |