Home | History | Annotate | Download | only in sensorhal
      1 /*
      2  * Copyright (C) 2015 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 #ifndef SENSORS_H_
     18 
     19 #define SENSORS_H_
     20 
     21 #include <hardware/hardware.h>
     22 #include <hardware/sensors.h>
     23 #include <media/stagefright/foundation/ABase.h>
     24 
     25 #include "hubconnection.h"
     26 
     27 struct SensorContext {
     28     struct sensors_poll_device_1 device;
     29 
     30     explicit SensorContext(const struct hw_module_t *module);
     31 
     32     bool getHubAlive();
     33 
     34 private:
     35     android::sp<android::HubConnection> mHubConnection;
     36     bool mHubAlive;
     37 
     38     int close();
     39     int activate(int handle, int enabled);
     40     int setDelay(int handle, int64_t delayNs);
     41     int poll(sensors_event_t *data, int count);
     42 
     43     int batch(int handle, int64_t sampling_period_ns,
     44               int64_t max_report_latency_ns);
     45 
     46     int flush(int handle);
     47 
     48     static int CloseWrapper(struct hw_device_t *dev);
     49 
     50     static int ActivateWrapper(
     51             struct sensors_poll_device_t *dev, int handle, int enabled);
     52 
     53     static int SetDelayWrapper(
     54             struct sensors_poll_device_t *dev, int handle, int64_t delayNs);
     55 
     56     static int PollWrapper(
     57             struct sensors_poll_device_t *dev, sensors_event_t *data, int count);
     58 
     59     static int BatchWrapper(
     60             struct sensors_poll_device_1 *dev,
     61             int handle,
     62             int flags,
     63             int64_t sampling_period_ns,
     64             int64_t max_report_latency_ns);
     65 
     66     static int FlushWrapper(struct sensors_poll_device_1 *dev, int handle);
     67 
     68     DISALLOW_EVIL_CONSTRUCTORS(SensorContext);
     69 };
     70 
     71 #endif  // SENSORS_H_
     72