summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/android/sensor.h4
-rw-r--r--libs/sensor/OWNERS2
-rw-r--r--services/sensorservice/OWNERS2
-rw-r--r--services/sensorservice/SensorDevice.cpp21
-rw-r--r--services/sensorservice/SensorService.cpp10
-rw-r--r--services/sensorservice/hidl/Android.bp1
-rw-r--r--services/sensorservice/hidl/SensorManager.cpp7
7 files changed, 39 insertions, 8 deletions
diff --git a/include/android/sensor.h b/include/android/sensor.h
index a88733cac7..2db0ee7fd9 100644
--- a/include/android/sensor.h
+++ b/include/android/sensor.h
@@ -197,7 +197,7 @@ enum {
* A sensor event.
*/
-/* NOTE: Must match hardware/sensors.h */
+/* NOTE: changes to these structs have to be backward compatible */
typedef struct ASensorVector {
union {
float v[3];
@@ -259,7 +259,7 @@ typedef struct {
};
} AAdditionalInfoEvent;
-/* NOTE: Must match hardware/sensors.h */
+/* NOTE: changes to this struct has to be backward compatible */
typedef struct ASensorEvent {
int32_t version; /* sizeof(struct ASensorEvent) */
int32_t sensor;
diff --git a/libs/sensor/OWNERS b/libs/sensor/OWNERS
new file mode 100644
index 0000000000..6a38a1ff14
--- /dev/null
+++ b/libs/sensor/OWNERS
@@ -0,0 +1,2 @@
+ashutoshj@google.com
+pengxu@google.com
diff --git a/services/sensorservice/OWNERS b/services/sensorservice/OWNERS
new file mode 100644
index 0000000000..6a38a1ff14
--- /dev/null
+++ b/services/sensorservice/OWNERS
@@ -0,0 +1,2 @@
+ashutoshj@google.com
+pengxu@google.com
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 7d9b0b730a..da3b2758d1 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -223,8 +223,13 @@ ssize_t SensorDevice::poll(sensors_event_t* buffer, size_t count) {
}
void SensorDevice::autoDisable(void *ident, int handle) {
- Info& info( mActivationCount.editValueFor(handle) );
Mutex::Autolock _l(mLock);
+ ssize_t activationIndex = mActivationCount.indexOfKey(handle);
+ if (activationIndex < 0) {
+ ALOGW("Handle %d cannot be found in activation record", handle);
+ return;
+ }
+ Info& info(mActivationCount.editValueAt(activationIndex));
info.removeBatchParamsForIdent(ident);
}
@@ -235,7 +240,12 @@ status_t SensorDevice::activate(void* ident, int handle, int enabled) {
bool actuateHardware = false;
Mutex::Autolock _l(mLock);
- Info& info( mActivationCount.editValueFor(handle) );
+ ssize_t activationIndex = mActivationCount.indexOfKey(handle);
+ if (activationIndex < 0) {
+ ALOGW("Handle %d cannot be found in activation record", handle);
+ return BAD_VALUE;
+ }
+ Info& info(mActivationCount.editValueAt(activationIndex));
ALOGD_IF(DEBUG_CONNECTIONS,
"SensorDevice::activate: ident=%p, handle=0x%08x, enabled=%d, count=%zu",
@@ -329,7 +339,12 @@ status_t SensorDevice::batch(
ident, handle, flags, samplingPeriodNs, maxBatchReportLatencyNs);
Mutex::Autolock _l(mLock);
- Info& info(mActivationCount.editValueFor(handle));
+ ssize_t activationIndex = mActivationCount.indexOfKey(handle);
+ if (activationIndex < 0) {
+ ALOGW("Handle %d cannot be found in activation record", handle);
+ return BAD_VALUE;
+ }
+ Info& info(mActivationCount.editValueAt(activationIndex));
if (info.batchParams.indexOfKey(ident) < 0) {
BatchParams params(samplingPeriodNs, maxBatchReportLatencyNs);
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 62c2756d2f..dc491d97c0 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -933,8 +933,14 @@ sp<ISensorEventConnection> SensorService::createSensorEventConnection(const Stri
}
uid_t uid = IPCThreadState::self()->getCallingUid();
- sp<SensorEventConnection> result(new SensorEventConnection(this, uid, packageName,
- requestedMode == DATA_INJECTION, opPackageName));
+ pid_t pid = IPCThreadState::self()->getCallingPid();
+
+ String8 connPackageName =
+ (packageName == "") ? String8::format("unknown_package_pid_%d", pid) : packageName;
+ String16 connOpPackageName =
+ (opPackageName == String16("")) ? String16(connPackageName) : opPackageName;
+ sp<SensorEventConnection> result(new SensorEventConnection(this, uid, connPackageName,
+ requestedMode == DATA_INJECTION, connOpPackageName));
if (requestedMode == DATA_INJECTION) {
if (mActiveConnections.indexOf(result) < 0) {
mActiveConnections.add(result);
diff --git a/services/sensorservice/hidl/Android.bp b/services/sensorservice/hidl/Android.bp
index 8bbc4c59a8..02c13fa579 100644
--- a/services/sensorservice/hidl/Android.bp
+++ b/services/sensorservice/hidl/Android.bp
@@ -14,6 +14,7 @@ cc_library_shared {
"libbase",
"libhidlbase",
"libhidltransport",
+ "libhwbinder",
"libutils",
"libsensor",
"android.frameworks.sensorservice@1.0",
diff --git a/services/sensorservice/hidl/SensorManager.cpp b/services/sensorservice/hidl/SensorManager.cpp
index cf5ab05082..fee6da1e60 100644
--- a/services/sensorservice/hidl/SensorManager.cpp
+++ b/services/sensorservice/hidl/SensorManager.cpp
@@ -29,6 +29,9 @@
#include "DirectReportChannel.h"
#include "utils.h"
+#include <hwbinder/IPCThreadState.h>
+#include <utils/String8.h>
+
namespace android {
namespace frameworks {
namespace sensorservice {
@@ -212,7 +215,9 @@ Return<void> SensorManager::createEventQueue(
return Void();
}
- sp<::android::SensorEventQueue> internalQueue = getInternalManager().createEventQueue();
+ String8 package(String8::format("hidl_client_pid_%d",
+ android::hardware::IPCThreadState::self()->getCallingPid()));
+ sp<::android::SensorEventQueue> internalQueue = getInternalManager().createEventQueue(package);
if (internalQueue == nullptr) {
LOG(WARNING) << "::android::SensorManager::createEventQueue returns nullptr.";
_hidl_cb(nullptr, Result::UNKNOWN_ERROR);