diff options
author | Devin Moore <devinmoore@google.com> | 2023-12-06 22:28:35 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2023-12-06 22:28:35 +0000 |
commit | 3fbd84983865847cf317c8ebee8de6663cfc3abc (patch) | |
tree | efcbd9408a35fda1d638947f82d65d8208ebf40c | |
parent | cd8f9a2521f1b26e8e40bdc9e4ae60edf4ac1545 (diff) | |
download | interfaces-3fbd84983865847cf317c8ebee8de6663cfc3abc.tar.gz |
Revert "Introducing IVibratorController and IVibratorControlService"
Revert submission 25200993-add-ivibratorcontroller
Reason for revert: Broken Cuttlefish tests
Reverted changes: /q/submissionid:25200993-add-ivibratorcontroller
Change-Id: Iaa186266d244f2f781a547a4ad67d12b287aa818
15 files changed, 0 insertions, 649 deletions
diff --git a/vibrator/OWNERS b/vibrator/OWNERS deleted file mode 100644 index c4de58a..0000000 --- a/vibrator/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# Bug component: 345036 -include platform/frameworks/base:/services/core/java/com/android/server/vibrator/OWNERS diff --git a/vibrator/aidl/Android.bp b/vibrator/aidl/Android.bp deleted file mode 100644 index 0451921..0000000 --- a/vibrator/aidl/Android.bp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ - -package { - default_applicable_licenses: ["Android-Apache-2.0"], -} - -aidl_interface { - name: "android.frameworks.vibrator", - srcs: ["android/frameworks/vibrator/*.aidl"], - owner: "google", - vendor_available: true, - host_supported: true, - stability: "vintf", - backend: { - java: { - platform_apis: true, - }, - ndk: { - enabled: true, - }, - cpp: { - enabled: false, - }, - }, - frozen: false, - -} diff --git a/vibrator/aidl/TEST_MAPPING b/vibrator/aidl/TEST_MAPPING deleted file mode 100644 index f7f7b11..0000000 --- a/vibrator/aidl/TEST_MAPPING +++ /dev/null @@ -1,7 +0,0 @@ -{ - "postsubmit": [ - { - "name": "VtsHalVibratorControlServiceTargetTest" - } - ] -} diff --git a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorControlService.aidl b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorControlService.aidl deleted file mode 100644 index f6a0e11..0000000 --- a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorControlService.aidl +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ -/////////////////////////////////////////////////////////////////////////////// -// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // -/////////////////////////////////////////////////////////////////////////////// - -// This file is a snapshot of an AIDL file. Do not edit it manually. There are -// two cases: -// 1). this is a frozen version file - do not edit this in any case. -// 2). this is a 'current' file. If you make a backwards compatible change to -// the interface (from the latest frozen version), the build system will -// prompt you to update this file with `m <name>-update-api`. -// -// You must not make a backward incompatible change to any AIDL file built -// with the aidl_interface module type with versions property set. The module -// type is used to build AIDL files in a way that they can be used across -// independently updatable components of the system. If a device is shipped -// with such a backward incompatible change, it has a high risk of breaking -// later when a module using the interface is updated, e.g., Mainline modules. - -package android.frameworks.vibrator; -/* @hide */ -@VintfStability -interface IVibratorControlService { - oneway void registerVibratorController(in android.frameworks.vibrator.IVibratorController controller); - oneway void unregisterVibratorController(in android.frameworks.vibrator.IVibratorController controller); - oneway void setVibrationParams(in android.frameworks.vibrator.VibrationParam[] params, in android.frameworks.vibrator.IVibratorController token); - oneway void clearVibrationParams(in android.frameworks.vibrator.VibrationTypeMask types, in android.frameworks.vibrator.IVibratorController token); - oneway void onRequestVibrationParamsComplete(in IBinder requestToken, in android.frameworks.vibrator.VibrationParam[] result); -} diff --git a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorController.aidl b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorController.aidl deleted file mode 100644 index 324fb49..0000000 --- a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/IVibratorController.aidl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ -/////////////////////////////////////////////////////////////////////////////// -// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // -/////////////////////////////////////////////////////////////////////////////// - -// This file is a snapshot of an AIDL file. Do not edit it manually. There are -// two cases: -// 1). this is a frozen version file - do not edit this in any case. -// 2). this is a 'current' file. If you make a backwards compatible change to -// the interface (from the latest frozen version), the build system will -// prompt you to update this file with `m <name>-update-api`. -// -// You must not make a backward incompatible change to any AIDL file built -// with the aidl_interface module type with versions property set. The module -// type is used to build AIDL files in a way that they can be used across -// independently updatable components of the system. If a device is shipped -// with such a backward incompatible change, it has a high risk of breaking -// later when a module using the interface is updated, e.g., Mainline modules. - -package android.frameworks.vibrator; -/* @hide */ -@VintfStability -interface IVibratorController { - oneway void requestVibrationParams(in android.frameworks.vibrator.VibrationTypeMask type, in long deadlineElapsedRealtimeMillis, in IBinder requestToken); -} diff --git a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/ScaleParam.aidl b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/ScaleParam.aidl deleted file mode 100644 index f2b8931..0000000 --- a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/ScaleParam.aidl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ -/////////////////////////////////////////////////////////////////////////////// -// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // -/////////////////////////////////////////////////////////////////////////////// - -// This file is a snapshot of an AIDL file. Do not edit it manually. There are -// two cases: -// 1). this is a frozen version file - do not edit this in any case. -// 2). this is a 'current' file. If you make a backwards compatible change to -// the interface (from the latest frozen version), the build system will -// prompt you to update this file with `m <name>-update-api`. -// -// You must not make a backward incompatible change to any AIDL file built -// with the aidl_interface module type with versions property set. The module -// type is used to build AIDL files in a way that they can be used across -// independently updatable components of the system. If a device is shipped -// with such a backward incompatible change, it has a high risk of breaking -// later when a module using the interface is updated, e.g., Mainline modules. - -package android.frameworks.vibrator; -@VintfStability -parcelable ScaleParam { - android.frameworks.vibrator.VibrationTypeMask types; - float scale; -} diff --git a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationParam.aidl b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationParam.aidl deleted file mode 100644 index ddf7d05..0000000 --- a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationParam.aidl +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ -/////////////////////////////////////////////////////////////////////////////// -// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // -/////////////////////////////////////////////////////////////////////////////// - -// This file is a snapshot of an AIDL file. Do not edit it manually. There are -// two cases: -// 1). this is a frozen version file - do not edit this in any case. -// 2). this is a 'current' file. If you make a backwards compatible change to -// the interface (from the latest frozen version), the build system will -// prompt you to update this file with `m <name>-update-api`. -// -// You must not make a backward incompatible change to any AIDL file built -// with the aidl_interface module type with versions property set. The module -// type is used to build AIDL files in a way that they can be used across -// independently updatable components of the system. If a device is shipped -// with such a backward incompatible change, it has a high risk of breaking -// later when a module using the interface is updated, e.g., Mainline modules. - -package android.frameworks.vibrator; -@VintfStability -union VibrationParam { - android.frameworks.vibrator.ScaleParam scale; -} diff --git a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationTypeMask.aidl b/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationTypeMask.aidl deleted file mode 100644 index 909a513..0000000 --- a/vibrator/aidl/aidl_api/android.frameworks.vibrator/current/android/frameworks/vibrator/VibrationTypeMask.aidl +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ -/////////////////////////////////////////////////////////////////////////////// -// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // -/////////////////////////////////////////////////////////////////////////////// - -// This file is a snapshot of an AIDL file. Do not edit it manually. There are -// two cases: -// 1). this is a frozen version file - do not edit this in any case. -// 2). this is a 'current' file. If you make a backwards compatible change to -// the interface (from the latest frozen version), the build system will -// prompt you to update this file with `m <name>-update-api`. -// -// You must not make a backward incompatible change to any AIDL file built -// with the aidl_interface module type with versions property set. The module -// type is used to build AIDL files in a way that they can be used across -// independently updatable components of the system. If a device is shipped -// with such a backward incompatible change, it has a high risk of breaking -// later when a module using the interface is updated, e.g., Mainline modules. - -package android.frameworks.vibrator; -@Backing(type="int") @VintfStability -enum VibrationTypeMask { - ALARM = (1 << 0) /* 1 */, - NOTIFICATION = (1 << 1) /* 2 */, - RINGTONE = (1 << 2) /* 4 */, - INTERACTIVE = (1 << 3) /* 8 */, - MEDIA = (1 << 4) /* 16 */, -} diff --git a/vibrator/aidl/android/frameworks/vibrator/IVibratorControlService.aidl b/vibrator/aidl/android/frameworks/vibrator/IVibratorControlService.aidl deleted file mode 100644 index 12da57d..0000000 --- a/vibrator/aidl/android/frameworks/vibrator/IVibratorControlService.aidl +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ - -package android.frameworks.vibrator; - -import android.frameworks.vibrator.IVibratorController; -import android.frameworks.vibrator.VibrationParam; -import android.frameworks.vibrator.VibrationTypeMask; - -/** - * IVibratorControlService is a service that allows clients to register IVibratorControllers to - * receive VibrationParams. It also allows the client to set and clear VibrationParams. - * @hide - */ -@VintfStability -interface IVibratorControlService { - /** - * Registers an IVibratorController to allow pushing VibrationParams. These params will be used - * to modify vibration characteristics, such as scaling. - * <p>Only one controller should be registered at the same time. Registering a new controller - * must unregister the old controller before registering the new one. - * - * @param controller The vibrator controller used for pulling requests. - */ - oneway void registerVibratorController(in IVibratorController controller); - - /** - * Unregisters an IVibratorController. - * <p>If the provided controller is not the registered one, the request must be ignored. - * - * @param controller The vibrator controller to be removed. - */ - oneway void unregisterVibratorController(in IVibratorController controller); - - /** - * Sets VibrationParams which will be used to modify some vibration characteristics, such as - * scaling. - * <p>If the provided controller is not the registered one, the request must be ignored. - * - * @param params The vibration params to be applied to new vibrations. - * @param token The token to register a death recipient to expire these params. - */ - oneway void setVibrationParams(in VibrationParam[] params, in IVibratorController token); - - /** - * Clears any set VibrationParams and reverts the vibration characteristics to their default - * settings. - * <p>If the provided controller is not the registered one, the request must be ignored. - * - * @param type The combined bitfield of VibrationTypeMask to be cleared - * @param token The token to register a death recipient to expire these params - */ - oneway void clearVibrationParams(in VibrationTypeMask types, in IVibratorController token); - - /** - * Notifies the VibrationControlService of new VibrationParams. - * <p>This method must be called by the IVibratorController after processing a - * 'requestVibrationParams()' call by the service. - * - * @param requestToken The token used for this request - * @param result The request result - */ - oneway void onRequestVibrationParamsComplete( - in IBinder requestToken, in VibrationParam[] result); -}
\ No newline at end of file diff --git a/vibrator/aidl/android/frameworks/vibrator/IVibratorController.aidl b/vibrator/aidl/android/frameworks/vibrator/IVibratorController.aidl deleted file mode 100644 index 7bcc7d2..0000000 --- a/vibrator/aidl/android/frameworks/vibrator/IVibratorController.aidl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ - -package android.frameworks.vibrator; - -import android.frameworks.vibrator.VibrationTypeMask; - -/** - * IVibratorController is an interface that allows clients to request the VibrationParams for the - * specified vibration types. If the request is longer than the specified deadline, the result will - * be ignored by the caller. - * @hide - */ -@VintfStability -interface IVibratorController { - /** - * Triggers a request to receive VibrationParams for the specified vibration types. The - * received params are used to modify vibration characteristics, such as scaling. - * <p> If the request takes longer than the specified deadline, the request must be ignored by - * the caller. - * - * @param type The type of vibration queried - * @param deadlineElapsedRealtimeMillis The request deadline, result ignored after this - * @param requestToken The token for the async result, used by the service - */ - oneway void requestVibrationParams(in VibrationTypeMask type, - in long deadlineElapsedRealtimeMillis, in IBinder requestToken); -}
\ No newline at end of file diff --git a/vibrator/aidl/android/frameworks/vibrator/ScaleParam.aidl b/vibrator/aidl/android/frameworks/vibrator/ScaleParam.aidl deleted file mode 100644 index 07228ff..0000000 --- a/vibrator/aidl/android/frameworks/vibrator/ScaleParam.aidl +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ - -package android.frameworks.vibrator; - -import android.frameworks.vibrator.VibrationTypeMask; - -/** - * Vibration scale for one or more vibration types - */ -@VintfStability -parcelable ScaleParam { - VibrationTypeMask types; // combined bitfield of VibrationTypeMask - float scale; -}
\ No newline at end of file diff --git a/vibrator/aidl/android/frameworks/vibrator/VibrationParam.aidl b/vibrator/aidl/android/frameworks/vibrator/VibrationParam.aidl deleted file mode 100644 index e9bde2a..0000000 --- a/vibrator/aidl/android/frameworks/vibrator/VibrationParam.aidl +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ - -package android.frameworks.vibrator; - -import android.frameworks.vibrator.ScaleParam; - -/** - * Consolidated representation of all vibration parameters - */ -@VintfStability -union VibrationParam { - ScaleParam scale; -}
\ No newline at end of file diff --git a/vibrator/aidl/android/frameworks/vibrator/VibrationTypeMask.aidl b/vibrator/aidl/android/frameworks/vibrator/VibrationTypeMask.aidl deleted file mode 100644 index 693acf5..0000000 --- a/vibrator/aidl/android/frameworks/vibrator/VibrationTypeMask.aidl +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ - -package android.frameworks.vibrator; - -@VintfStability -@Backing(type="int") -enum VibrationTypeMask { - ALARM = 1 << 0, // Alarm usage - NOTIFICATION = 1 << 1, // Notification and communication request usages - RINGTONE = 1 << 2, // Ringtone usage - INTERACTIVE = 1 << 3, // Touch and hardware feedback usages - MEDIA = 1 << 4 // Media and unknown usages -}
\ No newline at end of file diff --git a/vibrator/aidl/vts/functional/Android.bp b/vibrator/aidl/vts/functional/Android.bp deleted file mode 100644 index e95eb01..0000000 --- a/vibrator/aidl/vts/functional/Android.bp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ - -package { - default_applicable_licenses: ["Android-Apache-2.0"], -} - -cc_test { - name: "VtsHalVibratorControlServiceTargetTest", - defaults: [ - "VtsHalTargetTestDefaults", - "use_libaidlvintf_gtest_helper_static", - ], - tidy_timeout_srcs: [ - "VtsHalVibratorControlServiceTargetTest.cpp", - ], - srcs: [ - "VtsHalVibratorControlServiceTargetTest.cpp", - ], - static_libs: [ - "android.frameworks.vibrator-V1-ndk", - "libgmock", - ], - shared_libs: [ - "libbinder_ndk", - ], - test_suites: [ - "general-tests", - "vts", - ], -} diff --git a/vibrator/aidl/vts/functional/VtsHalVibratorControlServiceTargetTest.cpp b/vibrator/aidl/vts/functional/VtsHalVibratorControlServiceTargetTest.cpp deleted file mode 100644 index feb0554..0000000 --- a/vibrator/aidl/vts/functional/VtsHalVibratorControlServiceTargetTest.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2023 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 <aidl/Gtest.h> -#include <aidl/Vintf.h> -#include <aidl/android/frameworks/vibrator/BnVibratorControlService.h> -#include <aidl/android/frameworks/vibrator/BnVibratorController.h> -#include <aidl/android/frameworks/vibrator/IVibratorControlService.h> -#include <aidl/android/frameworks/vibrator/IVibratorController.h> -#include <aidl/android/frameworks/vibrator/ScaleParam.h> -#include <aidl/android/frameworks/vibrator/VibrationTypeMask.h> -#include <android-base/logging.h> -#include <android/binder_auto_utils.h> -#include <android/binder_manager.h> -#include <android/binder_process.h> -#include <utils/Condition.h> -#include <utils/Mutex.h> - -namespace android { - -using ::aidl::android::frameworks::vibrator::BnVibratorController; -using ::aidl::android::frameworks::vibrator::BnVibratorControlService; -using ::aidl::android::frameworks::vibrator::IVibratorController; -using ::aidl::android::frameworks::vibrator::IVibratorControlService; -using ::aidl::android::frameworks::vibrator::ScaleParam; -using ::aidl::android::frameworks::vibrator::VibrationParam; -using ::aidl::android::frameworks::vibrator::VibrationTypeMask; -using ::android::getAidlHalInstanceNames; -using ::android::PrintInstanceNameToString; -using ndk::SpAIBinder; -using ::testing::Eq; -using ::testing::InitGoogleTest; -using ::testing::TestWithParam; -using ::testing::ValuesIn; - -std::vector<VibrationParam> generateVibrationParams(VibrationTypeMask in_type, float scale) { - ScaleParam scaleParam = ScaleParam(); - scaleParam.types = in_type; - scaleParam.scale = scale; - VibrationParam vibrationParam = VibrationParam(scaleParam); - std::vector<VibrationParam> vibrationParams = {vibrationParam}; - return vibrationParams; -} - -class VibratorController : public BnVibratorController { - public: - ~VibratorController() override = default; - - ndk::ScopedAStatus requestVibrationParams(VibrationTypeMask in_type, - int64_t in_deadlineElapsedRealtimeMillis, - const ::ndk::SpAIBinder& in_requestToken) override { - if (in_requestToken == nullptr) { - LOG(INFO) << "Vibrator controller failed to process a request for vibration params"; - return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_ILLEGAL_ARGUMENT)); - } - - LOG(INFO) << "Vibrator controller received a request for vibration params for type: " - << toString(in_type) - << ", with a timeout of: " << in_deadlineElapsedRealtimeMillis; - - std::shared_ptr<IVibratorControlService> service = - IVibratorControlService::fromBinder(in_requestToken); - - EXPECT_TRUE(service - ->onRequestVibrationParamsComplete( - in_requestToken, generateVibrationParams(in_type, /* scale= */ 1)) - .isOk()); - - return ndk::ScopedAStatus::ok(); - } -}; - -class VibratorControlServiceTest : public ::testing::TestWithParam<std::string> { - public: - void SetUp() override { - SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str())); - service = IVibratorControlService::fromBinder(binder); - ASSERT_NE(service, nullptr); - } - - std::shared_ptr<IVibratorControlService> service; -}; - -TEST_P(VibratorControlServiceTest, RegisterVibrationControllerTest) { - std::shared_ptr<IVibratorController> vibratorController = - ::ndk::SharedRefBase::make<VibratorController>(); - - EXPECT_TRUE(service->registerVibratorController(vibratorController).isOk()); - - EXPECT_TRUE(service->unregisterVibratorController(vibratorController).isOk()); -} - -TEST_P(VibratorControlServiceTest, RequestVibrationParamsTest) { - std::shared_ptr<IVibratorController> vibratorController = - ::ndk::SharedRefBase::make<VibratorController>(); - - EXPECT_TRUE(service->registerVibratorController(vibratorController).isOk()); - - EXPECT_TRUE(vibratorController - ->requestVibrationParams(VibrationTypeMask::ALARM, - /* deadlineElapsedRealtimeMillis= */ 50, - service->asBinder()) - .isOk()); - EXPECT_TRUE(service->unregisterVibratorController(vibratorController).isOk()); -} - -TEST_P(VibratorControlServiceTest, SetAndClearVibrationParamsTest) { - std::shared_ptr<IVibratorController> vibratorController = - ::ndk::SharedRefBase::make<VibratorController>(); - - EXPECT_TRUE(service->registerVibratorController(vibratorController).isOk()); - - EXPECT_TRUE( - service - ->setVibrationParams(generateVibrationParams(VibrationTypeMask::ALARM, /* scale= */ 1), - vibratorController->getDefaultImpl()) - .isOk()); - - EXPECT_TRUE( - service - ->clearVibrationParams(VibrationTypeMask::ALARM, vibratorController->getDefaultImpl()) - .isOk()); - - EXPECT_TRUE(service->unregisterVibratorController(vibratorController).isOk()); -} - -GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VibratorControlServiceTest); - -INSTANTIATE_TEST_SUITE_P( - PerInstance, VibratorControlServiceTest, - testing::ValuesIn(getAidlHalInstanceNames(IVibratorControlService::descriptor)), - PrintInstanceNameToString); - -int main(int argc, char** argv) { - InitGoogleTest(&argc, argv); - ABinderProcess_setThreadPoolMaxThreadCount(/* numThreads= */ 1); - ABinderProcess_startThreadPool(); - return RUN_ALL_TESTS(); -} -} // namespace android |