1cfd74d65d832137e20e193c960802afba73b5d38sm/*
23c1e67e433728684b5f228c5d4f3e5b1457bb271sm * Copyright (C) 2010 The Android Open Source Project
3cfd74d65d832137e20e193c960802afba73b5d38sm *
4cfd74d65d832137e20e193c960802afba73b5d38sm * Licensed under the Apache License, Version 2.0 (the "License");
5cfd74d65d832137e20e193c960802afba73b5d38sm * you may not use this file except in compliance with the License.
6cfd74d65d832137e20e193c960802afba73b5d38sm * You may obtain a copy of the License at
7cfd74d65d832137e20e193c960802afba73b5d38sm *
8cfd74d65d832137e20e193c960802afba73b5d38sm *      http://www.apache.org/licenses/LICENSE-2.0
9cfd74d65d832137e20e193c960802afba73b5d38sm *
10cfd74d65d832137e20e193c960802afba73b5d38sm * Unless required by applicable law or agreed to in writing, software
11cfd74d65d832137e20e193c960802afba73b5d38sm * distributed under the License is distributed on an "AS IS" BASIS,
12cfd74d65d832137e20e193c960802afba73b5d38sm * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13cfd74d65d832137e20e193c960802afba73b5d38sm * See the License for the specific language governing permissions and
14cfd74d65d832137e20e193c960802afba73b5d38sm * limitations under the License.
15cfd74d65d832137e20e193c960802afba73b5d38sm */
16cfd74d65d832137e20e193c960802afba73b5d38smpackage com.replica.replicaisland;
17cfd74d65d832137e20e193c960802afba73b5d38sm
18cfd74d65d832137e20e193c960802afba73b5d38smimport android.os.Vibrator;
19cfd74d65d832137e20e193c960802afba73b5d38smimport android.content.Context;
20cfd74d65d832137e20e193c960802afba73b5d38sm
21cfd74d65d832137e20e193c960802afba73b5d38sm/** A system for accessing the Android vibrator.  Note that this system requires the app's
22cfd74d65d832137e20e193c960802afba73b5d38sm * AndroidManifest.xml to contain permissions for the Vibrator service.
23cfd74d65d832137e20e193c960802afba73b5d38sm */
24cfd74d65d832137e20e193c960802afba73b5d38smpublic class VibrationSystem extends BaseObject {
25cfd74d65d832137e20e193c960802afba73b5d38sm
26cfd74d65d832137e20e193c960802afba73b5d38sm    public VibrationSystem() {
27cfd74d65d832137e20e193c960802afba73b5d38sm        super();
28cfd74d65d832137e20e193c960802afba73b5d38sm    }
29cfd74d65d832137e20e193c960802afba73b5d38sm
30cfd74d65d832137e20e193c960802afba73b5d38sm    @Override
31cfd74d65d832137e20e193c960802afba73b5d38sm    public void reset() {
32cfd74d65d832137e20e193c960802afba73b5d38sm    }
33cfd74d65d832137e20e193c960802afba73b5d38sm
34cfd74d65d832137e20e193c960802afba73b5d38sm    public void vibrate(float seconds) {
35cfd74d65d832137e20e193c960802afba73b5d38sm        ContextParameters params = sSystemRegistry.contextParameters;
36cfd74d65d832137e20e193c960802afba73b5d38sm        if (params != null && params.context != null) {
37cfd74d65d832137e20e193c960802afba73b5d38sm            Vibrator vibrator = (Vibrator)params.context.getSystemService(Context.VIBRATOR_SERVICE);
38cfd74d65d832137e20e193c960802afba73b5d38sm            if (vibrator != null) {
39cfd74d65d832137e20e193c960802afba73b5d38sm                vibrator.vibrate((int)(seconds * 1000));
40cfd74d65d832137e20e193c960802afba73b5d38sm            }
41cfd74d65d832137e20e193c960802afba73b5d38sm        }
42cfd74d65d832137e20e193c960802afba73b5d38sm    }
43cfd74d65d832137e20e193c960802afba73b5d38sm}
44