upload android base code part4
This commit is contained in:
parent
b9e30e05b1
commit
78ea2404cd
23455 changed files with 5250148 additions and 0 deletions
66
android/hardware/interfaces/vibrator/1.0/Android.bp
Normal file
66
android/hardware/interfaces/vibrator/1.0/Android.bp
Normal file
|
@ -0,0 +1,66 @@
|
|||
// This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
filegroup {
|
||||
name: "android.hardware.vibrator@1.0_hal",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IVibrator.hal",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.vibrator@1.0_genc++",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.vibrator@1.0",
|
||||
srcs: [
|
||||
":android.hardware.vibrator@1.0_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/vibrator/1.0/types.cpp",
|
||||
"android/hardware/vibrator/1.0/VibratorAll.cpp",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.vibrator@1.0_genc++_headers",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.vibrator@1.0",
|
||||
srcs: [
|
||||
":android.hardware.vibrator@1.0_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/vibrator/1.0/types.h",
|
||||
"android/hardware/vibrator/1.0/hwtypes.h",
|
||||
"android/hardware/vibrator/1.0/IVibrator.h",
|
||||
"android/hardware/vibrator/1.0/IHwVibrator.h",
|
||||
"android/hardware/vibrator/1.0/BnHwVibrator.h",
|
||||
"android/hardware/vibrator/1.0/BpHwVibrator.h",
|
||||
"android/hardware/vibrator/1.0/BsVibrator.h",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "android.hardware.vibrator@1.0",
|
||||
defaults: ["hidl-module-defaults"],
|
||||
generated_sources: ["android.hardware.vibrator@1.0_genc++"],
|
||||
generated_headers: ["android.hardware.vibrator@1.0_genc++_headers"],
|
||||
export_generated_headers: ["android.hardware.vibrator@1.0_genc++_headers"],
|
||||
vendor_available: true,
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
],
|
||||
export_shared_lib_headers: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"libutils",
|
||||
],
|
||||
}
|
228
android/hardware/interfaces/vibrator/1.0/Android.mk
Normal file
228
android/hardware/interfaces/vibrator/1.0/Android.mk
Normal file
|
@ -0,0 +1,228 @@
|
|||
# This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
################################################################################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vibrator-V1.0-java
|
||||
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
||||
|
||||
intermediates := $(call local-generated-sources-dir, COMMON)
|
||||
|
||||
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := \
|
||||
android.hidl.base-V1.0-java \
|
||||
|
||||
|
||||
#
|
||||
# Build types.hal (Effect)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_0/Effect.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.0::types.Effect
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (EffectStrength)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_0/EffectStrength.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.0::types.EffectStrength
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (Status)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_0/Status.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.0::types.Status
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build IVibrator.hal
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_0/IVibrator.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IVibrator.hal
|
||||
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.0::IVibrator
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/IVibrator.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
include $(BUILD_JAVA_LIBRARY)
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vibrator-V1.0-java-static
|
||||
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
||||
|
||||
intermediates := $(call local-generated-sources-dir, COMMON)
|
||||
|
||||
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
android.hidl.base-V1.0-java-static \
|
||||
|
||||
|
||||
#
|
||||
# Build types.hal (Effect)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_0/Effect.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.0::types.Effect
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (EffectStrength)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_0/EffectStrength.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.0::types.EffectStrength
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build types.hal (Status)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_0/Status.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.0::types.Status
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build IVibrator.hal
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_0/IVibrator.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IVibrator.hal
|
||||
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.0::IVibrator
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/IVibrator.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vibrator-V1.0-java-constants
|
||||
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
||||
|
||||
intermediates := $(call local-generated-sources-dir, COMMON)
|
||||
|
||||
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_0/Constants.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(GEN): $(LOCAL_PATH)/IVibrator.hal
|
||||
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava-constants \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.0
|
||||
|
||||
$(GEN):
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
# Avoid dependency cycle of framework.jar -> this-library -> framework.jar
|
||||
LOCAL_NO_STANDARD_LIBRARIES := true
|
||||
LOCAL_JAVA_LIBRARIES := core-oj
|
||||
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
|
||||
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
72
android/hardware/interfaces/vibrator/1.0/IVibrator.hal
Normal file
72
android/hardware/interfaces/vibrator/1.0/IVibrator.hal
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.hardware.vibrator@1.0;
|
||||
|
||||
interface IVibrator {
|
||||
/**
|
||||
* Turn on vibrator
|
||||
*
|
||||
* This function must only be called after the previous timeout has expired or
|
||||
* was canceled (through off()).
|
||||
* @param timeout_ms number of milliseconds to vibrate.
|
||||
* @return vibratorOnRet whether vibrator command was successful or not.
|
||||
*/
|
||||
on(uint32_t timeoutMs) generates (Status vibratorOnRet);
|
||||
|
||||
/**
|
||||
* Turn off vibrator
|
||||
*
|
||||
* Cancel a previously-started vibration, if any.
|
||||
* @return vibratorOffRet whether vibrator command was successful or not.
|
||||
*/
|
||||
off() generates (Status vibratorOffRet);
|
||||
|
||||
/**
|
||||
* Returns whether the vibrator supports changes to its vibrational amplitude.
|
||||
*/
|
||||
supportsAmplitudeControl() generates (bool supports);
|
||||
|
||||
/**
|
||||
* Sets the motor's vibrational amplitude.
|
||||
*
|
||||
* Changes the force being produced by the underlying motor.
|
||||
*
|
||||
* @param amplitude The unitless force setting. Note that this number must
|
||||
* be between 1 and 255, inclusive. If the motor does not
|
||||
* have exactly 255 steps, it must do it's best to map it
|
||||
* onto the number of steps it does have.
|
||||
* @return status Whether the command was successful or not. Must return
|
||||
* Status::UNSUPPORTED_OPERATION if setting the amplitude is
|
||||
* not supported by the device.
|
||||
*/
|
||||
setAmplitude(uint8_t amplitude) generates (Status status);
|
||||
|
||||
/**
|
||||
* Fire off a predefined haptic event.
|
||||
*
|
||||
* @param event The type of haptic event to trigger.
|
||||
* @return status Whether the effect was successfully performed or not. Must
|
||||
* return Status::UNSUPPORTED_OPERATION is the effect is not
|
||||
* supported.
|
||||
* @return lengthMs The length of time the event is expected to take in
|
||||
* milliseconds. This doesn't need to be perfectly accurate,
|
||||
* but should be a reasonable approximation. Should be a
|
||||
* positive, non-zero value if the returned status is
|
||||
* Status::OK, and set to 0 otherwise.
|
||||
*/
|
||||
perform(Effect effect, EffectStrength strength) generates (Status status, uint32_t lengthMs);
|
||||
};
|
30
android/hardware/interfaces/vibrator/1.0/default/Android.bp
Normal file
30
android/hardware/interfaces/vibrator/1.0/default/Android.bp
Normal file
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// Copyright (C) 2016 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.
|
||||
|
||||
cc_library_shared {
|
||||
name: "android.hardware.vibrator@1.0-impl",
|
||||
defaults: ["hidl_defaults"],
|
||||
proprietary: true,
|
||||
relative_install_path: "hw",
|
||||
srcs: ["Vibrator.cpp"],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libhardware",
|
||||
"android.hardware.vibrator@1.0",
|
||||
],
|
||||
}
|
35
android/hardware/interfaces/vibrator/1.0/default/Android.mk
Normal file
35
android/hardware/interfaces/vibrator/1.0/default/Android.mk
Normal file
|
@ -0,0 +1,35 @@
|
|||
#
|
||||
# Copyright (C) 2016 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.
|
||||
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vibrator@1.0-service
|
||||
LOCAL_INIT_RC := android.hardware.vibrator@1.0-service.rc
|
||||
LOCAL_PROPRIETARY_MODULE := true
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_SRC_FILES := \
|
||||
service.cpp \
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libhidlbase \
|
||||
libhidltransport \
|
||||
liblog \
|
||||
libutils \
|
||||
libhardware \
|
||||
android.hardware.vibrator@1.0
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "VibratorService"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <log/log.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/vibrator.h>
|
||||
|
||||
#include "Vibrator.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vibrator {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
Vibrator::Vibrator(vibrator_device_t *device) : mDevice(device) {}
|
||||
|
||||
// Methods from ::android::hardware::vibrator::V1_0::IVibrator follow.
|
||||
Return<Status> Vibrator::on(uint32_t timeout_ms) {
|
||||
int32_t ret = mDevice->vibrator_on(mDevice, timeout_ms);
|
||||
if (ret != 0) {
|
||||
ALOGE("on command failed : %s", strerror(-ret));
|
||||
return Status::UNKNOWN_ERROR;
|
||||
}
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
Return<Status> Vibrator::off() {
|
||||
int32_t ret = mDevice->vibrator_off(mDevice);
|
||||
if (ret != 0) {
|
||||
ALOGE("off command failed : %s", strerror(-ret));
|
||||
return Status::UNKNOWN_ERROR;
|
||||
}
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
Return<bool> Vibrator::supportsAmplitudeControl() {
|
||||
return false;
|
||||
}
|
||||
|
||||
Return<Status> Vibrator::setAmplitude(uint8_t) {
|
||||
return Status::UNSUPPORTED_OPERATION;
|
||||
}
|
||||
|
||||
Return<void> Vibrator::perform(Effect, EffectStrength, perform_cb _hidl_cb) {
|
||||
_hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
|
||||
return Void();
|
||||
}
|
||||
|
||||
IVibrator* HIDL_FETCH_IVibrator(const char * /*hal*/) {
|
||||
vibrator_device_t *vib_device;
|
||||
const hw_module_t *hw_module = nullptr;
|
||||
|
||||
int ret = hw_get_module(VIBRATOR_HARDWARE_MODULE_ID, &hw_module);
|
||||
if (ret == 0) {
|
||||
ret = vibrator_open(hw_module, &vib_device);
|
||||
if (ret != 0) {
|
||||
ALOGE("vibrator_open failed: %d", ret);
|
||||
}
|
||||
} else {
|
||||
ALOGE("hw_get_module %s failed: %d", VIBRATOR_HARDWARE_MODULE_ID, ret);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
return new Vibrator(vib_device);
|
||||
} else {
|
||||
ALOGE("Passthrough failed to open legacy HAL.");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
51
android/hardware/interfaces/vibrator/1.0/default/Vibrator.h
Normal file
51
android/hardware/interfaces/vibrator/1.0/default/Vibrator.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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 ANDROID_HARDWARE_VIBRATOR_V1_0_VIBRATOR_H
|
||||
#define ANDROID_HARDWARE_VIBRATOR_V1_0_VIBRATOR_H
|
||||
|
||||
#include <android/hardware/vibrator/1.0/IVibrator.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include <hidl/MQDescriptor.h>
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vibrator {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
struct Vibrator : public IVibrator {
|
||||
Vibrator(vibrator_device_t *device);
|
||||
|
||||
// Methods from ::android::hardware::vibrator::V1_0::IVibrator follow.
|
||||
Return<Status> on(uint32_t timeoutMs) override;
|
||||
Return<Status> off() override;
|
||||
Return<bool> supportsAmplitudeControl() override;
|
||||
Return<Status> setAmplitude(uint8_t amplitude) override;
|
||||
Return<void> perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override;
|
||||
|
||||
private:
|
||||
vibrator_device_t *mDevice;
|
||||
};
|
||||
|
||||
extern "C" IVibrator* HIDL_FETCH_IVibrator(const char* name);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_VIBRATOR_V1_0_VIBRATOR_H
|
|
@ -0,0 +1,4 @@
|
|||
service vibrator-1-0 /vendor/bin/hw/android.hardware.vibrator@1.0-service
|
||||
class hal
|
||||
user system
|
||||
group system
|
26
android/hardware/interfaces/vibrator/1.0/default/service.cpp
Normal file
26
android/hardware/interfaces/vibrator/1.0/default/service.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
#define LOG_TAG "android.hardware.vibrator@1.0-service"
|
||||
|
||||
#include <android/hardware/vibrator/1.0/IVibrator.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
using android::hardware::vibrator::V1_0::IVibrator;
|
||||
using android::hardware::defaultPassthroughServiceImplementation;
|
||||
|
||||
int main() {
|
||||
return defaultPassthroughServiceImplementation<IVibrator>();
|
||||
}
|
48
android/hardware/interfaces/vibrator/1.0/types.hal
Normal file
48
android/hardware/interfaces/vibrator/1.0/types.hal
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.hardware.vibrator@1.0;
|
||||
|
||||
enum Status : uint32_t {
|
||||
OK,
|
||||
UNKNOWN_ERROR,
|
||||
BAD_VALUE,
|
||||
UNSUPPORTED_OPERATION
|
||||
};
|
||||
|
||||
@export
|
||||
enum Effect : uint32_t {
|
||||
/**
|
||||
* A single click effect.
|
||||
*
|
||||
* This effect should produce a sharp, crisp click sensation.
|
||||
*/
|
||||
CLICK,
|
||||
/**
|
||||
* A double click effect.
|
||||
*
|
||||
* This effect should produce two sequential sharp, crisp click sensations with a minimal
|
||||
* amount of time between them.
|
||||
*/
|
||||
DOUBLE_CLICK
|
||||
};
|
||||
|
||||
@export
|
||||
enum EffectStrength : uint8_t {
|
||||
LIGHT,
|
||||
MEDIUM,
|
||||
STRONG
|
||||
};
|
19
android/hardware/interfaces/vibrator/1.0/vts/Android.mk
Normal file
19
android/hardware/interfaces/vibrator/1.0/vts/Android.mk
Normal file
|
@ -0,0 +1,19 @@
|
|||
#
|
||||
# Copyright (C) 2016 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.
|
||||
#
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(call all-subdir-makefiles)
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Copyright (C) 2016 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.
|
||||
//
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalVibratorV1_0TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: ["VtsHalVibratorV1_0TargetTest.cpp"],
|
||||
static_libs: ["android.hardware.vibrator@1.0"],
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "vibrator_hidl_hal_test"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/vibrator/1.0/IVibrator.h>
|
||||
#include <android/hardware/vibrator/1.0/types.h>
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using ::android::hardware::vibrator::V1_0::Effect;
|
||||
using ::android::hardware::vibrator::V1_0::EffectStrength;
|
||||
using ::android::hardware::vibrator::V1_0::IVibrator;
|
||||
using ::android::hardware::vibrator::V1_0::Status;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::sp;
|
||||
|
||||
// The main test class for VIBRATOR HIDL HAL.
|
||||
class VibratorHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>();
|
||||
ASSERT_NE(vibrator, nullptr);
|
||||
}
|
||||
|
||||
virtual void TearDown() override {}
|
||||
|
||||
sp<IVibrator> vibrator;
|
||||
};
|
||||
|
||||
// A class for test environment setup (kept since this file is a template).
|
||||
class VibratorHidlEnvironment : public ::testing::Environment {
|
||||
public:
|
||||
virtual void SetUp() {}
|
||||
virtual void TearDown() {}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
static void validatePerformEffect(Status status, uint32_t lengthMs) {
|
||||
ASSERT_TRUE(status == Status::OK || status == Status::UNSUPPORTED_OPERATION);
|
||||
if (status == Status::OK) {
|
||||
ASSERT_GT(lengthMs, static_cast<uint32_t>(0));
|
||||
} else {
|
||||
ASSERT_EQ(lengthMs, static_cast<uint32_t>(0));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(VibratorHidlTest, OnThenOffBeforeTimeout) {
|
||||
EXPECT_EQ(Status::OK, vibrator->on(2000));
|
||||
sleep(1);
|
||||
EXPECT_EQ(Status::OK, vibrator->off());
|
||||
}
|
||||
|
||||
TEST_F(VibratorHidlTest, PerformEffect) {
|
||||
vibrator->perform(Effect::CLICK, EffectStrength::MEDIUM, validatePerformEffect);
|
||||
vibrator->perform(Effect::DOUBLE_CLICK, EffectStrength::LIGHT, validatePerformEffect);
|
||||
}
|
||||
|
||||
TEST_F(VibratorHidlTest, ChangeVibrationalAmplitude) {
|
||||
if (vibrator->supportsAmplitudeControl()) {
|
||||
EXPECT_EQ(Status::OK, vibrator->setAmplitude(1));
|
||||
EXPECT_EQ(Status::OK, vibrator->on(2000));
|
||||
EXPECT_EQ(Status::OK, vibrator->setAmplitude(128));
|
||||
sleep(1);
|
||||
EXPECT_EQ(Status::OK, vibrator->setAmplitude(255));
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(VibratorHidlTest, AmplitudeOutsideRangeFails) {
|
||||
if (vibrator->supportsAmplitudeControl()) {
|
||||
EXPECT_EQ(Status::BAD_VALUE, vibrator->setAmplitude(0));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(VibratorHidlTest, SetAmplitudeReturnUnsupportedOperationIfNotSupported) {
|
||||
if (!vibrator->supportsAmplitudeControl()) {
|
||||
EXPECT_EQ(Status::UNSUPPORTED_OPERATION, vibrator->setAmplitude(1));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::testing::AddGlobalTestEnvironment(new VibratorHidlEnvironment);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
LOG(INFO) << "Test result = " << status;
|
||||
return status;
|
||||
}
|
68
android/hardware/interfaces/vibrator/1.1/Android.bp
Normal file
68
android/hardware/interfaces/vibrator/1.1/Android.bp
Normal file
|
@ -0,0 +1,68 @@
|
|||
// This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
filegroup {
|
||||
name: "android.hardware.vibrator@1.1_hal",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IVibrator.hal",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.vibrator@1.1_genc++",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.vibrator@1.1",
|
||||
srcs: [
|
||||
":android.hardware.vibrator@1.1_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/vibrator/1.1/types.cpp",
|
||||
"android/hardware/vibrator/1.1/VibratorAll.cpp",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.vibrator@1.1_genc++_headers",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.vibrator@1.1",
|
||||
srcs: [
|
||||
":android.hardware.vibrator@1.1_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/vibrator/1.1/types.h",
|
||||
"android/hardware/vibrator/1.1/hwtypes.h",
|
||||
"android/hardware/vibrator/1.1/IVibrator.h",
|
||||
"android/hardware/vibrator/1.1/IHwVibrator.h",
|
||||
"android/hardware/vibrator/1.1/BnHwVibrator.h",
|
||||
"android/hardware/vibrator/1.1/BpHwVibrator.h",
|
||||
"android/hardware/vibrator/1.1/BsVibrator.h",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "android.hardware.vibrator@1.1",
|
||||
defaults: ["hidl-module-defaults"],
|
||||
generated_sources: ["android.hardware.vibrator@1.1_genc++"],
|
||||
generated_headers: ["android.hardware.vibrator@1.1_genc++_headers"],
|
||||
export_generated_headers: ["android.hardware.vibrator@1.1_genc++_headers"],
|
||||
vendor_available: true,
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
"android.hardware.vibrator@1.0",
|
||||
],
|
||||
export_shared_lib_headers: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"libutils",
|
||||
"android.hardware.vibrator@1.0",
|
||||
],
|
||||
}
|
154
android/hardware/interfaces/vibrator/1.1/Android.mk
Normal file
154
android/hardware/interfaces/vibrator/1.1/Android.mk
Normal file
|
@ -0,0 +1,154 @@
|
|||
# This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
################################################################################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vibrator-V1.1-java
|
||||
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
||||
|
||||
intermediates := $(call local-generated-sources-dir, COMMON)
|
||||
|
||||
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := \
|
||||
android.hardware.vibrator-V1.0-java \
|
||||
android.hidl.base-V1.0-java \
|
||||
|
||||
|
||||
#
|
||||
# Build types.hal (Effect_1_1)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_1/Effect_1_1.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.1::types.Effect_1_1
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build IVibrator.hal
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_1/IVibrator.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IVibrator.hal
|
||||
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.1::IVibrator
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/IVibrator.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
include $(BUILD_JAVA_LIBRARY)
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vibrator-V1.1-java-static
|
||||
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
||||
|
||||
intermediates := $(call local-generated-sources-dir, COMMON)
|
||||
|
||||
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
android.hardware.vibrator-V1.0-java-static \
|
||||
android.hidl.base-V1.0-java-static \
|
||||
|
||||
|
||||
#
|
||||
# Build types.hal (Effect_1_1)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_1/Effect_1_1.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.1::types.Effect_1_1
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
|
||||
#
|
||||
# Build IVibrator.hal
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_1/IVibrator.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IVibrator.hal
|
||||
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.1::IVibrator
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/IVibrator.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vibrator-V1.1-java-constants
|
||||
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
||||
|
||||
intermediates := $(call local-generated-sources-dir, COMMON)
|
||||
|
||||
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vibrator/V1_1/Constants.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): $(LOCAL_PATH)/types.hal
|
||||
$(GEN): $(LOCAL_PATH)/IVibrator.hal
|
||||
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava-constants \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vibrator@1.1
|
||||
|
||||
$(GEN):
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
# Avoid dependency cycle of framework.jar -> this-library -> framework.jar
|
||||
LOCAL_NO_STANDARD_LIBRARIES := true
|
||||
LOCAL_JAVA_LIBRARIES := core-oj
|
||||
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
|
||||
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
39
android/hardware/interfaces/vibrator/1.1/IVibrator.hal
Normal file
39
android/hardware/interfaces/vibrator/1.1/IVibrator.hal
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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.hardware.vibrator@1.1;
|
||||
|
||||
import @1.0::EffectStrength;
|
||||
import @1.0::IVibrator;
|
||||
import @1.0::Status;
|
||||
|
||||
interface IVibrator extends @1.0::IVibrator {
|
||||
/**
|
||||
* Fire off a predefined haptic event.
|
||||
*
|
||||
* @param event The type of haptic event to trigger.
|
||||
* @return status Whether the effect was successfully performed or not. Must
|
||||
* return Status::UNSUPPORTED_OPERATION is the effect is not
|
||||
* supported.
|
||||
* @return lengthMs The length of time the event is expected to take in
|
||||
* milliseconds. This doesn't need to be perfectly accurate,
|
||||
* but should be a reasonable approximation. Should be a
|
||||
* positive, non-zero value if the returned status is
|
||||
* Status::OK, and set to 0 otherwise.
|
||||
*/
|
||||
perform_1_1(Effect_1_1 effect, EffectStrength strength)
|
||||
generates (Status status, uint32_t lengthMs);
|
||||
};
|
29
android/hardware/interfaces/vibrator/1.1/types.hal
Normal file
29
android/hardware/interfaces/vibrator/1.1/types.hal
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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.hardware.vibrator@1.1;
|
||||
|
||||
import @1.0::Effect;
|
||||
|
||||
@export
|
||||
enum Effect_1_1 : @1.0::Effect {
|
||||
/**
|
||||
* A tick effect.
|
||||
*
|
||||
* This effect should produce a soft, short sensation, like the tick of a clock.
|
||||
*/
|
||||
TICK
|
||||
};
|
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// Copyright (C) 2017 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.
|
||||
//
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalVibratorV1_1TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: ["VtsHalVibratorV1_1TargetTest.cpp"],
|
||||
static_libs: [
|
||||
"android.hardware.vibrator@1.0",
|
||||
"android.hardware.vibrator@1.1",
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "vibrator_hidl_hal_test"
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/vibrator/1.1/IVibrator.h>
|
||||
#include <android/hardware/vibrator/1.1/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using ::android::hardware::vibrator::V1_0::Effect;
|
||||
using ::android::hardware::vibrator::V1_0::EffectStrength;
|
||||
using ::android::hardware::vibrator::V1_0::Status;
|
||||
using ::android::hardware::vibrator::V1_1::Effect_1_1;
|
||||
using ::android::hardware::vibrator::V1_1::IVibrator;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::sp;
|
||||
|
||||
// The main test class for VIBRATOR HIDL HAL 1.1.
|
||||
class VibratorHidlTest_1_1 : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>();
|
||||
ASSERT_NE(vibrator, nullptr);
|
||||
}
|
||||
|
||||
virtual void TearDown() override {}
|
||||
|
||||
sp<IVibrator> vibrator;
|
||||
};
|
||||
|
||||
static void validatePerformEffect(Status status, uint32_t lengthMs) {
|
||||
ASSERT_TRUE(status == Status::OK || status == Status::UNSUPPORTED_OPERATION);
|
||||
if (status == Status::OK) {
|
||||
ASSERT_GT(lengthMs, static_cast<uint32_t>(0))
|
||||
<< "Effects that return OK must return a non-zero duration";
|
||||
} else {
|
||||
ASSERT_EQ(lengthMs, static_cast<uint32_t>(0))
|
||||
<< "Effects that return UNSUPPORTED_OPERATION must have a duration of zero";
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(VibratorHidlTest_1_1, PerformEffect_1_1) {
|
||||
vibrator->perform_1_1(Effect_1_1::CLICK, EffectStrength::MEDIUM, validatePerformEffect);
|
||||
vibrator->perform_1_1(Effect_1_1::TICK, EffectStrength::STRONG, validatePerformEffect);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
LOG(INFO) << "Test result = " << status;
|
||||
return status;
|
||||
}
|
8
android/hardware/interfaces/vibrator/Android.bp
Normal file
8
android/hardware/interfaces/vibrator/Android.bp
Normal file
|
@ -0,0 +1,8 @@
|
|||
// This is an autogenerated file, do not edit.
|
||||
subdirs = [
|
||||
"1.0",
|
||||
"1.0/default",
|
||||
"1.0/vts/functional",
|
||||
"1.1",
|
||||
"1.1/vts/functional",
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue