2 * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "wrt/src/browser/vibration_manager.h"
19 #include "base/logging.h"
20 #include "tizen_src/chromium_impl/services/device/vibration/vibration_manager_impl_efl.h"
25 void VibrationManager::CreateInstance() {
26 static VibrationManager* vibration_provider_client = nullptr;
27 // vibration_provider_client is deleted by device::VibrationProviderClient
28 if (!vibration_provider_client)
29 vibration_provider_client = new VibrationManager;
32 VibrationManager::VibrationManager() : handle_(0) {
33 device::VibrationManagerImplEfl::RegisterProviderClient(this);
36 VibrationManager::~VibrationManager() {
37 LOG(INFO) << "~VibrationManager";
39 device_haptic_close(handle_);
42 bool VibrationManager::Initialize() {
46 int ret = device_haptic_open(0, &handle_);
47 if (ret != DEVICE_ERROR_NONE) {
48 LOG(ERROR) << "Fail to open haptic device";
52 LOG(INFO) << "Device Haptic open successful";
56 void VibrationManager::Vibrate(uint64_t ms) {
58 LOG(INFO) << "Device Vibration Start";
59 device_haptic_vibrate(handle_, ms, 100, nullptr);
63 void VibrationManager::CancelVibration() {
65 LOG(INFO) << "Device Vibration Stop";
66 device_haptic_stop(handle_, nullptr);