2 * Copyright (c) 2015 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 var JSON_ = xwalk.JSON;
18 var validator_ = xwalk.utils.validator;
19 var types_ = validator_.Types;
20 var type_ = xwalk.utils.type;
21 var native_ = new xwalk.utils.NativeManager(extension);
24 TYPE_SOUND: 'TYPE_SOUND',
25 TYPE_VIBRATION: 'TYPE_VIBRATION'
28 var FeedbackPattern = {
42 KEY_SHARP: 'KEY_SHARP',
55 CHARGERCONN: 'CHARGERCONN',
56 CHARGING_ERROR: 'CHARGING_ERROR',
57 FULLCHARGED: 'FULLCHARGED',
61 VIBRATION_ON: 'VIBRATION_ON',
62 SILENT_OFF: 'SILENT_OFF',
63 BT_CONNECTED: 'BT_CONNECTED',
64 BT_DISCONNECTED: 'BT_DISCONNECTED',
65 LIST_REORDER: 'LIST_REORDER',
66 LIST_SLIDER: 'LIST_SLIDER',
67 VOLUME_KEY: 'VOLUME_KEY'
70 function FeedbackManager() {
71 // constructor of FeedbackManager
75 FeedbackManager.prototype.isPatternSupported = function(pattern, type) {
76 var args = validator_.validateArgs(arguments, [
77 {name: 'pattern', type: types_.ENUM, values: Object.keys(FeedbackPattern)},
78 {name: 'type', type: types_.ENUM, values: Object.keys(FeedbackType)},
81 var result = native_.callSync('FeedbackManager_isPatternSupported', args);
82 if (native_.isFailure(result)) {
83 throw native_.getErrorObject(result);
85 return native_.getResultObject(result);
88 FeedbackManager.prototype.play = function(pattern, type) {
89 var args = validator_.validateArgs(arguments, [
93 values: Object.keys(FeedbackPattern)
98 values: Object.keys(FeedbackType),
105 'pattern': args.pattern,
106 'type': args.type ? args.type : 'any'
109 var result = native_.callSync('FeedbackManager_play', nativeParam);
110 if (native_.isFailure(result)) {
111 throw native_.getErrorObject(result);
115 FeedbackManager.prototype.stop = function() {
116 var args = validator_.validateArgs(arguments, []);
118 var result = native_.callSync('FeedbackManager_stop', args);
119 if (native_.isFailure(result)) {
120 throw native_.getErrorObject(result);
124 exports = new FeedbackManager();