diff options
-rw-r--r-- | vibrator/1.2/Android.bp | 23 | ||||
-rw-r--r-- | vibrator/1.2/IVibrator.hal | 37 | ||||
-rw-r--r-- | vibrator/1.2/types.hal | 64 | ||||
-rw-r--r-- | vibrator/1.2/vts/functional/Android.bp | 27 | ||||
-rw-r--r-- | vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp | 72 |
5 files changed, 223 insertions, 0 deletions
diff --git a/vibrator/1.2/Android.bp b/vibrator/1.2/Android.bp new file mode 100644 index 00000000..88192c18 --- /dev/null +++ b/vibrator/1.2/Android.bp | |||
@@ -0,0 +1,23 @@ | |||
1 | // This file is autogenerated by hidl-gen -Landroidbp. | ||
2 | |||
3 | hidl_interface { | ||
4 | name: "android.hardware.vibrator@1.2", | ||
5 | root: "android.hardware", | ||
6 | vndk: { | ||
7 | enabled: true, | ||
8 | }, | ||
9 | srcs: [ | ||
10 | "types.hal", | ||
11 | "IVibrator.hal", | ||
12 | ], | ||
13 | interfaces: [ | ||
14 | "android.hardware.vibrator@1.0", | ||
15 | "android.hardware.vibrator@1.1", | ||
16 | "android.hidl.base@1.0", | ||
17 | ], | ||
18 | types: [ | ||
19 | "Effect", | ||
20 | ], | ||
21 | gen_java: true, | ||
22 | } | ||
23 | |||
diff --git a/vibrator/1.2/IVibrator.hal b/vibrator/1.2/IVibrator.hal new file mode 100644 index 00000000..7244da1b --- /dev/null +++ b/vibrator/1.2/IVibrator.hal | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 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.hardware.vibrator@1.2; | ||
18 | |||
19 | import @1.0::EffectStrength; | ||
20 | import @1.0::Status; | ||
21 | import @1.1::IVibrator; | ||
22 | |||
23 | interface IVibrator extends @1.1::IVibrator { | ||
24 | /** | ||
25 | * Fire off a predefined haptic event. | ||
26 | * | ||
27 | * @param event The type of haptic event to trigger. | ||
28 | * @return status Whether the effect was successfully performed or not. Must | ||
29 | * return Status::UNSUPPORTED_OPERATION is the effect is not supported. | ||
30 | * @return lengthMs The length of time the event is expected to take in | ||
31 | * milliseconds. This doesn't need to be perfectly accurate, but should be a reasonable | ||
32 | * approximation. Should be a positive, non-zero value if the returned status is Status::OK, | ||
33 | * and set to 0 otherwise. | ||
34 | */ | ||
35 | perform_1_2(Effect effect, EffectStrength strength) | ||
36 | generates (Status status, uint32_t lengthMs); | ||
37 | }; | ||
diff --git a/vibrator/1.2/types.hal b/vibrator/1.2/types.hal new file mode 100644 index 00000000..7604f2ce --- /dev/null +++ b/vibrator/1.2/types.hal | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 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.hardware.vibrator@1.2; | ||
18 | |||
19 | import @1.1::Effect_1_1; | ||
20 | |||
21 | // Note that while the previous type had a version suffix, this type does not. This is because the | ||
22 | // versions are already present in the namespace and thus don't need to also be embedded in the | ||
23 | // name of the type. | ||
24 | enum Effect : @1.1::Effect_1_1 { | ||
25 | /** | ||
26 | * A thud effect. | ||
27 | * | ||
28 | * This effect should solid feeling bump, like the depression of a heavy mechanical button. | ||
29 | */ | ||
30 | THUD, | ||
31 | /** | ||
32 | * A pop effect. | ||
33 | * | ||
34 | * A short, quick burst effect. | ||
35 | */ | ||
36 | POP, | ||
37 | |||
38 | /** | ||
39 | * A heavy click effect. | ||
40 | * | ||
41 | * This should produce a sharp striking sensation, like a click but stronger. | ||
42 | */ | ||
43 | HEAVY_CLICK, | ||
44 | |||
45 | /** | ||
46 | * Ringtone patterns. They may correspond with the device's ringtone audio, or may just be a | ||
47 | * pattern that can be played as a ringtone with any audio, depending on the device. | ||
48 | */ | ||
49 | RINGTONE_1, | ||
50 | RINGTONE_2, | ||
51 | RINGTONE_3, | ||
52 | RINGTONE_4, | ||
53 | RINGTONE_5, | ||
54 | RINGTONE_6, | ||
55 | RINGTONE_7, | ||
56 | RINGTONE_8, | ||
57 | RINGTONE_9, | ||
58 | RINGTONE_10, | ||
59 | RINGTONE_11, | ||
60 | RINGTONE_12, | ||
61 | RINGTONE_13, | ||
62 | RINGTONE_14, | ||
63 | RINGTONE_15, | ||
64 | }; | ||
diff --git a/vibrator/1.2/vts/functional/Android.bp b/vibrator/1.2/vts/functional/Android.bp new file mode 100644 index 00000000..3a4e2efd --- /dev/null +++ b/vibrator/1.2/vts/functional/Android.bp | |||
@@ -0,0 +1,27 @@ | |||
1 | // | ||
2 | // Copyright (C) 2018 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 | cc_test { | ||
18 | name: "VtsHalVibratorV1_2TargetTest", | ||
19 | defaults: ["VtsHalTargetTestDefaults"], | ||
20 | srcs: ["VtsHalVibratorV1_2TargetTest.cpp"], | ||
21 | static_libs: [ | ||
22 | "android.hardware.vibrator@1.0", | ||
23 | "android.hardware.vibrator@1.1", | ||
24 | "android.hardware.vibrator@1.2", | ||
25 | ], | ||
26 | } | ||
27 | |||
diff --git a/vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp b/vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp new file mode 100644 index 00000000..d07d1b78 --- /dev/null +++ b/vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 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 "vibrator_hidl_hal_test" | ||
18 | |||
19 | #include <VtsHalHidlTargetTestBase.h> | ||
20 | #include <android-base/logging.h> | ||
21 | #include <android/hardware/vibrator/1.0/types.h> | ||
22 | #include <android/hardware/vibrator/1.2/IVibrator.h> | ||
23 | #include <android/hardware/vibrator/1.2/types.h> | ||
24 | #include <unistd.h> | ||
25 | |||
26 | using ::android::hardware::vibrator::V1_0::Status; | ||
27 | using ::android::hardware::vibrator::V1_0::EffectStrength; | ||
28 | using ::android::hardware::vibrator::V1_2::Effect; | ||
29 | using ::android::hardware::vibrator::V1_2::IVibrator; | ||
30 | using ::android::hardware::hidl_enum_iterator; | ||
31 | using ::android::hardware::Return; | ||
32 | using ::android::hardware::Void; | ||
33 | using ::android::sp; | ||
34 | |||
35 | // The main test class for VIBRATOR HIDL HAL 1.2. | ||
36 | class VibratorHidlTest_1_2 : public ::testing::VtsHalHidlTargetTestBase { | ||
37 | public: | ||
38 | virtual void SetUp() override { | ||
39 | vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>(); | ||
40 | ASSERT_NE(vibrator, nullptr); | ||
41 | } | ||
42 | |||
43 | virtual void TearDown() override {} | ||
44 | |||
45 | sp<IVibrator> vibrator; | ||
46 | }; | ||
47 | |||
48 | static void validatePerformEffect(Status status, uint32_t lengthMs) { | ||
49 | ASSERT_TRUE(status == Status::OK || status == Status::UNSUPPORTED_OPERATION); | ||
50 | if (status == Status::OK) { | ||
51 | ASSERT_GT(lengthMs, static_cast<uint32_t>(0)) | ||
52 | << "Effects that return OK must return a non-zero duration"; | ||
53 | } else { | ||
54 | ASSERT_EQ(lengthMs, static_cast<uint32_t>(0)) | ||
55 | << "Effects that return UNSUPPORTED_OPERATION must have a duration of zero"; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | TEST_F(VibratorHidlTest_1_2, PerformEffect_1_2) { | ||
60 | for (const auto& effect : hidl_enum_iterator<Effect>()) { | ||
61 | for (const auto& strength : hidl_enum_iterator<EffectStrength>()) { | ||
62 | vibrator->perform_1_2(effect, strength, validatePerformEffect); | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | |||
67 | int main(int argc, char** argv) { | ||
68 | ::testing::InitGoogleTest(&argc, argv); | ||
69 | int status = RUN_ALL_TESTS(); | ||
70 | LOG(INFO) << "Test result = " << status; | ||
71 | return status; | ||
72 | } | ||