blob: f8ee3fc607d88690db52d74debef268108868ef7 [file] [log] [blame]
Mathias Agopian589ce852010-07-13 22:21:56 -07001/*
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
Mathias Agopiana7352c92010-07-14 23:41:37 -070017#define LOG_TAG "Sensors"
18
Mathias Agopian801ea092017-03-06 15:05:04 -080019#include <sensor/SensorManager.h>
20
Mathias Agopian589ce852010-07-13 22:21:56 -070021#include <stdint.h>
22#include <sys/types.h>
23
Peng Xue36e3472016-11-03 11:57:10 -070024#include <cutils/native_handle.h>
Mathias Agopian589ce852010-07-13 22:21:56 -070025#include <utils/Errors.h>
26#include <utils/RefBase.h>
27#include <utils/Singleton.h>
28
Vladimir Komsiyskif1d48af2023-10-06 10:11:44 +020029#include <android/companion/virtualnative/IVirtualDeviceManagerNative.h>
30
Mathias Agopian1a2b83a2011-10-16 22:15:23 -070031#include <binder/IBinder.h>
Jiyong Park47f876b2018-04-17 13:56:46 +090032#include <binder/IPermissionController.h>
Mathias Agopiana7352c92010-07-14 23:41:37 -070033#include <binder/IServiceManager.h>
34
Mathias Agopian801ea092017-03-06 15:05:04 -080035#include <sensor/ISensorServer.h>
36#include <sensor/ISensorEventConnection.h>
37#include <sensor/Sensor.h>
38#include <sensor/SensorEventQueue.h>
Mathias Agopian589ce852010-07-13 22:21:56 -070039
40// ----------------------------------------------------------------------------
41namespace android {
42// ----------------------------------------------------------------------------
43
Vladimir Komsiyskif1d48af2023-10-06 10:11:44 +020044namespace {
45
46using ::android::companion::virtualnative::IVirtualDeviceManagerNative;
47
48static constexpr int DEVICE_ID_DEFAULT = 0;
49
50// Returns the deviceId of the device where this uid is observed. If the uid is present on more than
51// one devices, return the default deviceId.
52int getDeviceIdForUid(uid_t uid) {
53 sp<IBinder> binder =
54 defaultServiceManager()->checkService(String16("virtualdevice_native"));
55 if (binder != nullptr) {
56 auto vdm = interface_cast<IVirtualDeviceManagerNative>(binder);
57 std::vector<int> deviceIds;
58 vdm->getDeviceIdsForUid(uid, &deviceIds);
59 // If the UID is associated with multiple virtual devices, use the default device's
60 // sensors as we cannot disambiguate here. This effectively means that the app has
61 // activities on different devices at the same time, so it must handle the device
62 // awareness by itself.
63 if (deviceIds.size() == 1) {
64 const int deviceId = deviceIds.at(0);
65 int devicePolicy = IVirtualDeviceManagerNative::DEVICE_POLICY_DEFAULT;
66 vdm->getDevicePolicy(deviceId,
67 IVirtualDeviceManagerNative::POLICY_TYPE_SENSORS,
68 &devicePolicy);
69 if (devicePolicy == IVirtualDeviceManagerNative::DEVICE_POLICY_CUSTOM) {
70 return deviceId;
71 }
72 }
73 } else {
74 ALOGW("Cannot get virtualdevice_native service");
75 }
76 return DEVICE_ID_DEFAULT;
77}
78
79} // namespace
80
Peng Xufe5476a2017-03-17 17:27:42 -070081Mutex SensorManager::sLock;
82std::map<String16, SensorManager*> SensorManager::sPackageInstances;
Aravind Akellae2806cb2015-07-29 18:03:48 -070083
84SensorManager& SensorManager::getInstanceForPackage(const String16& packageName) {
Peng Xufe5476a2017-03-17 17:27:42 -070085 waitForSensorService(nullptr);
86
Aravind Akellae2806cb2015-07-29 18:03:48 -070087 Mutex::Autolock _l(sLock);
88 SensorManager* sensorManager;
Peng Xufe5476a2017-03-17 17:27:42 -070089 auto iterator = sPackageInstances.find(packageName);
Aravind Akellae2806cb2015-07-29 18:03:48 -070090
91 if (iterator != sPackageInstances.end()) {
92 sensorManager = iterator->second;
93 } else {
94 String16 opPackageName = packageName;
Vladimir Komsiyskif1d48af2023-10-06 10:11:44 +020095 const uid_t uid = IPCThreadState::self()->getCallingUid();
Aravind Akellae2806cb2015-07-29 18:03:48 -070096
97 // It is possible that the calling code has no access to the package name.
98 // In this case we will get the packages for the calling UID and pick the
99 // first one for attributing the app op. This will work correctly for
100 // runtime permissions as for legacy apps we will toggle the app op for
101 // all packages in the UID. The caveat is that the operation may be attributed
102 // to the wrong package and stats based on app ops may be slightly off.
103 if (opPackageName.size() <= 0) {
104 sp<IBinder> binder = defaultServiceManager()->getService(String16("permission"));
Yi Kongd5e079f2018-07-17 16:08:27 -0700105 if (binder != nullptr) {
Aravind Akellae2806cb2015-07-29 18:03:48 -0700106 Vector<String16> packages;
107 interface_cast<IPermissionController>(binder)->getPackagesForUid(uid, packages);
108 if (!packages.isEmpty()) {
109 opPackageName = packages[0];
110 } else {
111 ALOGE("No packages for calling UID");
112 }
113 } else {
114 ALOGE("Cannot get permission service");
115 }
116 }
117
Vladimir Komsiyskif1d48af2023-10-06 10:11:44 +0200118 // Check if the calling UID is observed on a virtual device. If so, provide that device's
119 // sensors by default instead of the default device's sensors.
120 const int deviceId = getDeviceIdForUid(uid);
121 sensorManager = new SensorManager(opPackageName, deviceId);
Aravind Akellae2806cb2015-07-29 18:03:48 -0700122
123 // If we had no package name, we looked it up from the UID and the sensor
124 // manager instance we created should also be mapped to the empty package
125 // name, to avoid looking up the packages for a UID and get the same result.
126 if (packageName.size() <= 0) {
127 sPackageInstances.insert(std::make_pair(String16(), sensorManager));
128 }
129
130 // Stash the per package sensor manager.
131 sPackageInstances.insert(std::make_pair(opPackageName, sensorManager));
132 }
133
134 return *sensorManager;
135}
136
Anthony Stange9352ab12023-02-21 17:57:38 +0000137void SensorManager::removeInstanceForPackage(const String16& packageName) {
138 Mutex::Autolock _l(sLock);
139 auto iterator = sPackageInstances.find(packageName);
140 if (iterator != sPackageInstances.end()) {
141 SensorManager* sensorManager = iterator->second;
142 delete sensorManager;
143 sPackageInstances.erase(iterator);
144 }
145}
146
Vladimir Komsiyskif1d48af2023-10-06 10:11:44 +0200147SensorManager::SensorManager(const String16& opPackageName, int deviceId)
148 : mSensorList(nullptr), mOpPackageName(opPackageName), mDeviceId(deviceId),
149 mDirectConnectionHandle(1) {
Brian Duddie8bbd6f42019-06-06 16:43:41 -0700150 Mutex::Autolock _l(mLock);
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700151 assertStateLocked();
Mathias Agopian589ce852010-07-13 22:21:56 -0700152}
153
Peng Xu2576cb62016-01-20 00:22:09 -0800154SensorManager::~SensorManager() {
Mathias Agopiana7352c92010-07-14 23:41:37 -0700155 free(mSensorList);
Erik Staatsd35a5742022-02-04 06:37:58 -0800156 free(mDynamicSensorList);
Mathias Agopian589ce852010-07-13 22:21:56 -0700157}
158
Peng Xufe5476a2017-03-17 17:27:42 -0700159status_t SensorManager::waitForSensorService(sp<ISensorServer> *server) {
160 // try for 300 seconds (60*5(getService() tries for 5 seconds)) before giving up ...
161 sp<ISensorServer> s;
162 const String16 name("sensorservice");
163 for (int i = 0; i < 60; i++) {
164 status_t err = getService(name, &s);
165 switch (err) {
166 case NAME_NOT_FOUND:
167 sleep(1);
168 continue;
169 case NO_ERROR:
170 if (server != nullptr) {
171 *server = s;
172 }
173 return NO_ERROR;
174 default:
175 return err;
176 }
177 }
178 return TIMED_OUT;
179}
180
Peng Xu2576cb62016-01-20 00:22:09 -0800181void SensorManager::sensorManagerDied() {
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700182 Mutex::Autolock _l(mLock);
183 mSensorServer.clear();
184 free(mSensorList);
Yi Kongd5e079f2018-07-17 16:08:27 -0700185 mSensorList = nullptr;
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700186 mSensors.clear();
Erik Staatsd35a5742022-02-04 06:37:58 -0800187 free(mDynamicSensorList);
188 mDynamicSensorList = nullptr;
189 mDynamicSensors.clear();
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700190}
191
Peng Xu2576cb62016-01-20 00:22:09 -0800192status_t SensorManager::assertStateLocked() {
Aravind Akella8f35ca92015-08-17 15:22:12 -0700193 bool initSensorManager = false;
Yi Kongd5e079f2018-07-17 16:08:27 -0700194 if (mSensorServer == nullptr) {
Aravind Akella8f35ca92015-08-17 15:22:12 -0700195 initSensorManager = true;
196 } else {
197 // Ping binder to check if sensorservice is alive.
198 status_t err = IInterface::asBinder(mSensorServer)->pingBinder();
199 if (err != NO_ERROR) {
200 initSensorManager = true;
201 }
202 }
203 if (initSensorManager) {
Peng Xufe5476a2017-03-17 17:27:42 -0700204 waitForSensorService(&mSensorServer);
205 LOG_ALWAYS_FATAL_IF(mSensorServer == nullptr, "getService(SensorService) NULL");
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700206
207 class DeathObserver : public IBinder::DeathRecipient {
Peng Xu2576cb62016-01-20 00:22:09 -0800208 SensorManager& mSensorManager;
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700209 virtual void binderDied(const wp<IBinder>& who) {
Yi Kong82d7c632019-09-20 12:10:47 -0700210 ALOGW("sensorservice died [%p]", static_cast<void*>(who.unsafe_get()));
Peng Xu2576cb62016-01-20 00:22:09 -0800211 mSensorManager.sensorManagerDied();
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700212 }
213 public:
Chih-Hung Hsieh68a593e2016-04-28 09:14:32 -0700214 explicit DeathObserver(SensorManager& mgr) : mSensorManager(mgr) { }
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700215 };
216
217 mDeathObserver = new DeathObserver(*const_cast<SensorManager *>(this));
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800218 IInterface::asBinder(mSensorServer)->linkToDeath(mDeathObserver);
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700219
Vladimir Komsiyskif1d48af2023-10-06 10:11:44 +0200220 if (mDeviceId == DEVICE_ID_DEFAULT) {
221 mSensors = mSensorServer->getSensorList(mOpPackageName);
222 } else {
223 mSensors = mSensorServer->getRuntimeSensorList(mOpPackageName, mDeviceId);
224 }
225
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700226 size_t count = mSensors.size();
Devin Moore49600b12023-04-25 00:17:13 +0000227 // If count is 0, mSensorList will be non-null. This is old
228 // existing behavior and callers expect this.
Dan Stozad723bd72014-11-18 10:24:03 -0800229 mSensorList =
230 static_cast<Sensor const**>(malloc(count * sizeof(Sensor*)));
Yi Kongd5e079f2018-07-17 16:08:27 -0700231 LOG_ALWAYS_FATAL_IF(mSensorList == nullptr, "mSensorList NULL");
Aravind Akella8f35ca92015-08-17 15:22:12 -0700232
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700233 for (size_t i=0 ; i<count ; i++) {
234 mSensorList[i] = mSensors.array() + i;
235 }
236 }
237
238 return NO_ERROR;
239}
240
Peng Xu2576cb62016-01-20 00:22:09 -0800241ssize_t SensorManager::getSensorList(Sensor const* const** list) {
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700242 Mutex::Autolock _l(mLock);
243 status_t err = assertStateLocked();
244 if (err < 0) {
Dan Stozad723bd72014-11-18 10:24:03 -0800245 return static_cast<ssize_t>(err);
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700246 }
Mathias Agopian589ce852010-07-13 22:21:56 -0700247 *list = mSensorList;
Dan Stozad723bd72014-11-18 10:24:03 -0800248 return static_cast<ssize_t>(mSensors.size());
Mathias Agopian589ce852010-07-13 22:21:56 -0700249}
250
Vladimir Komsiyski157e4e02023-12-07 18:52:18 +0100251ssize_t SensorManager::getDefaultDeviceSensorList(Vector<Sensor> & list) {
252 Mutex::Autolock _l(mLock);
253 status_t err = assertStateLocked();
254 if (err < 0) {
255 return static_cast<ssize_t>(err);
256 }
257
258 if (mDeviceId == DEVICE_ID_DEFAULT) {
259 list = mSensors;
260 } else {
261 list = mSensorServer->getSensorList(mOpPackageName);
262 }
263
264 return static_cast<ssize_t>(list.size());
265}
266
Peng Xu2576cb62016-01-20 00:22:09 -0800267ssize_t SensorManager::getDynamicSensorList(Vector<Sensor> & dynamicSensors) {
268 Mutex::Autolock _l(mLock);
269 status_t err = assertStateLocked();
270 if (err < 0) {
271 return static_cast<ssize_t>(err);
272 }
273
274 dynamicSensors = mSensorServer->getDynamicSensorList(mOpPackageName);
275 size_t count = dynamicSensors.size();
276
277 return static_cast<ssize_t>(count);
278}
279
Vladimir Komsiyskif76bba52022-10-23 10:56:06 +0200280ssize_t SensorManager::getRuntimeSensorList(int deviceId, Vector<Sensor>& runtimeSensors) {
281 Mutex::Autolock _l(mLock);
282 status_t err = assertStateLocked();
283 if (err < 0) {
284 return static_cast<ssize_t>(err);
285 }
286
287 runtimeSensors = mSensorServer->getRuntimeSensorList(mOpPackageName, deviceId);
288 size_t count = runtimeSensors.size();
289
290 return static_cast<ssize_t>(count);
291}
292
Erik Staatsd35a5742022-02-04 06:37:58 -0800293ssize_t SensorManager::getDynamicSensorList(Sensor const* const** list) {
294 Mutex::Autolock _l(mLock);
295 status_t err = assertStateLocked();
296 if (err < 0) {
297 return static_cast<ssize_t>(err);
298 }
299
300 free(mDynamicSensorList);
301 mDynamicSensorList = nullptr;
302 mDynamicSensors = mSensorServer->getDynamicSensorList(mOpPackageName);
303 size_t dynamicCount = mDynamicSensors.size();
304 if (dynamicCount > 0) {
305 mDynamicSensorList = static_cast<Sensor const**>(
306 malloc(dynamicCount * sizeof(Sensor*)));
307 if (mDynamicSensorList == nullptr) {
308 ALOGE("Failed to allocate dynamic sensor list for %zu sensors.",
309 dynamicCount);
310 return static_cast<ssize_t>(NO_MEMORY);
311 }
312
313 for (size_t i = 0; i < dynamicCount; i++) {
314 mDynamicSensorList[i] = mDynamicSensors.array() + i;
315 }
316 }
317
318 *list = mDynamicSensorList;
319 return static_cast<ssize_t>(mDynamicSensors.size());
320}
321
Mathias Agopiana7352c92010-07-14 23:41:37 -0700322Sensor const* SensorManager::getDefaultSensor(int type)
Mathias Agopian589ce852010-07-13 22:21:56 -0700323{
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700324 Mutex::Autolock _l(mLock);
325 if (assertStateLocked() == NO_ERROR) {
Aravind Akellab37ba392014-08-05 14:53:07 -0700326 bool wakeUpSensor = false;
327 // For the following sensor types, return a wake-up sensor. These types are by default
328 // defined as wake-up sensors. For the rest of the sensor types defined in sensors.h return
329 // a non_wake-up version.
330 if (type == SENSOR_TYPE_PROXIMITY || type == SENSOR_TYPE_SIGNIFICANT_MOTION ||
331 type == SENSOR_TYPE_TILT_DETECTOR || type == SENSOR_TYPE_WAKE_GESTURE ||
Nick Vaccaro5e7f79b2016-10-17 15:40:51 -0700332 type == SENSOR_TYPE_GLANCE_GESTURE || type == SENSOR_TYPE_PICK_UP_GESTURE ||
Nick Vaccaro2e990eb2017-01-12 21:13:58 -0800333 type == SENSOR_TYPE_WRIST_TILT_GESTURE ||
Anthony Stangefdb1fc82020-01-16 15:02:48 -0500334 type == SENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT || type == SENSOR_TYPE_HINGE_ANGLE) {
Aravind Akellab37ba392014-08-05 14:53:07 -0700335 wakeUpSensor = true;
336 }
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700337 // For now we just return the first sensor of that type we find.
338 // in the future it will make sense to let the SensorService make
339 // that decision.
340 for (size_t i=0 ; i<mSensors.size() ; i++) {
Aravind Akellab37ba392014-08-05 14:53:07 -0700341 if (mSensorList[i]->getType() == type &&
342 mSensorList[i]->isWakeUpSensor() == wakeUpSensor) {
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700343 return mSensorList[i];
Aravind Akellab37ba392014-08-05 14:53:07 -0700344 }
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700345 }
Mathias Agopiana7352c92010-07-14 23:41:37 -0700346 }
Yi Kongd5e079f2018-07-17 16:08:27 -0700347 return nullptr;
Mathias Agopian589ce852010-07-13 22:21:56 -0700348}
349
Arthur Ishiguro340882c2021-02-18 15:17:44 -0800350sp<SensorEventQueue> SensorManager::createEventQueue(
351 String8 packageName, int mode, String16 attributionTag) {
Mathias Agopianbe58de02011-10-16 00:38:30 -0700352 sp<SensorEventQueue> queue;
353
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700354 Mutex::Autolock _l(mLock);
355 while (assertStateLocked() == NO_ERROR) {
Arthur Ishiguro340882c2021-02-18 15:17:44 -0800356 sp<ISensorEventConnection> connection = mSensorServer->createSensorEventConnection(
357 packageName, mode, mOpPackageName, attributionTag);
Yi Kongd5e079f2018-07-17 16:08:27 -0700358 if (connection == nullptr) {
Aravind Akellaa9e6cc32015-04-16 18:57:31 -0700359 // SensorService just died or the app doesn't have required permissions.
360 ALOGE("createEventQueue: connection is NULL.");
Yi Kongd5e079f2018-07-17 16:08:27 -0700361 return nullptr;
Mathias Agopian1a2b83a2011-10-16 22:15:23 -0700362 }
363 queue = new SensorEventQueue(connection);
364 break;
Mathias Agopianbe58de02011-10-16 00:38:30 -0700365 }
Mathias Agopianbe58de02011-10-16 00:38:30 -0700366 return queue;
Mathias Agopian589ce852010-07-13 22:21:56 -0700367}
368
Aravind Akella841a5922015-06-29 12:37:48 -0700369bool SensorManager::isDataInjectionEnabled() {
Aravind Akellaa9e6cc32015-04-16 18:57:31 -0700370 Mutex::Autolock _l(mLock);
371 if (assertStateLocked() == NO_ERROR) {
Aravind Akella841a5922015-06-29 12:37:48 -0700372 return mSensorServer->isDataInjectionEnabled();
Aravind Akellaa9e6cc32015-04-16 18:57:31 -0700373 }
Aravind Akella841a5922015-06-29 12:37:48 -0700374 return false;
Aravind Akellaa9e6cc32015-04-16 18:57:31 -0700375}
376
Mark Wheatley8f285d92023-07-07 20:07:18 +0000377bool SensorManager::isReplayDataInjectionEnabled() {
378 Mutex::Autolock _l(mLock);
379 if (assertStateLocked() == NO_ERROR) {
380 return mSensorServer->isReplayDataInjectionEnabled();
381 }
382 return false;
383}
384
385bool SensorManager::isHalBypassReplayDataInjectionEnabled() {
386 Mutex::Autolock _l(mLock);
387 if (assertStateLocked() == NO_ERROR) {
388 return mSensorServer->isHalBypassReplayDataInjectionEnabled();
389 }
390 return false;
391}
392
Peng Xue36e3472016-11-03 11:57:10 -0700393int SensorManager::createDirectChannel(
394 size_t size, int channelType, const native_handle_t *resourceHandle) {
Vladimir Komsiyski4871f092023-01-19 18:25:43 +0100395 static constexpr int DEFAULT_DEVICE_ID = 0;
396 return createDirectChannel(DEFAULT_DEVICE_ID, size, channelType, resourceHandle);
397}
398
399int SensorManager::createDirectChannel(
400 int deviceId, size_t size, int channelType, const native_handle_t *resourceHandle) {
Peng Xue36e3472016-11-03 11:57:10 -0700401 Mutex::Autolock _l(mLock);
402 if (assertStateLocked() != NO_ERROR) {
403 return NO_INIT;
404 }
405
Peng Xud9c8a862017-03-05 01:48:11 -0800406 if (channelType != SENSOR_DIRECT_MEM_TYPE_ASHMEM
407 && channelType != SENSOR_DIRECT_MEM_TYPE_GRALLOC) {
408 ALOGE("Bad channel shared memory type %d", channelType);
409 return BAD_VALUE;
Peng Xue36e3472016-11-03 11:57:10 -0700410 }
Peng Xud9c8a862017-03-05 01:48:11 -0800411
412 sp<ISensorEventConnection> conn =
Vladimir Komsiyski4871f092023-01-19 18:25:43 +0100413 mSensorServer->createSensorDirectConnection(mOpPackageName, deviceId,
Peng Xud9c8a862017-03-05 01:48:11 -0800414 static_cast<uint32_t>(size),
415 static_cast<int32_t>(channelType),
416 SENSOR_DIRECT_FMT_SENSORS_EVENT, resourceHandle);
417 if (conn == nullptr) {
418 return NO_MEMORY;
419 }
420
421 int nativeHandle = mDirectConnectionHandle++;
422 mDirectConnection.emplace(nativeHandle, conn);
423 return nativeHandle;
Peng Xue36e3472016-11-03 11:57:10 -0700424}
425
426void SensorManager::destroyDirectChannel(int channelNativeHandle) {
427 Mutex::Autolock _l(mLock);
428 if (assertStateLocked() == NO_ERROR) {
429 mDirectConnection.erase(channelNativeHandle);
430 }
431}
432
433int SensorManager::configureDirectChannel(int channelNativeHandle, int sensorHandle, int rateLevel) {
434 Mutex::Autolock _l(mLock);
435 if (assertStateLocked() != NO_ERROR) {
436 return NO_INIT;
437 }
438
439 auto i = mDirectConnection.find(channelNativeHandle);
440 if (i == mDirectConnection.end()) {
441 ALOGE("Cannot find the handle in client direct connection table");
442 return BAD_VALUE;
443 }
444
445 int ret;
446 ret = i->second->configureChannel(sensorHandle, rateLevel);
447 ALOGE_IF(ret < 0, "SensorManager::configureChannel (%d, %d) returns %d",
448 static_cast<int>(sensorHandle), static_cast<int>(rateLevel),
449 static_cast<int>(ret));
450 return ret;
451}
452
Peng Xudd5c5cb2017-03-16 17:39:43 -0700453int SensorManager::setOperationParameter(
Alexey Polyudov88711e82017-05-23 19:54:04 -0700454 int handle, int type,
455 const Vector<float> &floats, const Vector<int32_t> &ints) {
Peng Xudd5c5cb2017-03-16 17:39:43 -0700456 Mutex::Autolock _l(mLock);
457 if (assertStateLocked() != NO_ERROR) {
458 return NO_INIT;
459 }
Alexey Polyudov88711e82017-05-23 19:54:04 -0700460 return mSensorServer->setOperationParameter(handle, type, floats, ints);
Peng Xudd5c5cb2017-03-16 17:39:43 -0700461}
462
Mathias Agopian589ce852010-07-13 22:21:56 -0700463// ----------------------------------------------------------------------------
464}; // namespace android