summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2013-07-03 16:20:57 -0700
committerMathias Agopian <mathias@google.com>2013-07-08 15:44:41 -0700
commitba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1 (patch)
tree51961ca9c701778e3f4dc6bf8ac367a47d217733 /services
parentcf90bad477055fb4f1ff34c0883d744a3dfe94a1 (diff)
downloadframeworks_native-ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1.zip
frameworks_native-ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1.tar.gz
frameworks_native-ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1.tar.bz2
improve sensorservice's dumpsys
it now displays the reported trigger mode properly, as well as the number and type of the last received data Change-Id: I2ff64b32ab71f1332bc2e09671c8c02bb9550490
Diffstat (limited to 'services')
-rw-r--r--services/sensorservice/SensorDevice.cpp14
-rw-r--r--services/sensorservice/SensorDevice.h2
-rw-r--r--services/sensorservice/SensorFusion.cpp5
-rw-r--r--services/sensorservice/SensorFusion.h2
-rw-r--r--services/sensorservice/SensorService.cpp76
5 files changed, 62 insertions, 37 deletions
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 16dabe8..18a1523 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -65,30 +65,26 @@ SensorDevice::SensorDevice()
}
}
-void SensorDevice::dump(String8& result, char* buffer, size_t SIZE)
+void SensorDevice::dump(String8& result)
{
if (!mSensorModule) return;
sensor_t const* list;
ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list);
- snprintf(buffer, SIZE, "%d h/w sensors:\n", int(count));
- result.append(buffer);
+ result.appendFormat("%d h/w sensors:\n", int(count));
Mutex::Autolock _l(mLock);
for (size_t i=0 ; i<size_t(count) ; i++) {
const Info& info = mActivationCount.valueFor(list[i].handle);
- snprintf(buffer, SIZE, "handle=0x%08x, active-count=%d, rates(ms)={ ",
+ result.appendFormat("handle=0x%08x, active-count=%d, rates(ms)={ ",
list[i].handle,
info.rates.size());
- result.append(buffer);
for (size_t j=0 ; j<info.rates.size() ; j++) {
- snprintf(buffer, SIZE, "%4.1f%s",
+ result.appendFormat("%4.1f%s",
info.rates.valueAt(j) / 1e6f,
j<info.rates.size()-1 ? ", " : "");
- result.append(buffer);
}
- snprintf(buffer, SIZE, " }, selected=%4.1f ms\n", info.delay / 1e6f);
- result.append(buffer);
+ result.appendFormat(" }, selected=%4.1f ms\n", info.delay / 1e6f);
}
}
diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h
index c0b357d..ca67ce2 100644
--- a/services/sensorservice/SensorDevice.h
+++ b/services/sensorservice/SensorDevice.h
@@ -57,7 +57,7 @@ public:
status_t activate(void* ident, int handle, int enabled);
status_t setDelay(void* ident, int handle, int64_t ns);
status_t resetStateWithoutActuatingHardware(void *ident, int handle);
- void dump(String8& result, char* buffer, size_t SIZE);
+ void dump(String8& result);
};
// ---------------------------------------------------------------------------
diff --git a/services/sensorservice/SensorFusion.cpp b/services/sensorservice/SensorFusion.cpp
index a0a17da..4014477 100644
--- a/services/sensorservice/SensorFusion.cpp
+++ b/services/sensorservice/SensorFusion.cpp
@@ -136,9 +136,9 @@ int32_t SensorFusion::getMinDelay() const {
return mAcc.getMinDelay();
}
-void SensorFusion::dump(String8& result, char* buffer, size_t SIZE) {
+void SensorFusion::dump(String8& result) {
const Fusion& fusion(mFusion);
- snprintf(buffer, SIZE, "9-axis fusion %s (%d clients), gyro-rate=%7.2fHz, "
+ result.appendFormat("9-axis fusion %s (%d clients), gyro-rate=%7.2fHz, "
"q=< %g, %g, %g, %g > (%g), "
"b=< %g, %g, %g >\n",
mEnabled ? "enabled" : "disabled",
@@ -152,7 +152,6 @@ void SensorFusion::dump(String8& result, char* buffer, size_t SIZE) {
fusion.getBias().x,
fusion.getBias().y,
fusion.getBias().z);
- result.append(buffer);
}
// ---------------------------------------------------------------------------
diff --git a/services/sensorservice/SensorFusion.h b/services/sensorservice/SensorFusion.h
index 3c2244e..432adbc 100644
--- a/services/sensorservice/SensorFusion.h
+++ b/services/sensorservice/SensorFusion.h
@@ -68,7 +68,7 @@ public:
float getPowerUsage() const;
int32_t getMinDelay() const;
- void dump(String8& result, char* buffer, size_t SIZE);
+ void dump(String8& result);
};
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 39e61b7..99993ba 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -187,47 +187,77 @@ static const String16 sDump("android.permission.DUMP");
status_t SensorService::dump(int fd, const Vector<String16>& args)
{
- const size_t SIZE = 1024;
- char buffer[SIZE];
String8 result;
if (!PermissionCache::checkCallingPermission(sDump)) {
- snprintf(buffer, SIZE, "Permission Denial: "
+ result.appendFormat("Permission Denial: "
"can't dump SurfaceFlinger from pid=%d, uid=%d\n",
IPCThreadState::self()->getCallingPid(),
IPCThreadState::self()->getCallingUid());
- result.append(buffer);
} else {
Mutex::Autolock _l(mLock);
- snprintf(buffer, SIZE, "Sensor List:\n");
- result.append(buffer);
+ result.append("Sensor List:\n");
for (size_t i=0 ; i<mSensorList.size() ; i++) {
const Sensor& s(mSensorList[i]);
const sensors_event_t& e(mLastEventSeen.valueFor(s.getHandle()));
- snprintf(buffer, SIZE,
- "%-48s| %-32s | 0x%08x | maxRate=%7.2fHz | "
- "last=<%5.1f,%5.1f,%5.1f>\n",
+ result.appendFormat(
+ "%-48s| %-32s | 0x%08x | ",
s.getName().string(),
s.getVendor().string(),
- s.getHandle(),
- s.getMinDelay() ? (1000000.0f / s.getMinDelay()) : 0.0f,
- e.data[0], e.data[1], e.data[2]);
- result.append(buffer);
+ s.getHandle());
+
+ if (s.getMinDelay() > 0) {
+ result.appendFormat(
+ "maxRate=%7.2fHz | ", 1e6f / s.getMinDelay());
+ } else {
+ result.append(s.getMinDelay() == 0
+ ? "on-demand | "
+ : "one-shot | ");
+ }
+
+ switch (s.getType()) {
+ case SENSOR_TYPE_ROTATION_VECTOR:
+ case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR:
+ result.appendFormat(
+ "last=<%5.1f,%5.1f,%5.1f,%5.1f,%5.1f>\n",
+ e.data[0], e.data[1], e.data[2], e.data[3], e.data[4]);
+ break;
+ case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED:
+ case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
+ result.appendFormat(
+ "last=<%5.1f,%5.1f,%5.1f,%5.1f,%5.1f,%5.1f>\n",
+ e.data[0], e.data[1], e.data[2], e.data[3], e.data[4], e.data[5]);
+ break;
+ case SENSOR_TYPE_GAME_ROTATION_VECTOR:
+ result.appendFormat(
+ "last=<%5.1f,%5.1f,%5.1f,%5.1f>\n",
+ e.data[0], e.data[1], e.data[2], e.data[3]);
+ break;
+ case SENSOR_TYPE_SIGNIFICANT_MOTION:
+ case SENSOR_TYPE_STEP_DETECTOR:
+ result.appendFormat( "last=<%f>\n", e.data[0]);
+ break;
+ case SENSOR_TYPE_STEP_COUNTER:
+ result.appendFormat( "last=<%llu>\n", e.u64.step_counter);
+ break;
+ default:
+ // default to 3 values
+ result.appendFormat(
+ "last=<%5.1f,%5.1f,%5.1f>\n",
+ e.data[0], e.data[1], e.data[2]);
+ break;
+ }
}
- SensorFusion::getInstance().dump(result, buffer, SIZE);
- SensorDevice::getInstance().dump(result, buffer, SIZE);
-
- snprintf(buffer, SIZE, "%d active connections\n",
- mActiveConnections.size());
- result.append(buffer);
- snprintf(buffer, SIZE, "Active sensors:\n");
- result.append(buffer);
+ SensorFusion::getInstance().dump(result);
+ SensorDevice::getInstance().dump(result);
+
+ result.appendFormat("%d active connections\n", mActiveConnections.size());
+ result.append("Active sensors:\n");
for (size_t i=0 ; i<mActiveSensors.size() ; i++) {
int handle = mActiveSensors.keyAt(i);
- snprintf(buffer, SIZE, "%s (handle=0x%08x, connections=%d)\n",
+ result.appendFormat("%s (handle=0x%08x, connections=%d)\n",
getSensorName(handle).string(),
handle,
mActiveSensors.valueAt(i)->getNumConnections());
- result.append(buffer);
}
}
write(fd, result.string(), result.size());