1 /*
2  * Copyright (C) 2010 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 #pragma once
18 
19 #include <stdint.h>
20 #include <sys/types.h>
21 
22 #include <utils/Errors.h>
23 #include <utils/StrongPointer.h>
24 #include <utils/Vector.h>
25 
26 #include <binder/IInterface.h>
27 
28 struct native_handle;
29 typedef struct native_handle native_handle_t;
30 namespace android {
31 // ----------------------------------------------------------------------------
32 
33 class ISensorEventConnection;
34 class Parcel;
35 class Sensor;
36 class String8;
37 class String16;
38 
39 class ISensorServer : public IInterface
40 {
41 public:
42     DECLARE_META_INTERFACE(SensorServer)
43 
44     virtual Vector<Sensor> getSensorList(const String16& opPackageName) = 0;
45     virtual Vector<Sensor> getDynamicSensorList(const String16& opPackageName) = 0;
46     virtual Vector<Sensor> getRuntimeSensorList(const String16& opPackageName, int deviceId) = 0;
47 
48     virtual sp<ISensorEventConnection> createSensorEventConnection(const String8& packageName,
49              int mode, const String16& opPackageName, const String16& attributionTag) = 0;
50     virtual int32_t isDataInjectionEnabled() = 0;
51     virtual int32_t isReplayDataInjectionEnabled() = 0;
52     virtual int32_t isHalBypassReplayDataInjectionEnabled() = 0;
53 
54     virtual sp<ISensorEventConnection> createSensorDirectConnection(const String16& opPackageName,
55             int deviceId, uint32_t size, int32_t type, int32_t format,
56             const native_handle_t *resource) = 0;
57 
58     virtual int setOperationParameter(
59             int32_t handle, int32_t type, const Vector<float> &floats, const Vector<int32_t> &ints) = 0;
60 };
61 
62 // ----------------------------------------------------------------------------
63 
64 class BnSensorServer : public BnInterface<ISensorServer>
65 {
66 public:
67     virtual status_t shellCommand(int in, int out, int err,
68                                   Vector<String16>& args) = 0;
69 
70     virtual status_t    onTransact( uint32_t code,
71                                     const Parcel& data,
72                                     Parcel* reply,
73                                     uint32_t flags = 0);
74 };
75 
76 // ----------------------------------------------------------------------------
77 }; // namespace android
78