Jaikumar Ganesh | 9a8df4d | 2013-02-12 16:31:32 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 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 |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 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. |
| 15 | */ |
| 16 | |
| 17 | package android.hardware; |
| 18 | |
| 19 | /** |
| 20 | * This class represents a Trigger Event - the event |
| 21 | * associated with a Trigger Sensor. When the sensor detects a trigger |
| 22 | * event condition, such as significant motion in the case of the |
| 23 | * {@link Sensor#TYPE_SIGNIFICANT_MOTION}, the {@link TriggerEventListener} |
| 24 | * is called with the TriggerEvent. The sensor is automatically canceled |
| 25 | * after the trigger. |
| 26 | * <p> |
| 27 | * This class holds information such as the value of the sensor |
| 28 | * when the trigger happened, the timestamp along with detailed |
| 29 | * information regarding the Sensor itself. |
| 30 | * </p> |
| 31 | * @see android.hardware.SensorManager |
| 32 | * @see android.hardware.TriggerEvent |
| 33 | * @see android.hardware.Sensor |
| 34 | */ |
| 35 | public final class TriggerEvent { |
| 36 | /** |
| 37 | * <p> |
| 38 | * The length and contents of the {@link #values values} array depends on |
| 39 | * which {@link android.hardware.Sensor sensor} type is being monitored (see |
| 40 | * also {@link SensorEvent} for a definition of the coordinate system used). |
| 41 | * </p> |
| 42 | * <h4> {@link Sensor#TYPE_SIGNIFICANT_MOTION} </h4> |
| 43 | * The value field is of length 1. value[0] = 1.0 when the sensor triggers. |
| 44 | * 1.0 is the only allowed value. |
| 45 | */ |
| 46 | public final float[] values; |
| 47 | |
| 48 | /** |
| 49 | * The sensor that generated this event. See |
| 50 | * {@link android.hardware.SensorManager SensorManager} for details. |
| 51 | */ |
| 52 | public Sensor sensor; |
| 53 | |
| 54 | /** |
| 55 | * The time in nanosecond at which the event happened |
| 56 | */ |
| 57 | public long timestamp; |
| 58 | |
| 59 | TriggerEvent(int size) { |
| 60 | values = new float[size]; |
| 61 | } |
| 62 | } |