Prefer std::string over String8
String8 is obsolete, only use std::string in the
input libraries now.
Bug: 64258224
Test: make
Change-Id: I958b6b281d969138f39cc26825c877a24bc4a853
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index c4b5dca..6187528 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -31,7 +31,6 @@
#include <utils/Errors.h>
#include <utils/Timers.h>
#include <utils/RefBase.h>
-#include <utils/String8.h>
#include <utils/Vector.h>
#include <utils/BitSet.h>
@@ -142,16 +141,16 @@
virtual ~InputChannel();
public:
- InputChannel(const String8& name, int fd);
+ InputChannel(const std::string& name, int fd);
/* Creates a pair of input channels.
*
* Returns OK on success.
*/
- static status_t openInputChannelPair(const String8& name,
+ static status_t openInputChannelPair(const std::string& name,
sp<InputChannel>& outServerChannel, sp<InputChannel>& outClientChannel);
- inline String8 getName() const { return mName; }
+ inline std::string getName() const { return mName; }
inline int getFd() const { return mFd; }
/* Sends a message to the other endpoint.
@@ -183,7 +182,7 @@
sp<InputChannel> dup() const;
private:
- String8 mName;
+ std::string mName;
int mFd;
};
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index b8901bd..5fe8d8b 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -99,34 +99,34 @@
// --- InputChannel ---
-InputChannel::InputChannel(const String8& name, int fd) :
+InputChannel::InputChannel(const std::string& name, int fd) :
mName(name), mFd(fd) {
#if DEBUG_CHANNEL_LIFECYCLE
ALOGD("Input channel constructed: name='%s', fd=%d",
- mName.string(), fd);
+ mName.c_str(), fd);
#endif
int result = fcntl(mFd, F_SETFL, O_NONBLOCK);
LOG_ALWAYS_FATAL_IF(result != 0, "channel '%s' ~ Could not make socket "
- "non-blocking. errno=%d", mName.string(), errno);
+ "non-blocking. errno=%d", mName.c_str(), errno);
}
InputChannel::~InputChannel() {
#if DEBUG_CHANNEL_LIFECYCLE
ALOGD("Input channel destroyed: name='%s', fd=%d",
- mName.string(), mFd);
+ mName.c_str(), mFd);
#endif
::close(mFd);
}
-status_t InputChannel::openInputChannelPair(const String8& name,
+status_t InputChannel::openInputChannelPair(const std::string& name,
sp<InputChannel>& outServerChannel, sp<InputChannel>& outClientChannel) {
int sockets[2];
if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sockets)) {
status_t result = -errno;
ALOGE("channel '%s' ~ Could not create socket pair. errno=%d",
- name.string(), errno);
+ name.c_str(), errno);
outServerChannel.clear();
outClientChannel.clear();
return result;
@@ -138,12 +138,12 @@
setsockopt(sockets[1], SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(bufferSize));
setsockopt(sockets[1], SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize));
- String8 serverChannelName = name;
- serverChannelName.append(" (server)");
+ std::string serverChannelName = name;
+ serverChannelName += " (server)";
outServerChannel = new InputChannel(serverChannelName, sockets[0]);
- String8 clientChannelName = name;
- clientChannelName.append(" (client)");
+ std::string clientChannelName = name;
+ clientChannelName += " (client)";
outClientChannel = new InputChannel(clientChannelName, sockets[1]);
return OK;
}
@@ -158,7 +158,7 @@
if (nWrite < 0) {
int error = errno;
#if DEBUG_CHANNEL_MESSAGES
- ALOGD("channel '%s' ~ error sending message of type %d, errno=%d", mName.string(),
+ ALOGD("channel '%s' ~ error sending message of type %d, errno=%d", mName.c_str(),
msg->header.type, error);
#endif
if (error == EAGAIN || error == EWOULDBLOCK) {
@@ -173,13 +173,13 @@
if (size_t(nWrite) != msgLength) {
#if DEBUG_CHANNEL_MESSAGES
ALOGD("channel '%s' ~ error sending message type %d, send was incomplete",
- mName.string(), msg->header.type);
+ mName.c_str(), msg->header.type);
#endif
return DEAD_OBJECT;
}
#if DEBUG_CHANNEL_MESSAGES
- ALOGD("channel '%s' ~ sent message of type %d", mName.string(), msg->header.type);
+ ALOGD("channel '%s' ~ sent message of type %d", mName.c_str(), msg->header.type);
#endif
return OK;
}
@@ -193,7 +193,7 @@
if (nRead < 0) {
int error = errno;
#if DEBUG_CHANNEL_MESSAGES
- ALOGD("channel '%s' ~ receive message failed, errno=%d", mName.string(), errno);
+ ALOGD("channel '%s' ~ receive message failed, errno=%d", mName.c_str(), errno);
#endif
if (error == EAGAIN || error == EWOULDBLOCK) {
return WOULD_BLOCK;
@@ -206,20 +206,20 @@
if (nRead == 0) { // check for EOF
#if DEBUG_CHANNEL_MESSAGES
- ALOGD("channel '%s' ~ receive message failed because peer was closed", mName.string());
+ ALOGD("channel '%s' ~ receive message failed because peer was closed", mName.c_str());
#endif
return DEAD_OBJECT;
}
if (!msg->isValid(nRead)) {
#if DEBUG_CHANNEL_MESSAGES
- ALOGD("channel '%s' ~ received invalid message", mName.string());
+ ALOGD("channel '%s' ~ received invalid message", mName.c_str());
#endif
return BAD_VALUE;
}
#if DEBUG_CHANNEL_MESSAGES
- ALOGD("channel '%s' ~ received message of type %d", mName.string(), msg->header.type);
+ ALOGD("channel '%s' ~ received message of type %d", mName.c_str(), msg->header.type);
#endif
return OK;
}
@@ -255,7 +255,7 @@
ALOGD("channel '%s' publisher ~ publishKeyEvent: seq=%u, deviceId=%d, source=0x%x, "
"action=0x%x, flags=0x%x, keyCode=%d, scanCode=%d, metaState=0x%x, repeatCount=%d,"
"downTime=%" PRId64 ", eventTime=%" PRId64,
- mChannel->getName().string(), seq,
+ mChannel->getName().c_str(), seq,
deviceId, source, action, flags, keyCode, scanCode, metaState, repeatCount,
downTime, eventTime);
#endif
@@ -307,7 +307,7 @@
"metaState=0x%x, buttonState=0x%x, xOffset=%f, yOffset=%f, "
"xPrecision=%f, yPrecision=%f, downTime=%" PRId64 ", eventTime=%" PRId64 ", "
"pointerCount=%" PRIu32,
- mChannel->getName().string(), seq,
+ mChannel->getName().c_str(), seq,
deviceId, source, action, actionButton, flags, edgeFlags, metaState, buttonState,
xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount);
#endif
@@ -319,7 +319,7 @@
if (pointerCount > MAX_POINTERS || pointerCount < 1) {
ALOGE("channel '%s' publisher ~ Invalid number of pointers provided: %" PRIu32 ".",
- mChannel->getName().string(), pointerCount);
+ mChannel->getName().c_str(), pointerCount);
return BAD_VALUE;
}
@@ -352,7 +352,7 @@
status_t InputPublisher::receiveFinishedSignal(uint32_t* outSeq, bool* outHandled) {
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' publisher ~ receiveFinishedSignal",
- mChannel->getName().string());
+ mChannel->getName().c_str());
#endif
InputMessage msg;
@@ -364,7 +364,7 @@
}
if (msg.header.type != InputMessage::TYPE_FINISHED) {
ALOGE("channel '%s' publisher ~ Received unexpected message of type %d from consumer",
- mChannel->getName().string(), msg.header.type);
+ mChannel->getName().c_str(), msg.header.type);
return UNKNOWN_ERROR;
}
*outSeq = msg.body.finished.seq;
@@ -402,7 +402,7 @@
int32_t* displayId) {
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' consumer ~ consume: consumeBatches=%s, frameTime=%" PRId64,
- mChannel->getName().string(), consumeBatches ? "true" : "false", frameTime);
+ mChannel->getName().c_str(), consumeBatches ? "true" : "false", frameTime);
#endif
*outSeq = 0;
@@ -426,7 +426,7 @@
if (*outEvent) {
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' consumer ~ consumed batch event, seq=%u",
- mChannel->getName().string(), *outSeq);
+ mChannel->getName().c_str(), *outSeq);
#endif
break;
}
@@ -445,7 +445,7 @@
*outEvent = keyEvent;
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' consumer ~ consumed key event, seq=%u",
- mChannel->getName().string(), *outSeq);
+ mChannel->getName().c_str(), *outSeq);
#endif
break;
}
@@ -458,7 +458,7 @@
batch.samples.push(mMsg);
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' consumer ~ appended to batch event",
- mChannel->getName().string());
+ mChannel->getName().c_str());
#endif
break;
} else {
@@ -474,7 +474,7 @@
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' consumer ~ consumed batch event and "
"deferred current event, seq=%u",
- mChannel->getName().string(), *outSeq);
+ mChannel->getName().c_str(), *outSeq);
#endif
break;
}
@@ -488,7 +488,7 @@
batch.samples.push(mMsg);
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' consumer ~ started batch event",
- mChannel->getName().string());
+ mChannel->getName().c_str());
#endif
break;
}
@@ -503,14 +503,14 @@
*displayId = mMsg.body.motion.displayId;
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' consumer ~ consumed motion event, seq=%u",
- mChannel->getName().string(), *outSeq);
+ mChannel->getName().c_str(), *outSeq);
#endif
break;
}
default:
ALOGE("channel '%s' consumer ~ Received unexpected message of type %d",
- mChannel->getName().string(), mMsg.header.type);
+ mChannel->getName().c_str(), mMsg.header.type);
return UNKNOWN_ERROR;
}
}
@@ -828,7 +828,7 @@
status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) {
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' consumer ~ sendFinishedSignal: seq=%u, handled=%s",
- mChannel->getName().string(), seq, handled ? "true" : "false");
+ mChannel->getName().c_str(), seq, handled ? "true" : "false");
#endif
if (!seq) {
diff --git a/libs/input/tests/InputChannel_test.cpp b/libs/input/tests/InputChannel_test.cpp
index e71ebe2..96c165c 100644
--- a/libs/input/tests/InputChannel_test.cpp
+++ b/libs/input/tests/InputChannel_test.cpp
@@ -41,9 +41,9 @@
// of a pipe and to check for EPIPE on the other end after the channel is destroyed.
Pipe pipe;
- sp<InputChannel> inputChannel = new InputChannel(String8("channel name"), pipe.sendFd);
+ sp<InputChannel> inputChannel = new InputChannel("channel name", pipe.sendFd);
- EXPECT_STREQ("channel name", inputChannel->getName().string())
+ EXPECT_STREQ("channel name", inputChannel->getName().c_str())
<< "channel should have provided name";
EXPECT_EQ(pipe.sendFd, inputChannel->getFd())
<< "channel should have provided fd";
@@ -60,16 +60,16 @@
TEST_F(InputChannelTest, OpenInputChannelPair_ReturnsAPairOfConnectedChannels) {
sp<InputChannel> serverChannel, clientChannel;
- status_t result = InputChannel::openInputChannelPair(String8("channel name"),
+ status_t result = InputChannel::openInputChannelPair("channel name",
serverChannel, clientChannel);
ASSERT_EQ(OK, result)
<< "should have successfully opened a channel pair";
// Name
- EXPECT_STREQ("channel name (server)", serverChannel->getName().string())
+ EXPECT_STREQ("channel name (server)", serverChannel->getName().c_str())
<< "server channel should have suffixed name";
- EXPECT_STREQ("channel name (client)", clientChannel->getName().string())
+ EXPECT_STREQ("channel name (client)", clientChannel->getName().c_str())
<< "client channel should have suffixed name";
// Server->Client communication
@@ -111,7 +111,7 @@
TEST_F(InputChannelTest, ReceiveSignal_WhenNoSignalPresent_ReturnsAnError) {
sp<InputChannel> serverChannel, clientChannel;
- status_t result = InputChannel::openInputChannelPair(String8("channel name"),
+ status_t result = InputChannel::openInputChannelPair("channel name",
serverChannel, clientChannel);
ASSERT_EQ(OK, result)
@@ -125,7 +125,7 @@
TEST_F(InputChannelTest, ReceiveSignal_WhenPeerClosed_ReturnsAnError) {
sp<InputChannel> serverChannel, clientChannel;
- status_t result = InputChannel::openInputChannelPair(String8("channel name"),
+ status_t result = InputChannel::openInputChannelPair("channel name",
serverChannel, clientChannel);
ASSERT_EQ(OK, result)
@@ -141,7 +141,7 @@
TEST_F(InputChannelTest, SendSignal_WhenPeerClosed_ReturnsAnError) {
sp<InputChannel> serverChannel, clientChannel;
- status_t result = InputChannel::openInputChannelPair(String8("channel name"),
+ status_t result = InputChannel::openInputChannelPair("channel name",
serverChannel, clientChannel);
ASSERT_EQ(OK, result)
diff --git a/libs/input/tests/InputPublisherAndConsumer_test.cpp b/libs/input/tests/InputPublisherAndConsumer_test.cpp
index f86f876..c532241 100644
--- a/libs/input/tests/InputPublisherAndConsumer_test.cpp
+++ b/libs/input/tests/InputPublisherAndConsumer_test.cpp
@@ -36,7 +36,7 @@
PreallocatedInputEventFactory mEventFactory;
virtual void SetUp() {
- status_t result = InputChannel::openInputChannelPair(String8("channel name"),
+ status_t result = InputChannel::openInputChannelPair("channel name",
serverChannel, clientChannel);
mPublisher = new InputPublisher(serverChannel);
diff --git a/services/inputflinger/Android.bp b/services/inputflinger/Android.bp
index 238cba3..a9e5a43 100644
--- a/services/inputflinger/Android.bp
+++ b/services/inputflinger/Android.bp
@@ -26,6 +26,7 @@
],
shared_libs: [
+ "libbase",
"libbinder",
"libcrypto",
"libcutils",
diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp
index 99fe0f5..4d9a2a0 100644
--- a/services/inputflinger/EventHub.cpp
+++ b/services/inputflinger/EventHub.cpp
@@ -39,6 +39,7 @@
#include <hardware_legacy/power.h>
+#include <android-base/stringprintf.h>
#include <cutils/properties.h>
#include <openssl/sha.h>
#include <utils/Log.h>
@@ -64,6 +65,8 @@
#define INDENT2 " "
#define INDENT3 " "
+using android::base::StringPrintf;
+
namespace android {
static const char *WAKE_LOCK_ID = "KeyEvents";
@@ -1733,43 +1736,43 @@
mNeedToReopenDevices = true;
}
-void EventHub::dump(String8& dump) {
- dump.append("Event Hub State:\n");
+void EventHub::dump(std::string& dump) {
+ dump += "Event Hub State:\n";
{ // acquire lock
AutoMutex _l(mLock);
- dump.appendFormat(INDENT "BuiltInKeyboardId: %d\n", mBuiltInKeyboardId);
+ dump += StringPrintf(INDENT "BuiltInKeyboardId: %d\n", mBuiltInKeyboardId);
- dump.append(INDENT "Devices:\n");
+ dump += INDENT "Devices:\n";
for (size_t i = 0; i < mDevices.size(); i++) {
const Device* device = mDevices.valueAt(i);
if (mBuiltInKeyboardId == device->id) {
- dump.appendFormat(INDENT2 "%d: %s (aka device 0 - built-in keyboard)\n",
+ dump += StringPrintf(INDENT2 "%d: %s (aka device 0 - built-in keyboard)\n",
device->id, device->identifier.name.string());
} else {
- dump.appendFormat(INDENT2 "%d: %s\n", device->id,
+ dump += StringPrintf(INDENT2 "%d: %s\n", device->id,
device->identifier.name.string());
}
- dump.appendFormat(INDENT3 "Classes: 0x%08x\n", device->classes);
- dump.appendFormat(INDENT3 "Path: %s\n", device->path.string());
- dump.appendFormat(INDENT3 "Enabled: %s\n", toString(device->enabled));
- dump.appendFormat(INDENT3 "Descriptor: %s\n", device->identifier.descriptor.string());
- dump.appendFormat(INDENT3 "Location: %s\n", device->identifier.location.string());
- dump.appendFormat(INDENT3 "ControllerNumber: %d\n", device->controllerNumber);
- dump.appendFormat(INDENT3 "UniqueId: %s\n", device->identifier.uniqueId.string());
- dump.appendFormat(INDENT3 "Identifier: bus=0x%04x, vendor=0x%04x, "
+ dump += StringPrintf(INDENT3 "Classes: 0x%08x\n", device->classes);
+ dump += StringPrintf(INDENT3 "Path: %s\n", device->path.string());
+ dump += StringPrintf(INDENT3 "Enabled: %s\n", toString(device->enabled));
+ dump += StringPrintf(INDENT3 "Descriptor: %s\n", device->identifier.descriptor.string());
+ dump += StringPrintf(INDENT3 "Location: %s\n", device->identifier.location.string());
+ dump += StringPrintf(INDENT3 "ControllerNumber: %d\n", device->controllerNumber);
+ dump += StringPrintf(INDENT3 "UniqueId: %s\n", device->identifier.uniqueId.string());
+ dump += StringPrintf(INDENT3 "Identifier: bus=0x%04x, vendor=0x%04x, "
"product=0x%04x, version=0x%04x\n",
device->identifier.bus, device->identifier.vendor,
device->identifier.product, device->identifier.version);
- dump.appendFormat(INDENT3 "KeyLayoutFile: %s\n",
+ dump += StringPrintf(INDENT3 "KeyLayoutFile: %s\n",
device->keyMap.keyLayoutFile.string());
- dump.appendFormat(INDENT3 "KeyCharacterMapFile: %s\n",
+ dump += StringPrintf(INDENT3 "KeyCharacterMapFile: %s\n",
device->keyMap.keyCharacterMapFile.string());
- dump.appendFormat(INDENT3 "ConfigurationFile: %s\n",
+ dump += StringPrintf(INDENT3 "ConfigurationFile: %s\n",
device->configurationFile.string());
- dump.appendFormat(INDENT3 "HaveKeyboardLayoutOverlay: %s\n",
+ dump += StringPrintf(INDENT3 "HaveKeyboardLayoutOverlay: %s\n",
toString(device->overlayKeyMap != NULL));
}
} // release lock
diff --git a/services/inputflinger/EventHub.h b/services/inputflinger/EventHub.h
index 727b73a..66bc294 100644
--- a/services/inputflinger/EventHub.h
+++ b/services/inputflinger/EventHub.h
@@ -24,7 +24,6 @@
#include <input/KeyLayoutMap.h>
#include <input/KeyCharacterMap.h>
#include <input/VirtualKeyMap.h>
-#include <utils/String8.h>
#include <utils/Mutex.h>
#include <utils/Log.h>
#include <utils/List.h>
@@ -262,7 +261,7 @@
virtual void wake() = 0;
/* Dump EventHub state to a string. */
- virtual void dump(String8& dump) = 0;
+ virtual void dump(std::string& dump) = 0;
/* Called by the heatbeat to ensures that the reader has not deadlocked. */
virtual void monitor() = 0;
@@ -333,7 +332,7 @@
virtual void wake();
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
virtual void monitor();
protected:
diff --git a/services/inputflinger/InputApplication.h b/services/inputflinger/InputApplication.h
index 1f5504c..724fc2c 100644
--- a/services/inputflinger/InputApplication.h
+++ b/services/inputflinger/InputApplication.h
@@ -18,10 +18,8 @@
#define _UI_INPUT_APPLICATION_H
#include <input/Input.h>
-
#include <utils/RefBase.h>
#include <utils/Timers.h>
-#include <utils/String8.h>
namespace android {
@@ -29,7 +27,7 @@
* Describes the properties of an application that can receive input.
*/
struct InputApplicationInfo {
- String8 name;
+ std::string name;
nsecs_t dispatchingTimeout;
};
@@ -46,8 +44,8 @@
return mInfo;
}
- inline String8 getName() const {
- return mInfo ? mInfo->name : String8("<invalid>");
+ inline std::string getName() const {
+ return mInfo ? mInfo->name : "<invalid>";
}
inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const {
diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp
index 8ab30e8..4194dea 100644
--- a/services/inputflinger/InputDispatcher.cpp
+++ b/services/inputflinger/InputDispatcher.cpp
@@ -47,10 +47,12 @@
#include <errno.h>
#include <limits.h>
+#include <sstream>
#include <stddef.h>
#include <time.h>
#include <unistd.h>
+#include <android-base/stringprintf.h>
#include <log/log.h>
#include <utils/Trace.h>
#include <powermanager/PowerManager.h>
@@ -61,6 +63,8 @@
#define INDENT3 " "
#define INDENT4 " "
+using android::base::StringPrintf;
+
namespace android {
// Default input dispatching timeout if there is no focused application or paused window
@@ -176,9 +180,9 @@
return displayId == ADISPLAY_ID_DEFAULT || displayId == ADISPLAY_ID_NONE;
}
-static void dumpRegion(String8& dump, const Region& region) {
+static void dumpRegion(std::string& dump, const Region& region) {
if (region.isEmpty()) {
- dump.append("<empty>");
+ dump += "<empty>";
return;
}
@@ -189,9 +193,9 @@
if (first) {
first = false;
} else {
- dump.append("|");
+ dump += "|";
}
- dump.appendFormat("[%d,%d][%d,%d]", cur->left, cur->top, cur->right, cur->bottom);
+ dump += StringPrintf("[%d,%d][%d,%d]", cur->left, cur->top, cur->right, cur->bottom);
cur++;
}
}
@@ -937,7 +941,7 @@
#if DEBUG_FOCUS
ALOGD("Dropping event delivery to target with channel '%s' because it "
"is no longer registered with the input dispatcher.",
- inputTarget.inputChannel->getName().string());
+ inputTarget.inputChannel->getName().c_str());
#endif
}
}
@@ -963,7 +967,7 @@
if (mInputTargetWaitCause != INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY) {
#if DEBUG_FOCUS
ALOGD("Waiting for application to become ready for input: %s. Reason: %s",
- getApplicationWindowLabelLocked(applicationHandle, windowHandle).string(),
+ getApplicationWindowLabelLocked(applicationHandle, windowHandle).c_str(),
reason);
#endif
nsecs_t timeout;
@@ -1070,7 +1074,7 @@
int32_t InputDispatcher::findFocusedWindowTargetsLocked(nsecs_t currentTime,
const EventEntry* entry, Vector<InputTarget>& inputTargets, nsecs_t* nextWakeupTime) {
int32_t injectionResult;
- String8 reason;
+ std::string reason;
// If there is no currently focused window and no focused application
// then drop the event.
@@ -1098,9 +1102,9 @@
// Check whether the window is ready for more input.
reason = checkWindowReadyForMoreInputLocked(currentTime,
mFocusedWindowHandle, entry, "focused");
- if (!reason.isEmpty()) {
+ if (!reason.empty()) {
injectionResult = handleTargetsNotReadyLocked(currentTime, entry,
- mFocusedApplicationHandle, mFocusedWindowHandle, nextWakeupTime, reason.string());
+ mFocusedApplicationHandle, mFocusedWindowHandle, nextWakeupTime, reason.c_str());
goto Unresponsive;
}
@@ -1309,8 +1313,8 @@
&& newTouchedWindowHandle != NULL) {
#if DEBUG_FOCUS
ALOGD("Touch is slipping out of window %s into window %s.",
- oldTouchedWindowHandle->getName().string(),
- newTouchedWindowHandle->getName().string());
+ oldTouchedWindowHandle->getName().c_str(),
+ newTouchedWindowHandle->getName().c_str());
#endif
// Make a slippery exit from the old window.
mTempTouchState.addOrUpdateWindow(oldTouchedWindowHandle,
@@ -1344,7 +1348,7 @@
if (mLastHoverWindowHandle != NULL) {
#if DEBUG_HOVER
ALOGD("Sending hover exit event to window %s.",
- mLastHoverWindowHandle->getName().string());
+ mLastHoverWindowHandle->getName().c_str());
#endif
mTempTouchState.addOrUpdateWindow(mLastHoverWindowHandle,
InputTarget::FLAG_DISPATCH_AS_HOVER_EXIT, BitSet32(0));
@@ -1354,7 +1358,7 @@
if (newHoverWindowHandle != NULL) {
#if DEBUG_HOVER
ALOGD("Sending hover enter event to window %s.",
- newHoverWindowHandle->getName().string());
+ newHoverWindowHandle->getName().c_str());
#endif
mTempTouchState.addOrUpdateWindow(newHoverWindowHandle,
InputTarget::FLAG_DISPATCH_AS_HOVER_ENTER, BitSet32(0));
@@ -1412,11 +1416,11 @@
const TouchedWindow& touchedWindow = mTempTouchState.windows[i];
if (touchedWindow.targetFlags & InputTarget::FLAG_FOREGROUND) {
// Check whether the window is ready for more input.
- String8 reason = checkWindowReadyForMoreInputLocked(currentTime,
+ std::string reason = checkWindowReadyForMoreInputLocked(currentTime,
touchedWindow.windowHandle, entry, "touched");
- if (!reason.isEmpty()) {
+ if (!reason.empty()) {
injectionResult = handleTargetsNotReadyLocked(currentTime, entry,
- NULL, touchedWindow.windowHandle, nextWakeupTime, reason.string());
+ NULL, touchedWindow.windowHandle, nextWakeupTime, reason.c_str());
goto Unresponsive;
}
}
@@ -1604,7 +1608,7 @@
ALOGW("Permission denied: injecting event from pid %d uid %d to window %s "
"owned by uid %d",
injectionState->injectorPid, injectionState->injectorUid,
- windowHandle->getName().string(),
+ windowHandle->getName().c_str(),
windowHandle->getInfo()->ownerUid);
} else {
ALOGW("Permission denied: injecting event from pid %d uid %d",
@@ -1656,18 +1660,18 @@
return false;
}
-String8 InputDispatcher::checkWindowReadyForMoreInputLocked(nsecs_t currentTime,
+std::string InputDispatcher::checkWindowReadyForMoreInputLocked(nsecs_t currentTime,
const sp<InputWindowHandle>& windowHandle, const EventEntry* eventEntry,
const char* targetType) {
// If the window is paused then keep waiting.
if (windowHandle->getInfo()->paused) {
- return String8::format("Waiting because the %s window is paused.", targetType);
+ return StringPrintf("Waiting because the %s window is paused.", targetType);
}
// If the window's connection is not registered then keep waiting.
ssize_t connectionIndex = getConnectionIndexLocked(windowHandle->getInputChannel());
if (connectionIndex < 0) {
- return String8::format("Waiting because the %s window's input channel is not "
+ return StringPrintf("Waiting because the %s window's input channel is not "
"registered with the input dispatcher. The window may be in the process "
"of being removed.", targetType);
}
@@ -1675,14 +1679,14 @@
// If the connection is dead then keep waiting.
sp<Connection> connection = mConnectionsByFd.valueAt(connectionIndex);
if (connection->status != Connection::STATUS_NORMAL) {
- return String8::format("Waiting because the %s window's input connection is %s."
+ return StringPrintf("Waiting because the %s window's input connection is %s."
"The window may be in the process of being removed.", targetType,
connection->getStatusLabel());
}
// If the connection is backed up then keep waiting.
if (connection->inputPublisherBlocked) {
- return String8::format("Waiting because the %s window's input channel is full. "
+ return StringPrintf("Waiting because the %s window's input channel is full. "
"Outbound queue length: %d. Wait queue length: %d.",
targetType, connection->outboundQueue.count(), connection->waitQueue.count());
}
@@ -1701,7 +1705,7 @@
// To obtain this behavior, we must serialize key events with respect to all
// prior input events.
if (!connection->outboundQueue.isEmpty() || !connection->waitQueue.isEmpty()) {
- return String8::format("Waiting to send key event because the %s window has not "
+ return StringPrintf("Waiting to send key event because the %s window has not "
"finished processing all of the input events that were previously "
"delivered to it. Outbound queue length: %d. Wait queue length: %d.",
targetType, connection->outboundQueue.count(), connection->waitQueue.count());
@@ -1725,7 +1729,7 @@
if (!connection->waitQueue.isEmpty()
&& currentTime >= connection->waitQueue.head->deliveryTime
+ STREAM_AHEAD_EVENT_TIMEOUT) {
- return String8::format("Waiting to send non-key event because the %s window has not "
+ return StringPrintf("Waiting to send non-key event because the %s window has not "
"finished processing certain input events that were delivered to it over "
"%0.1fms ago. Wait queue length: %d. Wait queue head age: %0.1fms.",
targetType, STREAM_AHEAD_EVENT_TIMEOUT * 0.000001f,
@@ -1733,17 +1737,17 @@
(currentTime - connection->waitQueue.head->deliveryTime) * 0.000001f);
}
}
- return String8::empty();
+ return "";
}
-String8 InputDispatcher::getApplicationWindowLabelLocked(
+std::string InputDispatcher::getApplicationWindowLabelLocked(
const sp<InputApplicationHandle>& applicationHandle,
const sp<InputWindowHandle>& windowHandle) {
if (applicationHandle != NULL) {
if (windowHandle != NULL) {
- String8 label(applicationHandle->getName());
- label.append(" - ");
- label.append(windowHandle->getName());
+ std::string label(applicationHandle->getName());
+ label += " - ";
+ label += windowHandle->getName();
return label;
} else {
return applicationHandle->getName();
@@ -1751,7 +1755,7 @@
} else if (windowHandle != NULL) {
return windowHandle->getName();
} else {
- return String8("<unknown application or window>");
+ return "<unknown application or window>";
}
}
@@ -1760,7 +1764,7 @@
const InputWindowInfo* info = mFocusedWindowHandle->getInfo();
if (info->inputFeatures & InputWindowInfo::INPUT_FEATURE_DISABLE_USER_ACTIVITY) {
#if DEBUG_DISPATCH_CYCLE
- ALOGD("Not poking user activity: disabled by window '%s'.", info->name.string());
+ ALOGD("Not poking user activity: disabled by window '%s'.", info->name.c_str());
#endif
return;
}
@@ -2882,7 +2886,7 @@
if (mFocusedWindowHandle != NULL) {
#if DEBUG_FOCUS
ALOGD("Focus left window: %s",
- mFocusedWindowHandle->getName().string());
+ mFocusedWindowHandle->getName().c_str());
#endif
sp<InputChannel> focusedInputChannel = mFocusedWindowHandle->getInputChannel();
if (focusedInputChannel != NULL) {
@@ -2895,7 +2899,7 @@
if (newFocusedWindowHandle != NULL) {
#if DEBUG_FOCUS
ALOGD("Focus entered window: %s",
- newFocusedWindowHandle->getName().string());
+ newFocusedWindowHandle->getName().c_str());
#endif
}
mFocusedWindowHandle = newFocusedWindowHandle;
@@ -2908,7 +2912,7 @@
if (!hasWindowHandleLocked(touchedWindow.windowHandle)) {
#if DEBUG_FOCUS
ALOGD("Touched window was removed: %s",
- touchedWindow.windowHandle->getName().string());
+ touchedWindow.windowHandle->getName().c_str());
#endif
sp<InputChannel> touchedInputChannel =
touchedWindow.windowHandle->getInputChannel();
@@ -2933,7 +2937,7 @@
const sp<InputWindowHandle>& oldWindowHandle = oldWindowHandles.itemAt(i);
if (!hasWindowHandleLocked(oldWindowHandle)) {
#if DEBUG_FOCUS
- ALOGD("Window went away: %s", oldWindowHandle->getName().string());
+ ALOGD("Window went away: %s", oldWindowHandle->getName().c_str());
#endif
oldWindowHandle->releaseInfo();
}
@@ -3035,7 +3039,7 @@
const sp<InputChannel>& toChannel) {
#if DEBUG_FOCUS
ALOGD("transferTouchFocus: fromChannel=%s, toChannel=%s",
- fromChannel->getName().string(), toChannel->getName().string());
+ fromChannel->getName().c_str(), toChannel->getName().c_str());
#endif
{ // acquire lock
AutoMutex _l(mLock);
@@ -3132,72 +3136,68 @@
}
void InputDispatcher::logDispatchStateLocked() {
- String8 dump;
+ std::string dump;
dumpDispatchStateLocked(dump);
- char* text = dump.lockBuffer(dump.size());
- char* start = text;
- while (*start != '\0') {
- char* end = strchr(start, '\n');
- if (*end == '\n') {
- *(end++) = '\0';
- }
- ALOGD("%s", start);
- start = end;
+ std::istringstream stream(dump);
+ std::string line;
+
+ while (std::getline(stream, line, '\n')) {
+ ALOGD("%s", line.c_str());
}
}
-void InputDispatcher::dumpDispatchStateLocked(String8& dump) {
- dump.appendFormat(INDENT "DispatchEnabled: %d\n", mDispatchEnabled);
- dump.appendFormat(INDENT "DispatchFrozen: %d\n", mDispatchFrozen);
+void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
+ dump += StringPrintf(INDENT "DispatchEnabled: %d\n", mDispatchEnabled);
+ dump += StringPrintf(INDENT "DispatchFrozen: %d\n", mDispatchFrozen);
if (mFocusedApplicationHandle != NULL) {
- dump.appendFormat(INDENT "FocusedApplication: name='%s', dispatchingTimeout=%0.3fms\n",
- mFocusedApplicationHandle->getName().string(),
+ dump += StringPrintf(INDENT "FocusedApplication: name='%s', dispatchingTimeout=%0.3fms\n",
+ mFocusedApplicationHandle->getName().c_str(),
mFocusedApplicationHandle->getDispatchingTimeout(
DEFAULT_INPUT_DISPATCHING_TIMEOUT) / 1000000.0);
} else {
- dump.append(INDENT "FocusedApplication: <null>\n");
+ dump += StringPrintf(INDENT "FocusedApplication: <null>\n");
}
- dump.appendFormat(INDENT "FocusedWindow: name='%s'\n",
- mFocusedWindowHandle != NULL ? mFocusedWindowHandle->getName().string() : "<null>");
+ dump += StringPrintf(INDENT "FocusedWindow: name='%s'\n",
+ mFocusedWindowHandle != NULL ? mFocusedWindowHandle->getName().c_str() : "<null>");
if (!mTouchStatesByDisplay.isEmpty()) {
- dump.appendFormat(INDENT "TouchStatesByDisplay:\n");
+ dump += StringPrintf(INDENT "TouchStatesByDisplay:\n");
for (size_t i = 0; i < mTouchStatesByDisplay.size(); i++) {
const TouchState& state = mTouchStatesByDisplay.valueAt(i);
- dump.appendFormat(INDENT2 "%d: down=%s, split=%s, deviceId=%d, source=0x%08x\n",
+ dump += StringPrintf(INDENT2 "%d: down=%s, split=%s, deviceId=%d, source=0x%08x\n",
state.displayId, toString(state.down), toString(state.split),
state.deviceId, state.source);
if (!state.windows.isEmpty()) {
- dump.append(INDENT3 "Windows:\n");
+ dump += INDENT3 "Windows:\n";
for (size_t i = 0; i < state.windows.size(); i++) {
const TouchedWindow& touchedWindow = state.windows[i];
- dump.appendFormat(INDENT4 "%zu: name='%s', pointerIds=0x%0x, targetFlags=0x%x\n",
- i, touchedWindow.windowHandle->getName().string(),
+ dump += StringPrintf(INDENT4 "%zu: name='%s', pointerIds=0x%0x, targetFlags=0x%x\n",
+ i, touchedWindow.windowHandle->getName().c_str(),
touchedWindow.pointerIds.value,
touchedWindow.targetFlags);
}
} else {
- dump.append(INDENT3 "Windows: <none>\n");
+ dump += INDENT3 "Windows: <none>\n";
}
}
} else {
- dump.append(INDENT "TouchStates: <no displays touched>\n");
+ dump += INDENT "TouchStates: <no displays touched>\n";
}
if (!mWindowHandles.isEmpty()) {
- dump.append(INDENT "Windows:\n");
+ dump += INDENT "Windows:\n";
for (size_t i = 0; i < mWindowHandles.size(); i++) {
const sp<InputWindowHandle>& windowHandle = mWindowHandles.itemAt(i);
const InputWindowInfo* windowInfo = windowHandle->getInfo();
- dump.appendFormat(INDENT2 "%zu: name='%s', displayId=%d, "
+ dump += StringPrintf(INDENT2 "%zu: name='%s', displayId=%d, "
"paused=%s, hasFocus=%s, hasWallpaper=%s, "
"visible=%s, canReceiveKeys=%s, flags=0x%08x, type=0x%08x, layer=%d, "
"frame=[%d,%d][%d,%d], scale=%f, "
"touchableRegion=",
- i, windowInfo->name.string(), windowInfo->displayId,
+ i, windowInfo->name.c_str(), windowInfo->displayId,
toString(windowInfo->paused),
toString(windowInfo->hasFocus),
toString(windowInfo->hasWallpaper),
@@ -3209,140 +3209,140 @@
windowInfo->frameRight, windowInfo->frameBottom,
windowInfo->scaleFactor);
dumpRegion(dump, windowInfo->touchableRegion);
- dump.appendFormat(", inputFeatures=0x%08x", windowInfo->inputFeatures);
- dump.appendFormat(", ownerPid=%d, ownerUid=%d, dispatchingTimeout=%0.3fms\n",
+ dump += StringPrintf(", inputFeatures=0x%08x", windowInfo->inputFeatures);
+ dump += StringPrintf(", ownerPid=%d, ownerUid=%d, dispatchingTimeout=%0.3fms\n",
windowInfo->ownerPid, windowInfo->ownerUid,
windowInfo->dispatchingTimeout / 1000000.0);
}
} else {
- dump.append(INDENT "Windows: <none>\n");
+ dump += INDENT "Windows: <none>\n";
}
if (!mMonitoringChannels.isEmpty()) {
- dump.append(INDENT "MonitoringChannels:\n");
+ dump += INDENT "MonitoringChannels:\n";
for (size_t i = 0; i < mMonitoringChannels.size(); i++) {
const sp<InputChannel>& channel = mMonitoringChannels[i];
- dump.appendFormat(INDENT2 "%zu: '%s'\n", i, channel->getName().string());
+ dump += StringPrintf(INDENT2 "%zu: '%s'\n", i, channel->getName().c_str());
}
} else {
- dump.append(INDENT "MonitoringChannels: <none>\n");
+ dump += INDENT "MonitoringChannels: <none>\n";
}
nsecs_t currentTime = now();
// Dump recently dispatched or dropped events from oldest to newest.
if (!mRecentQueue.isEmpty()) {
- dump.appendFormat(INDENT "RecentQueue: length=%u\n", mRecentQueue.count());
+ dump += StringPrintf(INDENT "RecentQueue: length=%u\n", mRecentQueue.count());
for (EventEntry* entry = mRecentQueue.head; entry; entry = entry->next) {
- dump.append(INDENT2);
+ dump += INDENT2;
entry->appendDescription(dump);
- dump.appendFormat(", age=%0.1fms\n",
+ dump += StringPrintf(", age=%0.1fms\n",
(currentTime - entry->eventTime) * 0.000001f);
}
} else {
- dump.append(INDENT "RecentQueue: <empty>\n");
+ dump += INDENT "RecentQueue: <empty>\n";
}
// Dump event currently being dispatched.
if (mPendingEvent) {
- dump.append(INDENT "PendingEvent:\n");
- dump.append(INDENT2);
+ dump += INDENT "PendingEvent:\n";
+ dump += INDENT2;
mPendingEvent->appendDescription(dump);
- dump.appendFormat(", age=%0.1fms\n",
+ dump += StringPrintf(", age=%0.1fms\n",
(currentTime - mPendingEvent->eventTime) * 0.000001f);
} else {
- dump.append(INDENT "PendingEvent: <none>\n");
+ dump += INDENT "PendingEvent: <none>\n";
}
// Dump inbound events from oldest to newest.
if (!mInboundQueue.isEmpty()) {
- dump.appendFormat(INDENT "InboundQueue: length=%u\n", mInboundQueue.count());
+ dump += StringPrintf(INDENT "InboundQueue: length=%u\n", mInboundQueue.count());
for (EventEntry* entry = mInboundQueue.head; entry; entry = entry->next) {
- dump.append(INDENT2);
+ dump += INDENT2;
entry->appendDescription(dump);
- dump.appendFormat(", age=%0.1fms\n",
+ dump += StringPrintf(", age=%0.1fms\n",
(currentTime - entry->eventTime) * 0.000001f);
}
} else {
- dump.append(INDENT "InboundQueue: <empty>\n");
+ dump += INDENT "InboundQueue: <empty>\n";
}
if (!mReplacedKeys.isEmpty()) {
- dump.append(INDENT "ReplacedKeys:\n");
+ dump += INDENT "ReplacedKeys:\n";
for (size_t i = 0; i < mReplacedKeys.size(); i++) {
const KeyReplacement& replacement = mReplacedKeys.keyAt(i);
int32_t newKeyCode = mReplacedKeys.valueAt(i);
- dump.appendFormat(INDENT2 "%zu: originalKeyCode=%d, deviceId=%d, newKeyCode=%d\n",
+ dump += StringPrintf(INDENT2 "%zu: originalKeyCode=%d, deviceId=%d, newKeyCode=%d\n",
i, replacement.keyCode, replacement.deviceId, newKeyCode);
}
} else {
- dump.append(INDENT "ReplacedKeys: <empty>\n");
+ dump += INDENT "ReplacedKeys: <empty>\n";
}
if (!mConnectionsByFd.isEmpty()) {
- dump.append(INDENT "Connections:\n");
+ dump += INDENT "Connections:\n";
for (size_t i = 0; i < mConnectionsByFd.size(); i++) {
const sp<Connection>& connection = mConnectionsByFd.valueAt(i);
- dump.appendFormat(INDENT2 "%zu: channelName='%s', windowName='%s', "
+ dump += StringPrintf(INDENT2 "%zu: channelName='%s', windowName='%s', "
"status=%s, monitor=%s, inputPublisherBlocked=%s\n",
i, connection->getInputChannelName(), connection->getWindowName(),
connection->getStatusLabel(), toString(connection->monitor),
toString(connection->inputPublisherBlocked));
if (!connection->outboundQueue.isEmpty()) {
- dump.appendFormat(INDENT3 "OutboundQueue: length=%u\n",
+ dump += StringPrintf(INDENT3 "OutboundQueue: length=%u\n",
connection->outboundQueue.count());
for (DispatchEntry* entry = connection->outboundQueue.head; entry;
entry = entry->next) {
dump.append(INDENT4);
entry->eventEntry->appendDescription(dump);
- dump.appendFormat(", targetFlags=0x%08x, resolvedAction=%d, age=%0.1fms\n",
+ dump += StringPrintf(", targetFlags=0x%08x, resolvedAction=%d, age=%0.1fms\n",
entry->targetFlags, entry->resolvedAction,
(currentTime - entry->eventEntry->eventTime) * 0.000001f);
}
} else {
- dump.append(INDENT3 "OutboundQueue: <empty>\n");
+ dump += INDENT3 "OutboundQueue: <empty>\n";
}
if (!connection->waitQueue.isEmpty()) {
- dump.appendFormat(INDENT3 "WaitQueue: length=%u\n",
+ dump += StringPrintf(INDENT3 "WaitQueue: length=%u\n",
connection->waitQueue.count());
for (DispatchEntry* entry = connection->waitQueue.head; entry;
entry = entry->next) {
- dump.append(INDENT4);
+ dump += INDENT4;
entry->eventEntry->appendDescription(dump);
- dump.appendFormat(", targetFlags=0x%08x, resolvedAction=%d, "
+ dump += StringPrintf(", targetFlags=0x%08x, resolvedAction=%d, "
"age=%0.1fms, wait=%0.1fms\n",
entry->targetFlags, entry->resolvedAction,
(currentTime - entry->eventEntry->eventTime) * 0.000001f,
(currentTime - entry->deliveryTime) * 0.000001f);
}
} else {
- dump.append(INDENT3 "WaitQueue: <empty>\n");
+ dump += INDENT3 "WaitQueue: <empty>\n";
}
}
} else {
- dump.append(INDENT "Connections: <none>\n");
+ dump += INDENT "Connections: <none>\n";
}
if (isAppSwitchPendingLocked()) {
- dump.appendFormat(INDENT "AppSwitch: pending, due in %0.1fms\n",
+ dump += StringPrintf(INDENT "AppSwitch: pending, due in %0.1fms\n",
(mAppSwitchDueTime - now()) / 1000000.0);
} else {
- dump.append(INDENT "AppSwitch: not pending\n");
+ dump += INDENT "AppSwitch: not pending\n";
}
- dump.append(INDENT "Configuration:\n");
- dump.appendFormat(INDENT2 "KeyRepeatDelay: %0.1fms\n",
+ dump += INDENT "Configuration:\n";
+ dump += StringPrintf(INDENT2 "KeyRepeatDelay: %0.1fms\n",
mConfig.keyRepeatDelay * 0.000001f);
- dump.appendFormat(INDENT2 "KeyRepeatTimeout: %0.1fms\n",
+ dump += StringPrintf(INDENT2 "KeyRepeatTimeout: %0.1fms\n",
mConfig.keyRepeatTimeout * 0.000001f);
}
status_t InputDispatcher::registerInputChannel(const sp<InputChannel>& inputChannel,
const sp<InputWindowHandle>& inputWindowHandle, bool monitor) {
#if DEBUG_REGISTRATION
- ALOGD("channel '%s' ~ registerInputChannel - monitor=%s", inputChannel->getName().string(),
+ ALOGD("channel '%s' ~ registerInputChannel - monitor=%s", inputChannel->getName().c_str(),
toString(monitor));
#endif
@@ -3351,7 +3351,7 @@
if (getConnectionIndexLocked(inputChannel) >= 0) {
ALOGW("Attempted to register already registered input channel '%s'",
- inputChannel->getName().string());
+ inputChannel->getName().c_str());
return BAD_VALUE;
}
@@ -3374,7 +3374,7 @@
status_t InputDispatcher::unregisterInputChannel(const sp<InputChannel>& inputChannel) {
#if DEBUG_REGISTRATION
- ALOGD("channel '%s' ~ unregisterInputChannel", inputChannel->getName().string());
+ ALOGD("channel '%s' ~ unregisterInputChannel", inputChannel->getName().c_str());
#endif
{ // acquire lock
@@ -3397,7 +3397,7 @@
ssize_t connectionIndex = getConnectionIndexLocked(inputChannel);
if (connectionIndex < 0) {
ALOGW("Attempted to unregister already unregistered input channel '%s'",
- inputChannel->getName().string());
+ inputChannel->getName().c_str());
return BAD_VALUE;
}
@@ -3466,7 +3466,7 @@
float waitDuration = (currentTime - waitStartTime) * 0.000001f;
ALOGI("Application is not responding: %s. "
"It has been %0.1fms since event, %0.1fms since wait started. Reason: %s",
- getApplicationWindowLabelLocked(applicationHandle, windowHandle).string(),
+ getApplicationWindowLabelLocked(applicationHandle, windowHandle).c_str(),
dispatchLatency, waitDuration, reason);
// Capture a record of the InputDispatcher state at the time of the ANR.
@@ -3476,13 +3476,13 @@
char timestr[64];
strftime(timestr, sizeof(timestr), "%F %T", &tm);
mLastANRState.clear();
- mLastANRState.append(INDENT "ANR:\n");
- mLastANRState.appendFormat(INDENT2 "Time: %s\n", timestr);
- mLastANRState.appendFormat(INDENT2 "Window: %s\n",
- getApplicationWindowLabelLocked(applicationHandle, windowHandle).string());
- mLastANRState.appendFormat(INDENT2 "DispatchLatency: %0.1fms\n", dispatchLatency);
- mLastANRState.appendFormat(INDENT2 "WaitDuration: %0.1fms\n", waitDuration);
- mLastANRState.appendFormat(INDENT2 "Reason: %s\n", reason);
+ mLastANRState += INDENT "ANR:\n";
+ mLastANRState += StringPrintf(INDENT2 "Time: %s\n", timestr);
+ mLastANRState += StringPrintf(INDENT2 "Window: %s\n",
+ getApplicationWindowLabelLocked(applicationHandle, windowHandle).c_str());
+ mLastANRState += StringPrintf(INDENT2 "DispatchLatency: %0.1fms\n", dispatchLatency);
+ mLastANRState += StringPrintf(INDENT2 "WaitDuration: %0.1fms\n", waitDuration);
+ mLastANRState += StringPrintf(INDENT2 "Reason: %s\n", reason);
dumpDispatchStateLocked(mLastANRState);
CommandEntry* commandEntry = postCommandLocked(
@@ -3566,11 +3566,11 @@
if (dispatchEntry) {
nsecs_t eventDuration = finishTime - dispatchEntry->deliveryTime;
if (eventDuration > SLOW_EVENT_PROCESSING_WARNING_TIMEOUT) {
- String8 msg;
- msg.appendFormat("Window '%s' spent %0.1fms processing the last input event: ",
+ std::string msg =
+ StringPrintf("Window '%s' spent %0.1fms processing the last input event: ",
connection->getWindowName(), eventDuration * 0.000001f);
dispatchEntry->eventEntry->appendDescription(msg);
- ALOGI("%s", msg.string());
+ ALOGI("%s", msg.c_str());
}
bool restartEvent;
@@ -3737,15 +3737,15 @@
#if DEBUG_OUTBOUND_EVENT_DETAILS
{
- String8 msg;
+ std::string msg;
const KeyedVector<int32_t, int32_t>& fallbackKeys =
connection->inputState.getFallbackKeys();
for (size_t i = 0; i < fallbackKeys.size(); i++) {
- msg.appendFormat(", %d->%d", fallbackKeys.keyAt(i),
+ msg += StringPrintf(", %d->%d", fallbackKeys.keyAt(i),
fallbackKeys.valueAt(i));
}
ALOGD("Unhandled key event: %zu currently tracked fallback keys%s.",
- fallbackKeys.size(), msg.string());
+ fallbackKeys.size(), msg.c_str());
}
#endif
@@ -3824,15 +3824,15 @@
}
}
-void InputDispatcher::dump(String8& dump) {
+void InputDispatcher::dump(std::string& dump) {
AutoMutex _l(mLock);
- dump.append("Input Dispatcher State:\n");
+ dump += "Input Dispatcher State:\n";
dumpDispatchStateLocked(dump);
- if (!mLastANRState.isEmpty()) {
- dump.append("\nInput Dispatcher State at time of last ANR:\n");
- dump.append(mLastANRState);
+ if (!mLastANRState.empty()) {
+ dump += "\nInput Dispatcher State at time of last ANR:\n";
+ dump += mLastANRState;
}
}
@@ -3904,9 +3904,8 @@
InputDispatcher::ConfigurationChangedEntry::~ConfigurationChangedEntry() {
}
-void InputDispatcher::ConfigurationChangedEntry::appendDescription(String8& msg) const {
- msg.append("ConfigurationChangedEvent(), policyFlags=0x%08x",
- policyFlags);
+void InputDispatcher::ConfigurationChangedEntry::appendDescription(std::string& msg) const {
+ msg += StringPrintf("ConfigurationChangedEvent(), policyFlags=0x%08x", policyFlags);
}
@@ -3920,8 +3919,8 @@
InputDispatcher::DeviceResetEntry::~DeviceResetEntry() {
}
-void InputDispatcher::DeviceResetEntry::appendDescription(String8& msg) const {
- msg.appendFormat("DeviceResetEvent(deviceId=%d), policyFlags=0x%08x",
+void InputDispatcher::DeviceResetEntry::appendDescription(std::string& msg) const {
+ msg += StringPrintf("DeviceResetEvent(deviceId=%d), policyFlags=0x%08x",
deviceId, policyFlags);
}
@@ -3943,8 +3942,8 @@
InputDispatcher::KeyEntry::~KeyEntry() {
}
-void InputDispatcher::KeyEntry::appendDescription(String8& msg) const {
- msg.appendFormat("KeyEvent(deviceId=%d, source=0x%08x, action=%d, "
+void InputDispatcher::KeyEntry::appendDescription(std::string& msg) const {
+ msg += StringPrintf("KeyEvent(deviceId=%d, source=0x%08x, action=%d, "
"flags=0x%08x, keyCode=%d, scanCode=%d, metaState=0x%08x, "
"repeatCount=%d), policyFlags=0x%08x",
deviceId, source, action, flags, keyCode, scanCode, metaState,
@@ -3988,20 +3987,20 @@
InputDispatcher::MotionEntry::~MotionEntry() {
}
-void InputDispatcher::MotionEntry::appendDescription(String8& msg) const {
- msg.appendFormat("MotionEvent(deviceId=%d, source=0x%08x, action=%d, actionButton=0x%08x, "
+void InputDispatcher::MotionEntry::appendDescription(std::string& msg) const {
+ msg += StringPrintf("MotionEvent(deviceId=%d, source=0x%08x, action=%d, actionButton=0x%08x, "
"flags=0x%08x, metaState=0x%08x, buttonState=0x%08x, "
"edgeFlags=0x%08x, xPrecision=%.1f, yPrecision=%.1f, displayId=%d, pointers=[",
deviceId, source, action, actionButton, flags, metaState, buttonState, edgeFlags,
xPrecision, yPrecision, displayId);
for (uint32_t i = 0; i < pointerCount; i++) {
if (i) {
- msg.append(", ");
+ msg += ", ";
}
- msg.appendFormat("%d: (%.1f, %.1f)", pointerProperties[i].id,
+ msg += StringPrintf("%d: (%.1f, %.1f)", pointerProperties[i].id,
pointerCoords[i].getX(), pointerCoords[i].getY());
}
- msg.appendFormat("]), policyFlags=0x%08x", policyFlags);
+ msg += StringPrintf("]), policyFlags=0x%08x", policyFlags);
}
@@ -4400,7 +4399,7 @@
const char* InputDispatcher::Connection::getWindowName() const {
if (inputWindowHandle != NULL) {
- return inputWindowHandle->getName().string();
+ return inputWindowHandle->getName().c_str();
}
if (monitor) {
return "monitor";
diff --git a/services/inputflinger/InputDispatcher.h b/services/inputflinger/InputDispatcher.h
index 90c69ce..92b3a9c 100644
--- a/services/inputflinger/InputDispatcher.h
+++ b/services/inputflinger/InputDispatcher.h
@@ -24,7 +24,6 @@
#include <utils/threads.h>
#include <utils/Timers.h>
#include <utils/RefBase.h>
-#include <utils/String8.h>
#include <utils/Looper.h>
#include <utils/BitSet.h>
#include <cutils/atomic.h>
@@ -209,7 +208,7 @@
* Returns a new timeout to continue waiting, or 0 to abort dispatch. */
virtual nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
const sp<InputWindowHandle>& inputWindowHandle,
- const String8& reason) = 0;
+ const std::string& reason) = 0;
/* Notifies the system that an input channel is unrecoverably broken. */
virtual void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle) = 0;
@@ -281,7 +280,7 @@
/* Dumps the state of the input dispatcher.
*
* This method may be called on any thread (usually by the input manager). */
- virtual void dump(String8& dump) = 0;
+ virtual void dump(std::string& dump) = 0;
/* Called by the heatbeat to ensures that the dispatcher has not deadlocked. */
virtual void monitor() = 0;
@@ -373,7 +372,7 @@
public:
explicit InputDispatcher(const sp<InputDispatcherPolicyInterface>& policy);
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
virtual void monitor();
virtual void dispatchOnce();
@@ -446,7 +445,7 @@
void release();
- virtual void appendDescription(String8& msg) const = 0;
+ virtual void appendDescription(std::string& msg) const = 0;
protected:
EventEntry(int32_t type, nsecs_t eventTime, uint32_t policyFlags);
@@ -456,7 +455,7 @@
struct ConfigurationChangedEntry : EventEntry {
explicit ConfigurationChangedEntry(nsecs_t eventTime);
- virtual void appendDescription(String8& msg) const;
+ virtual void appendDescription(std::string& msg) const;
protected:
virtual ~ConfigurationChangedEntry();
@@ -466,7 +465,7 @@
int32_t deviceId;
DeviceResetEntry(nsecs_t eventTime, int32_t deviceId);
- virtual void appendDescription(String8& msg) const;
+ virtual void appendDescription(std::string& msg) const;
protected:
virtual ~DeviceResetEntry();
@@ -498,7 +497,7 @@
int32_t deviceId, uint32_t source, uint32_t policyFlags, int32_t action,
int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
int32_t repeatCount, nsecs_t downTime);
- virtual void appendDescription(String8& msg) const;
+ virtual void appendDescription(std::string& msg) const;
void recycle();
protected:
@@ -531,7 +530,7 @@
int32_t displayId, uint32_t pointerCount,
const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
float xOffset, float yOffset);
- virtual void appendDescription(String8& msg) const;
+ virtual void appendDescription(std::string& msg) const;
protected:
virtual ~MotionEntry();
@@ -602,7 +601,7 @@
KeyEntry* keyEntry;
sp<InputApplicationHandle> inputApplicationHandle;
sp<InputWindowHandle> inputWindowHandle;
- String8 reason;
+ std::string reason;
int32_t userActivityEventType;
uint32_t seq;
bool handled;
@@ -832,7 +831,7 @@
explicit Connection(const sp<InputChannel>& inputChannel,
const sp<InputWindowHandle>& inputWindowHandle, bool monitor);
- inline const char* getInputChannelName() const { return inputChannel->getName().string(); }
+ inline const char* getInputChannelName() const { return inputChannel->getName().c_str(); }
const char* getWindowName() const;
const char* getStatusLabel() const;
@@ -994,7 +993,7 @@
sp<InputApplicationHandle> mFocusedApplicationHandle;
// Dispatcher state at time of last ANR.
- String8 mLastANRState;
+ std::string mLastANRState;
// Dispatch inbound events.
bool dispatchConfigurationChangedLocked(
@@ -1055,10 +1054,10 @@
bool isWindowObscuredAtPointLocked(const sp<InputWindowHandle>& windowHandle,
int32_t x, int32_t y) const;
bool isWindowObscuredLocked(const sp<InputWindowHandle>& windowHandle) const;
- String8 getApplicationWindowLabelLocked(const sp<InputApplicationHandle>& applicationHandle,
+ std::string getApplicationWindowLabelLocked(const sp<InputApplicationHandle>& applicationHandle,
const sp<InputWindowHandle>& windowHandle);
- String8 checkWindowReadyForMoreInputLocked(nsecs_t currentTime,
+ std::string checkWindowReadyForMoreInputLocked(nsecs_t currentTime,
const sp<InputWindowHandle>& windowHandle, const EventEntry* eventEntry,
const char* targetType);
@@ -1096,7 +1095,7 @@
void resetAndDropEverythingLocked(const char* reason);
// Dump state.
- void dumpDispatchStateLocked(String8& dump);
+ void dumpDispatchStateLocked(std::string& dump);
void logDispatchStateLocked();
// Registration.
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
index 591f8d7..e398a84 100644
--- a/services/inputflinger/InputReader.cpp
+++ b/services/inputflinger/InputReader.cpp
@@ -54,6 +54,7 @@
#include <log/log.h>
+#include <android-base/stringprintf.h>
#include <input/Keyboard.h>
#include <input/VirtualKeyMap.h>
@@ -63,6 +64,8 @@
#define INDENT4 " "
#define INDENT5 " "
+using android::base::StringPrintf;
+
namespace android {
// --- Constants ---
@@ -290,19 +293,19 @@
mVirtualDisplays = viewports;
}
-void InputReaderConfiguration::dump(String8& dump) const {
- dump.append(INDENT4 "ViewportInternal:\n");
+void InputReaderConfiguration::dump(std::string& dump) const {
+ dump += INDENT4 "ViewportInternal:\n";
dumpViewport(dump, mInternalDisplay);
- dump.append(INDENT4 "ViewportExternal:\n");
+ dump += INDENT4 "ViewportExternal:\n";
dumpViewport(dump, mExternalDisplay);
- dump.append(INDENT4 "ViewportVirtual:\n");
+ dump += INDENT4 "ViewportVirtual:\n";
for (const DisplayViewport& viewport : mVirtualDisplays) {
dumpViewport(dump, viewport);
}
}
-void InputReaderConfiguration::dumpViewport(String8& dump, const DisplayViewport& viewport) const {
- dump.appendFormat(INDENT5 "Viewport: displayId=%d, orientation=%d, uniqueId='%s', "
+void InputReaderConfiguration::dumpViewport(std::string& dump, const DisplayViewport& viewport) const {
+ dump += StringPrintf(INDENT5 "Viewport: displayId=%d, orientation=%d, uniqueId='%s', "
"logicalFrame=[%d, %d, %d, %d], "
"physicalFrame=[%d, %d, %d, %d], "
"deviceSize=[%d, %d]\n",
@@ -873,71 +876,71 @@
return false;
}
-void InputReader::dump(String8& dump) {
+void InputReader::dump(std::string& dump) {
AutoMutex _l(mLock);
mEventHub->dump(dump);
- dump.append("\n");
+ dump += "\n";
- dump.append("Input Reader State:\n");
+ dump += "Input Reader State:\n";
for (size_t i = 0; i < mDevices.size(); i++) {
mDevices.valueAt(i)->dump(dump);
}
- dump.append(INDENT "Configuration:\n");
- dump.append(INDENT2 "ExcludedDeviceNames: [");
+ dump += INDENT "Configuration:\n";
+ dump += INDENT2 "ExcludedDeviceNames: [";
for (size_t i = 0; i < mConfig.excludedDeviceNames.size(); i++) {
if (i != 0) {
- dump.append(", ");
+ dump += ", ";
}
- dump.append(mConfig.excludedDeviceNames.itemAt(i).string());
+ dump += mConfig.excludedDeviceNames.itemAt(i).string();
}
- dump.append("]\n");
- dump.appendFormat(INDENT2 "VirtualKeyQuietTime: %0.1fms\n",
+ dump += "]\n";
+ dump += StringPrintf(INDENT2 "VirtualKeyQuietTime: %0.1fms\n",
mConfig.virtualKeyQuietTime * 0.000001f);
- dump.appendFormat(INDENT2 "PointerVelocityControlParameters: "
+ dump += StringPrintf(INDENT2 "PointerVelocityControlParameters: "
"scale=%0.3f, lowThreshold=%0.3f, highThreshold=%0.3f, acceleration=%0.3f\n",
mConfig.pointerVelocityControlParameters.scale,
mConfig.pointerVelocityControlParameters.lowThreshold,
mConfig.pointerVelocityControlParameters.highThreshold,
mConfig.pointerVelocityControlParameters.acceleration);
- dump.appendFormat(INDENT2 "WheelVelocityControlParameters: "
+ dump += StringPrintf(INDENT2 "WheelVelocityControlParameters: "
"scale=%0.3f, lowThreshold=%0.3f, highThreshold=%0.3f, acceleration=%0.3f\n",
mConfig.wheelVelocityControlParameters.scale,
mConfig.wheelVelocityControlParameters.lowThreshold,
mConfig.wheelVelocityControlParameters.highThreshold,
mConfig.wheelVelocityControlParameters.acceleration);
- dump.appendFormat(INDENT2 "PointerGesture:\n");
- dump.appendFormat(INDENT3 "Enabled: %s\n",
+ dump += StringPrintf(INDENT2 "PointerGesture:\n");
+ dump += StringPrintf(INDENT3 "Enabled: %s\n",
toString(mConfig.pointerGesturesEnabled));
- dump.appendFormat(INDENT3 "QuietInterval: %0.1fms\n",
+ dump += StringPrintf(INDENT3 "QuietInterval: %0.1fms\n",
mConfig.pointerGestureQuietInterval * 0.000001f);
- dump.appendFormat(INDENT3 "DragMinSwitchSpeed: %0.1fpx/s\n",
+ dump += StringPrintf(INDENT3 "DragMinSwitchSpeed: %0.1fpx/s\n",
mConfig.pointerGestureDragMinSwitchSpeed);
- dump.appendFormat(INDENT3 "TapInterval: %0.1fms\n",
+ dump += StringPrintf(INDENT3 "TapInterval: %0.1fms\n",
mConfig.pointerGestureTapInterval * 0.000001f);
- dump.appendFormat(INDENT3 "TapDragInterval: %0.1fms\n",
+ dump += StringPrintf(INDENT3 "TapDragInterval: %0.1fms\n",
mConfig.pointerGestureTapDragInterval * 0.000001f);
- dump.appendFormat(INDENT3 "TapSlop: %0.1fpx\n",
+ dump += StringPrintf(INDENT3 "TapSlop: %0.1fpx\n",
mConfig.pointerGestureTapSlop);
- dump.appendFormat(INDENT3 "MultitouchSettleInterval: %0.1fms\n",
+ dump += StringPrintf(INDENT3 "MultitouchSettleInterval: %0.1fms\n",
mConfig.pointerGestureMultitouchSettleInterval * 0.000001f);
- dump.appendFormat(INDENT3 "MultitouchMinDistance: %0.1fpx\n",
+ dump += StringPrintf(INDENT3 "MultitouchMinDistance: %0.1fpx\n",
mConfig.pointerGestureMultitouchMinDistance);
- dump.appendFormat(INDENT3 "SwipeTransitionAngleCosine: %0.1f\n",
+ dump += StringPrintf(INDENT3 "SwipeTransitionAngleCosine: %0.1f\n",
mConfig.pointerGestureSwipeTransitionAngleCosine);
- dump.appendFormat(INDENT3 "SwipeMaxWidthRatio: %0.1f\n",
+ dump += StringPrintf(INDENT3 "SwipeMaxWidthRatio: %0.1f\n",
mConfig.pointerGestureSwipeMaxWidthRatio);
- dump.appendFormat(INDENT3 "MovementSpeedRatio: %0.1f\n",
+ dump += StringPrintf(INDENT3 "MovementSpeedRatio: %0.1f\n",
mConfig.pointerGestureMovementSpeedRatio);
- dump.appendFormat(INDENT3 "ZoomSpeedRatio: %0.1f\n",
+ dump += StringPrintf(INDENT3 "ZoomSpeedRatio: %0.1f\n",
mConfig.pointerGestureZoomSpeedRatio);
- dump.append(INDENT3 "Viewports:\n");
+ dump += INDENT3 "Viewports:\n";
mConfig.dump(dump);
}
@@ -1069,21 +1072,21 @@
bumpGeneration();
}
-void InputDevice::dump(String8& dump) {
+void InputDevice::dump(std::string& dump) {
InputDeviceInfo deviceInfo;
getDeviceInfo(& deviceInfo);
- dump.appendFormat(INDENT "Device %d: %s\n", deviceInfo.getId(),
+ dump += StringPrintf(INDENT "Device %d: %s\n", deviceInfo.getId(),
deviceInfo.getDisplayName().string());
- dump.appendFormat(INDENT2 "Generation: %d\n", mGeneration);
- dump.appendFormat(INDENT2 "IsExternal: %s\n", toString(mIsExternal));
- dump.appendFormat(INDENT2 "HasMic: %s\n", toString(mHasMic));
- dump.appendFormat(INDENT2 "Sources: 0x%08x\n", deviceInfo.getSources());
- dump.appendFormat(INDENT2 "KeyboardType: %d\n", deviceInfo.getKeyboardType());
+ dump += StringPrintf(INDENT2 "Generation: %d\n", mGeneration);
+ dump += StringPrintf(INDENT2 "IsExternal: %s\n", toString(mIsExternal));
+ dump += StringPrintf(INDENT2 "HasMic: %s\n", toString(mHasMic));
+ dump += StringPrintf(INDENT2 "Sources: 0x%08x\n", deviceInfo.getSources());
+ dump += StringPrintf(INDENT2 "KeyboardType: %d\n", deviceInfo.getKeyboardType());
const Vector<InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges();
if (!ranges.isEmpty()) {
- dump.append(INDENT2 "Motion Ranges:\n");
+ dump += INDENT2 "Motion Ranges:\n";
for (size_t i = 0; i < ranges.size(); i++) {
const InputDeviceInfo::MotionRange& range = ranges.itemAt(i);
const char* label = getAxisLabel(range.axis);
@@ -1094,7 +1097,7 @@
} else {
snprintf(name, sizeof(name), "%d", range.axis);
}
- dump.appendFormat(INDENT3 "%s: source=0x%08x, "
+ dump += StringPrintf(INDENT3 "%s: source=0x%08x, "
"min=%0.3f, max=%0.3f, flat=%0.3f, fuzz=%0.3f, resolution=%0.3f\n",
name, range.source, range.min, range.max, range.flat, range.fuzz,
range.resolution);
@@ -1982,7 +1985,7 @@
info->addSource(getSources());
}
-void InputMapper::dump(String8& dump) {
+void InputMapper::dump(std::string& dump) {
}
void InputMapper::configure(nsecs_t when,
@@ -2044,21 +2047,21 @@
mDevice->bumpGeneration();
}
-void InputMapper::dumpRawAbsoluteAxisInfo(String8& dump,
+void InputMapper::dumpRawAbsoluteAxisInfo(std::string& dump,
const RawAbsoluteAxisInfo& axis, const char* name) {
if (axis.valid) {
- dump.appendFormat(INDENT4 "%s: min=%d, max=%d, flat=%d, fuzz=%d, resolution=%d\n",
+ dump += StringPrintf(INDENT4 "%s: min=%d, max=%d, flat=%d, fuzz=%d, resolution=%d\n",
name, axis.minValue, axis.maxValue, axis.flat, axis.fuzz, axis.resolution);
} else {
- dump.appendFormat(INDENT4 "%s: unknown range\n", name);
+ dump += StringPrintf(INDENT4 "%s: unknown range\n", name);
}
}
-void InputMapper::dumpStylusState(String8& dump, const StylusState& state) {
- dump.appendFormat(INDENT4 "When: %" PRId64 "\n", state.when);
- dump.appendFormat(INDENT4 "Pressure: %f\n", state.pressure);
- dump.appendFormat(INDENT4 "Button State: 0x%08x\n", state.buttons);
- dump.appendFormat(INDENT4 "Tool Type: %" PRId32 "\n", state.toolType);
+void InputMapper::dumpStylusState(std::string& dump, const StylusState& state) {
+ dump += StringPrintf(INDENT4 "When: %" PRId64 "\n", state.when);
+ dump += StringPrintf(INDENT4 "Pressure: %f\n", state.pressure);
+ dump += StringPrintf(INDENT4 "Button State: 0x%08x\n", state.buttons);
+ dump += StringPrintf(INDENT4 "Tool Type: %" PRId32 "\n", state.toolType);
}
// --- SwitchInputMapper ---
@@ -2112,9 +2115,9 @@
return getEventHub()->getSwitchState(getDeviceId(), switchCode);
}
-void SwitchInputMapper::dump(String8& dump) {
- dump.append(INDENT2 "Switch Input Mapper:\n");
- dump.appendFormat(INDENT3 "SwitchValues: %x\n", mSwitchValues);
+void SwitchInputMapper::dump(std::string& dump) {
+ dump += INDENT2 "Switch Input Mapper:\n";
+ dump += StringPrintf(INDENT3 "SwitchValues: %x\n", mSwitchValues);
}
// --- VibratorInputMapper ---
@@ -2143,15 +2146,15 @@
void VibratorInputMapper::vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t repeat,
int32_t token) {
#if DEBUG_VIBRATOR
- String8 patternStr;
+ std::string patternStr;
for (size_t i = 0; i < patternSize; i++) {
if (i != 0) {
- patternStr.append(", ");
+ patternStr += ", ";
}
- patternStr.appendFormat("%" PRId64, pattern[i]);
+ patternStr += StringPrintf("%" PRId64, pattern[i]);
}
ALOGD("vibrate: deviceId=%d, pattern=[%s], repeat=%zd, token=%d",
- getDeviceId(), patternStr.string(), repeat, token);
+ getDeviceId(), patternStr.c_str(), repeat, token);
#endif
mVibrating = true;
@@ -2224,9 +2227,9 @@
getEventHub()->cancelVibrate(getDeviceId());
}
-void VibratorInputMapper::dump(String8& dump) {
- dump.append(INDENT2 "Vibrator Input Mapper:\n");
- dump.appendFormat(INDENT3 "Vibrating: %s\n", toString(mVibrating));
+void VibratorInputMapper::dump(std::string& dump) {
+ dump += INDENT2 "Vibrator Input Mapper:\n";
+ dump += StringPrintf(INDENT3 "Vibrating: %s\n", toString(mVibrating));
}
@@ -2252,14 +2255,14 @@
info->setKeyCharacterMap(getEventHub()->getKeyCharacterMap(getDeviceId()));
}
-void KeyboardInputMapper::dump(String8& dump) {
- dump.append(INDENT2 "Keyboard Input Mapper:\n");
+void KeyboardInputMapper::dump(std::string& dump) {
+ dump += INDENT2 "Keyboard Input Mapper:\n";
dumpParameters(dump);
- dump.appendFormat(INDENT3 "KeyboardType: %d\n", mKeyboardType);
- dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation);
- dump.appendFormat(INDENT3 "KeyDowns: %zu keys currently down\n", mKeyDowns.size());
- dump.appendFormat(INDENT3 "MetaState: 0x%0x\n", mMetaState);
- dump.appendFormat(INDENT3 "DownTime: %" PRId64 "\n", mDownTime);
+ dump += StringPrintf(INDENT3 "KeyboardType: %d\n", mKeyboardType);
+ dump += StringPrintf(INDENT3 "Orientation: %d\n", mOrientation);
+ dump += StringPrintf(INDENT3 "KeyDowns: %zu keys currently down\n", mKeyDowns.size());
+ dump += StringPrintf(INDENT3 "MetaState: 0x%0x\n", mMetaState);
+ dump += StringPrintf(INDENT3 "DownTime: %" PRId64 "\n", mDownTime);
}
@@ -2319,13 +2322,13 @@
mParameters.handlesKeyRepeat);
}
-void KeyboardInputMapper::dumpParameters(String8& dump) {
- dump.append(INDENT3 "Parameters:\n");
- dump.appendFormat(INDENT4 "HasAssociatedDisplay: %s\n",
+void KeyboardInputMapper::dumpParameters(std::string& dump) {
+ dump += INDENT3 "Parameters:\n";
+ dump += StringPrintf(INDENT4 "HasAssociatedDisplay: %s\n",
toString(mParameters.hasAssociatedDisplay));
- dump.appendFormat(INDENT4 "OrientationAware: %s\n",
+ dump += StringPrintf(INDENT4 "OrientationAware: %s\n",
toString(mParameters.orientationAware));
- dump.appendFormat(INDENT4 "HandlesKeyRepeat: %s\n",
+ dump += StringPrintf(INDENT4 "HandlesKeyRepeat: %s\n",
toString(mParameters.handlesKeyRepeat));
}
@@ -2604,23 +2607,23 @@
}
}
-void CursorInputMapper::dump(String8& dump) {
- dump.append(INDENT2 "Cursor Input Mapper:\n");
+void CursorInputMapper::dump(std::string& dump) {
+ dump += INDENT2 "Cursor Input Mapper:\n";
dumpParameters(dump);
- dump.appendFormat(INDENT3 "XScale: %0.3f\n", mXScale);
- dump.appendFormat(INDENT3 "YScale: %0.3f\n", mYScale);
- dump.appendFormat(INDENT3 "XPrecision: %0.3f\n", mXPrecision);
- dump.appendFormat(INDENT3 "YPrecision: %0.3f\n", mYPrecision);
- dump.appendFormat(INDENT3 "HaveVWheel: %s\n",
+ dump += StringPrintf(INDENT3 "XScale: %0.3f\n", mXScale);
+ dump += StringPrintf(INDENT3 "YScale: %0.3f\n", mYScale);
+ dump += StringPrintf(INDENT3 "XPrecision: %0.3f\n", mXPrecision);
+ dump += StringPrintf(INDENT3 "YPrecision: %0.3f\n", mYPrecision);
+ dump += StringPrintf(INDENT3 "HaveVWheel: %s\n",
toString(mCursorScrollAccumulator.haveRelativeVWheel()));
- dump.appendFormat(INDENT3 "HaveHWheel: %s\n",
+ dump += StringPrintf(INDENT3 "HaveHWheel: %s\n",
toString(mCursorScrollAccumulator.haveRelativeHWheel()));
- dump.appendFormat(INDENT3 "VWheelScale: %0.3f\n", mVWheelScale);
- dump.appendFormat(INDENT3 "HWheelScale: %0.3f\n", mHWheelScale);
- dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation);
- dump.appendFormat(INDENT3 "ButtonState: 0x%08x\n", mButtonState);
- dump.appendFormat(INDENT3 "Down: %s\n", toString(isPointerDown(mButtonState)));
- dump.appendFormat(INDENT3 "DownTime: %" PRId64 "\n", mDownTime);
+ dump += StringPrintf(INDENT3 "VWheelScale: %0.3f\n", mVWheelScale);
+ dump += StringPrintf(INDENT3 "HWheelScale: %0.3f\n", mHWheelScale);
+ dump += StringPrintf(INDENT3 "Orientation: %d\n", mOrientation);
+ dump += StringPrintf(INDENT3 "ButtonState: 0x%08x\n", mButtonState);
+ dump += StringPrintf(INDENT3 "Down: %s\n", toString(isPointerDown(mButtonState)));
+ dump += StringPrintf(INDENT3 "DownTime: %" PRId64 "\n", mDownTime);
}
void CursorInputMapper::configure(nsecs_t when,
@@ -2728,26 +2731,26 @@
}
}
-void CursorInputMapper::dumpParameters(String8& dump) {
- dump.append(INDENT3 "Parameters:\n");
- dump.appendFormat(INDENT4 "HasAssociatedDisplay: %s\n",
+void CursorInputMapper::dumpParameters(std::string& dump) {
+ dump += INDENT3 "Parameters:\n";
+ dump += StringPrintf(INDENT4 "HasAssociatedDisplay: %s\n",
toString(mParameters.hasAssociatedDisplay));
switch (mParameters.mode) {
case Parameters::MODE_POINTER:
- dump.append(INDENT4 "Mode: pointer\n");
+ dump += INDENT4 "Mode: pointer\n";
break;
case Parameters::MODE_POINTER_RELATIVE:
- dump.append(INDENT4 "Mode: relative pointer\n");
+ dump += INDENT4 "Mode: relative pointer\n";
break;
case Parameters::MODE_NAVIGATION:
- dump.append(INDENT4 "Mode: navigation\n");
+ dump += INDENT4 "Mode: navigation\n";
break;
default:
ALOG_ASSERT(false);
}
- dump.appendFormat(INDENT4 "OrientationAware: %s\n",
+ dump += StringPrintf(INDENT4 "OrientationAware: %s\n",
toString(mParameters.orientationAware));
}
@@ -3000,9 +3003,9 @@
}
}
-void RotaryEncoderInputMapper::dump(String8& dump) {
- dump.append(INDENT2 "Rotary Encoder Input Mapper:\n");
- dump.appendFormat(INDENT3 "HaveWheel: %s\n",
+void RotaryEncoderInputMapper::dump(std::string& dump) {
+ dump += INDENT2 "Rotary Encoder Input Mapper:\n";
+ dump += StringPrintf(INDENT3 "HaveWheel: %s\n",
toString(mRotaryEncoderScrollAccumulator.haveRelativeVWheel()));
}
@@ -3151,8 +3154,8 @@
}
}
-void TouchInputMapper::dump(String8& dump) {
- dump.appendFormat(INDENT2 "Touch Input Mapper (mode - %s):\n", modeToString(mDeviceMode));
+void TouchInputMapper::dump(std::string& dump) {
+ dump += StringPrintf(INDENT2 "Touch Input Mapper (mode - %s):\n", modeToString(mDeviceMode));
dumpParameters(dump);
dumpVirtualKeys(dump);
dumpRawPointerAxes(dump);
@@ -3160,30 +3163,30 @@
dumpAffineTransformation(dump);
dumpSurface(dump);
- dump.appendFormat(INDENT3 "Translation and Scaling Factors:\n");
- dump.appendFormat(INDENT4 "XTranslate: %0.3f\n", mXTranslate);
- dump.appendFormat(INDENT4 "YTranslate: %0.3f\n", mYTranslate);
- dump.appendFormat(INDENT4 "XScale: %0.3f\n", mXScale);
- dump.appendFormat(INDENT4 "YScale: %0.3f\n", mYScale);
- dump.appendFormat(INDENT4 "XPrecision: %0.3f\n", mXPrecision);
- dump.appendFormat(INDENT4 "YPrecision: %0.3f\n", mYPrecision);
- dump.appendFormat(INDENT4 "GeometricScale: %0.3f\n", mGeometricScale);
- dump.appendFormat(INDENT4 "PressureScale: %0.3f\n", mPressureScale);
- dump.appendFormat(INDENT4 "SizeScale: %0.3f\n", mSizeScale);
- dump.appendFormat(INDENT4 "OrientationScale: %0.3f\n", mOrientationScale);
- dump.appendFormat(INDENT4 "DistanceScale: %0.3f\n", mDistanceScale);
- dump.appendFormat(INDENT4 "HaveTilt: %s\n", toString(mHaveTilt));
- dump.appendFormat(INDENT4 "TiltXCenter: %0.3f\n", mTiltXCenter);
- dump.appendFormat(INDENT4 "TiltXScale: %0.3f\n", mTiltXScale);
- dump.appendFormat(INDENT4 "TiltYCenter: %0.3f\n", mTiltYCenter);
- dump.appendFormat(INDENT4 "TiltYScale: %0.3f\n", mTiltYScale);
+ dump += StringPrintf(INDENT3 "Translation and Scaling Factors:\n");
+ dump += StringPrintf(INDENT4 "XTranslate: %0.3f\n", mXTranslate);
+ dump += StringPrintf(INDENT4 "YTranslate: %0.3f\n", mYTranslate);
+ dump += StringPrintf(INDENT4 "XScale: %0.3f\n", mXScale);
+ dump += StringPrintf(INDENT4 "YScale: %0.3f\n", mYScale);
+ dump += StringPrintf(INDENT4 "XPrecision: %0.3f\n", mXPrecision);
+ dump += StringPrintf(INDENT4 "YPrecision: %0.3f\n", mYPrecision);
+ dump += StringPrintf(INDENT4 "GeometricScale: %0.3f\n", mGeometricScale);
+ dump += StringPrintf(INDENT4 "PressureScale: %0.3f\n", mPressureScale);
+ dump += StringPrintf(INDENT4 "SizeScale: %0.3f\n", mSizeScale);
+ dump += StringPrintf(INDENT4 "OrientationScale: %0.3f\n", mOrientationScale);
+ dump += StringPrintf(INDENT4 "DistanceScale: %0.3f\n", mDistanceScale);
+ dump += StringPrintf(INDENT4 "HaveTilt: %s\n", toString(mHaveTilt));
+ dump += StringPrintf(INDENT4 "TiltXCenter: %0.3f\n", mTiltXCenter);
+ dump += StringPrintf(INDENT4 "TiltXScale: %0.3f\n", mTiltXScale);
+ dump += StringPrintf(INDENT4 "TiltYCenter: %0.3f\n", mTiltYCenter);
+ dump += StringPrintf(INDENT4 "TiltYScale: %0.3f\n", mTiltYScale);
- dump.appendFormat(INDENT3 "Last Raw Button State: 0x%08x\n", mLastRawState.buttonState);
- dump.appendFormat(INDENT3 "Last Raw Touch: pointerCount=%d\n",
+ dump += StringPrintf(INDENT3 "Last Raw Button State: 0x%08x\n", mLastRawState.buttonState);
+ dump += StringPrintf(INDENT3 "Last Raw Touch: pointerCount=%d\n",
mLastRawState.rawPointerData.pointerCount);
for (uint32_t i = 0; i < mLastRawState.rawPointerData.pointerCount; i++) {
const RawPointerData::Pointer& pointer = mLastRawState.rawPointerData.pointers[i];
- dump.appendFormat(INDENT4 "[%d]: id=%d, x=%d, y=%d, pressure=%d, "
+ dump += StringPrintf(INDENT4 "[%d]: id=%d, x=%d, y=%d, pressure=%d, "
"touchMajor=%d, touchMinor=%d, toolMajor=%d, toolMinor=%d, "
"orientation=%d, tiltX=%d, tiltY=%d, distance=%d, "
"toolType=%d, isHovering=%s\n", i,
@@ -3194,14 +3197,14 @@
pointer.toolType, toString(pointer.isHovering));
}
- dump.appendFormat(INDENT3 "Last Cooked Button State: 0x%08x\n", mLastCookedState.buttonState);
- dump.appendFormat(INDENT3 "Last Cooked Touch: pointerCount=%d\n",
+ dump += StringPrintf(INDENT3 "Last Cooked Button State: 0x%08x\n", mLastCookedState.buttonState);
+ dump += StringPrintf(INDENT3 "Last Cooked Touch: pointerCount=%d\n",
mLastCookedState.cookedPointerData.pointerCount);
for (uint32_t i = 0; i < mLastCookedState.cookedPointerData.pointerCount; i++) {
const PointerProperties& pointerProperties =
mLastCookedState.cookedPointerData.pointerProperties[i];
const PointerCoords& pointerCoords = mLastCookedState.cookedPointerData.pointerCoords[i];
- dump.appendFormat(INDENT4 "[%d]: id=%d, x=%0.3f, y=%0.3f, pressure=%0.3f, "
+ dump += StringPrintf(INDENT4 "[%d]: id=%d, x=%0.3f, y=%0.3f, pressure=%0.3f, "
"touchMajor=%0.3f, touchMinor=%0.3f, toolMajor=%0.3f, toolMinor=%0.3f, "
"orientation=%0.3f, tilt=%0.3f, distance=%0.3f, "
"toolType=%d, isHovering=%s\n", i,
@@ -3220,26 +3223,26 @@
toString(mLastCookedState.cookedPointerData.isHovering(i)));
}
- dump.append(INDENT3 "Stylus Fusion:\n");
- dump.appendFormat(INDENT4 "ExternalStylusConnected: %s\n",
+ dump += INDENT3 "Stylus Fusion:\n";
+ dump += StringPrintf(INDENT4 "ExternalStylusConnected: %s\n",
toString(mExternalStylusConnected));
- dump.appendFormat(INDENT4 "External Stylus ID: %" PRId64 "\n", mExternalStylusId);
- dump.appendFormat(INDENT4 "External Stylus Data Timeout: %" PRId64 "\n",
+ dump += StringPrintf(INDENT4 "External Stylus ID: %" PRId64 "\n", mExternalStylusId);
+ dump += StringPrintf(INDENT4 "External Stylus Data Timeout: %" PRId64 "\n",
mExternalStylusFusionTimeout);
- dump.append(INDENT3 "External Stylus State:\n");
+ dump += INDENT3 "External Stylus State:\n";
dumpStylusState(dump, mExternalStylusState);
if (mDeviceMode == DEVICE_MODE_POINTER) {
- dump.appendFormat(INDENT3 "Pointer Gesture Detector:\n");
- dump.appendFormat(INDENT4 "XMovementScale: %0.3f\n",
+ dump += StringPrintf(INDENT3 "Pointer Gesture Detector:\n");
+ dump += StringPrintf(INDENT4 "XMovementScale: %0.3f\n",
mPointerXMovementScale);
- dump.appendFormat(INDENT4 "YMovementScale: %0.3f\n",
+ dump += StringPrintf(INDENT4 "YMovementScale: %0.3f\n",
mPointerYMovementScale);
- dump.appendFormat(INDENT4 "XZoomScale: %0.3f\n",
+ dump += StringPrintf(INDENT4 "XZoomScale: %0.3f\n",
mPointerXZoomScale);
- dump.appendFormat(INDENT4 "YZoomScale: %0.3f\n",
+ dump += StringPrintf(INDENT4 "YZoomScale: %0.3f\n",
mPointerYZoomScale);
- dump.appendFormat(INDENT4 "MaxSwipeWidth: %f\n",
+ dump += StringPrintf(INDENT4 "MaxSwipeWidth: %f\n",
mPointerGestureMaxSwipeWidth);
}
}
@@ -3400,15 +3403,15 @@
mParameters.wake);
}
-void TouchInputMapper::dumpParameters(String8& dump) {
- dump.append(INDENT3 "Parameters:\n");
+void TouchInputMapper::dumpParameters(std::string& dump) {
+ dump += INDENT3 "Parameters:\n";
switch (mParameters.gestureMode) {
case Parameters::GESTURE_MODE_SINGLE_TOUCH:
- dump.append(INDENT4 "GestureMode: single-touch\n");
+ dump += INDENT4 "GestureMode: single-touch\n";
break;
case Parameters::GESTURE_MODE_MULTI_TOUCH:
- dump.append(INDENT4 "GestureMode: multi-touch\n");
+ dump += INDENT4 "GestureMode: multi-touch\n";
break;
default:
assert(false);
@@ -3416,27 +3419,27 @@
switch (mParameters.deviceType) {
case Parameters::DEVICE_TYPE_TOUCH_SCREEN:
- dump.append(INDENT4 "DeviceType: touchScreen\n");
+ dump += INDENT4 "DeviceType: touchScreen\n";
break;
case Parameters::DEVICE_TYPE_TOUCH_PAD:
- dump.append(INDENT4 "DeviceType: touchPad\n");
+ dump += INDENT4 "DeviceType: touchPad\n";
break;
case Parameters::DEVICE_TYPE_TOUCH_NAVIGATION:
- dump.append(INDENT4 "DeviceType: touchNavigation\n");
+ dump += INDENT4 "DeviceType: touchNavigation\n";
break;
case Parameters::DEVICE_TYPE_POINTER:
- dump.append(INDENT4 "DeviceType: pointer\n");
+ dump += INDENT4 "DeviceType: pointer\n";
break;
default:
ALOG_ASSERT(false);
}
- dump.appendFormat(
+ dump += StringPrintf(
INDENT4 "AssociatedDisplay: hasAssociatedDisplay=%s, isExternal=%s, displayId='%s'\n",
toString(mParameters.hasAssociatedDisplay),
toString(mParameters.associatedDisplayIsExternal),
mParameters.uniqueDisplayId.c_str());
- dump.appendFormat(INDENT4 "OrientationAware: %s\n",
+ dump += StringPrintf(INDENT4 "OrientationAware: %s\n",
toString(mParameters.orientationAware));
}
@@ -3444,8 +3447,8 @@
mRawPointerAxes.clear();
}
-void TouchInputMapper::dumpRawPointerAxes(String8& dump) {
- dump.append(INDENT3 "Raw Touch Axes:\n");
+void TouchInputMapper::dumpRawPointerAxes(std::string& dump) {
+ dump += INDENT3 "Raw Touch Axes:\n";
dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.x, "X");
dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.y, "Y");
dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.pressure, "Pressure");
@@ -3890,8 +3893,8 @@
}
}
-void TouchInputMapper::dumpSurface(String8& dump) {
- dump.appendFormat(INDENT3 "Viewport: displayId=%d, orientation=%d, "
+void TouchInputMapper::dumpSurface(std::string& dump) {
+ dump += StringPrintf(INDENT3 "Viewport: displayId=%d, orientation=%d, "
"logicalFrame=[%d, %d, %d, %d], "
"physicalFrame=[%d, %d, %d, %d], "
"deviceSize=[%d, %d]\n",
@@ -3902,11 +3905,11 @@
mViewport.physicalRight, mViewport.physicalBottom,
mViewport.deviceWidth, mViewport.deviceHeight);
- dump.appendFormat(INDENT3 "SurfaceWidth: %dpx\n", mSurfaceWidth);
- dump.appendFormat(INDENT3 "SurfaceHeight: %dpx\n", mSurfaceHeight);
- dump.appendFormat(INDENT3 "SurfaceLeft: %d\n", mSurfaceLeft);
- dump.appendFormat(INDENT3 "SurfaceTop: %d\n", mSurfaceTop);
- dump.appendFormat(INDENT3 "SurfaceOrientation: %d\n", mSurfaceOrientation);
+ dump += StringPrintf(INDENT3 "SurfaceWidth: %dpx\n", mSurfaceWidth);
+ dump += StringPrintf(INDENT3 "SurfaceHeight: %dpx\n", mSurfaceHeight);
+ dump += StringPrintf(INDENT3 "SurfaceLeft: %d\n", mSurfaceLeft);
+ dump += StringPrintf(INDENT3 "SurfaceTop: %d\n", mSurfaceTop);
+ dump += StringPrintf(INDENT3 "SurfaceOrientation: %d\n", mSurfaceOrientation);
}
void TouchInputMapper::configureVirtualKeys() {
@@ -3963,13 +3966,13 @@
}
}
-void TouchInputMapper::dumpVirtualKeys(String8& dump) {
+void TouchInputMapper::dumpVirtualKeys(std::string& dump) {
if (!mVirtualKeys.isEmpty()) {
- dump.append(INDENT3 "Virtual Keys:\n");
+ dump += INDENT3 "Virtual Keys:\n";
for (size_t i = 0; i < mVirtualKeys.size(); i++) {
const VirtualKey& virtualKey = mVirtualKeys.itemAt(i);
- dump.appendFormat(INDENT4 "%zu: scanCode=%d, keyCode=%d, "
+ dump += StringPrintf(INDENT4 "%zu: scanCode=%d, keyCode=%d, "
"hitLeft=%d, hitRight=%d, hitTop=%d, hitBottom=%d\n",
i, virtualKey.scanCode, virtualKey.keyCode,
virtualKey.hitLeft, virtualKey.hitRight,
@@ -4118,75 +4121,75 @@
}
}
-void TouchInputMapper::dumpCalibration(String8& dump) {
- dump.append(INDENT3 "Calibration:\n");
+void TouchInputMapper::dumpCalibration(std::string& dump) {
+ dump += INDENT3 "Calibration:\n";
// Size
switch (mCalibration.sizeCalibration) {
case Calibration::SIZE_CALIBRATION_NONE:
- dump.append(INDENT4 "touch.size.calibration: none\n");
+ dump += INDENT4 "touch.size.calibration: none\n";
break;
case Calibration::SIZE_CALIBRATION_GEOMETRIC:
- dump.append(INDENT4 "touch.size.calibration: geometric\n");
+ dump += INDENT4 "touch.size.calibration: geometric\n";
break;
case Calibration::SIZE_CALIBRATION_DIAMETER:
- dump.append(INDENT4 "touch.size.calibration: diameter\n");
+ dump += INDENT4 "touch.size.calibration: diameter\n";
break;
case Calibration::SIZE_CALIBRATION_BOX:
- dump.append(INDENT4 "touch.size.calibration: box\n");
+ dump += INDENT4 "touch.size.calibration: box\n";
break;
case Calibration::SIZE_CALIBRATION_AREA:
- dump.append(INDENT4 "touch.size.calibration: area\n");
+ dump += INDENT4 "touch.size.calibration: area\n";
break;
default:
ALOG_ASSERT(false);
}
if (mCalibration.haveSizeScale) {
- dump.appendFormat(INDENT4 "touch.size.scale: %0.3f\n",
+ dump += StringPrintf(INDENT4 "touch.size.scale: %0.3f\n",
mCalibration.sizeScale);
}
if (mCalibration.haveSizeBias) {
- dump.appendFormat(INDENT4 "touch.size.bias: %0.3f\n",
+ dump += StringPrintf(INDENT4 "touch.size.bias: %0.3f\n",
mCalibration.sizeBias);
}
if (mCalibration.haveSizeIsSummed) {
- dump.appendFormat(INDENT4 "touch.size.isSummed: %s\n",
+ dump += StringPrintf(INDENT4 "touch.size.isSummed: %s\n",
toString(mCalibration.sizeIsSummed));
}
// Pressure
switch (mCalibration.pressureCalibration) {
case Calibration::PRESSURE_CALIBRATION_NONE:
- dump.append(INDENT4 "touch.pressure.calibration: none\n");
+ dump += INDENT4 "touch.pressure.calibration: none\n";
break;
case Calibration::PRESSURE_CALIBRATION_PHYSICAL:
- dump.append(INDENT4 "touch.pressure.calibration: physical\n");
+ dump += INDENT4 "touch.pressure.calibration: physical\n";
break;
case Calibration::PRESSURE_CALIBRATION_AMPLITUDE:
- dump.append(INDENT4 "touch.pressure.calibration: amplitude\n");
+ dump += INDENT4 "touch.pressure.calibration: amplitude\n";
break;
default:
ALOG_ASSERT(false);
}
if (mCalibration.havePressureScale) {
- dump.appendFormat(INDENT4 "touch.pressure.scale: %0.3f\n",
+ dump += StringPrintf(INDENT4 "touch.pressure.scale: %0.3f\n",
mCalibration.pressureScale);
}
// Orientation
switch (mCalibration.orientationCalibration) {
case Calibration::ORIENTATION_CALIBRATION_NONE:
- dump.append(INDENT4 "touch.orientation.calibration: none\n");
+ dump += INDENT4 "touch.orientation.calibration: none\n";
break;
case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
- dump.append(INDENT4 "touch.orientation.calibration: interpolated\n");
+ dump += INDENT4 "touch.orientation.calibration: interpolated\n";
break;
case Calibration::ORIENTATION_CALIBRATION_VECTOR:
- dump.append(INDENT4 "touch.orientation.calibration: vector\n");
+ dump += INDENT4 "touch.orientation.calibration: vector\n";
break;
default:
ALOG_ASSERT(false);
@@ -4195,41 +4198,41 @@
// Distance
switch (mCalibration.distanceCalibration) {
case Calibration::DISTANCE_CALIBRATION_NONE:
- dump.append(INDENT4 "touch.distance.calibration: none\n");
+ dump += INDENT4 "touch.distance.calibration: none\n";
break;
case Calibration::DISTANCE_CALIBRATION_SCALED:
- dump.append(INDENT4 "touch.distance.calibration: scaled\n");
+ dump += INDENT4 "touch.distance.calibration: scaled\n";
break;
default:
ALOG_ASSERT(false);
}
if (mCalibration.haveDistanceScale) {
- dump.appendFormat(INDENT4 "touch.distance.scale: %0.3f\n",
+ dump += StringPrintf(INDENT4 "touch.distance.scale: %0.3f\n",
mCalibration.distanceScale);
}
switch (mCalibration.coverageCalibration) {
case Calibration::COVERAGE_CALIBRATION_NONE:
- dump.append(INDENT4 "touch.coverage.calibration: none\n");
+ dump += INDENT4 "touch.coverage.calibration: none\n";
break;
case Calibration::COVERAGE_CALIBRATION_BOX:
- dump.append(INDENT4 "touch.coverage.calibration: box\n");
+ dump += INDENT4 "touch.coverage.calibration: box\n";
break;
default:
ALOG_ASSERT(false);
}
}
-void TouchInputMapper::dumpAffineTransformation(String8& dump) {
- dump.append(INDENT3 "Affine Transformation:\n");
+void TouchInputMapper::dumpAffineTransformation(std::string& dump) {
+ dump += INDENT3 "Affine Transformation:\n";
- dump.appendFormat(INDENT4 "X scale: %0.3f\n", mAffineTransform.x_scale);
- dump.appendFormat(INDENT4 "X ymix: %0.3f\n", mAffineTransform.x_ymix);
- dump.appendFormat(INDENT4 "X offset: %0.3f\n", mAffineTransform.x_offset);
- dump.appendFormat(INDENT4 "Y xmix: %0.3f\n", mAffineTransform.y_xmix);
- dump.appendFormat(INDENT4 "Y scale: %0.3f\n", mAffineTransform.y_scale);
- dump.appendFormat(INDENT4 "Y offset: %0.3f\n", mAffineTransform.y_offset);
+ dump += StringPrintf(INDENT4 "X scale: %0.3f\n", mAffineTransform.x_scale);
+ dump += StringPrintf(INDENT4 "X ymix: %0.3f\n", mAffineTransform.x_ymix);
+ dump += StringPrintf(INDENT4 "X offset: %0.3f\n", mAffineTransform.x_offset);
+ dump += StringPrintf(INDENT4 "Y xmix: %0.3f\n", mAffineTransform.y_xmix);
+ dump += StringPrintf(INDENT4 "Y scale: %0.3f\n", mAffineTransform.y_scale);
+ dump += StringPrintf(INDENT4 "Y offset: %0.3f\n", mAffineTransform.y_offset);
}
void TouchInputMapper::updateAffineTransformation() {
@@ -7005,11 +7008,11 @@
0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
}
-void ExternalStylusInputMapper::dump(String8& dump) {
- dump.append(INDENT2 "External Stylus Input Mapper:\n");
- dump.append(INDENT3 "Raw Stylus Axes:\n");
+void ExternalStylusInputMapper::dump(std::string& dump) {
+ dump += INDENT2 "External Stylus Input Mapper:\n";
+ dump += INDENT3 "Raw Stylus Axes:\n";
dumpRawAbsoluteAxisInfo(dump, mRawPressureAxis, "Pressure");
- dump.append(INDENT3 "Stylus State:\n");
+ dump += INDENT3 "Stylus State:\n";
dumpStylusState(dump, mStylusState);
}
@@ -7114,37 +7117,37 @@
return -1;
}
-void JoystickInputMapper::dump(String8& dump) {
- dump.append(INDENT2 "Joystick Input Mapper:\n");
+void JoystickInputMapper::dump(std::string& dump) {
+ dump += INDENT2 "Joystick Input Mapper:\n";
- dump.append(INDENT3 "Axes:\n");
+ dump += INDENT3 "Axes:\n";
size_t numAxes = mAxes.size();
for (size_t i = 0; i < numAxes; i++) {
const Axis& axis = mAxes.valueAt(i);
const char* label = getAxisLabel(axis.axisInfo.axis);
if (label) {
- dump.appendFormat(INDENT4 "%s", label);
+ dump += StringPrintf(INDENT4 "%s", label);
} else {
- dump.appendFormat(INDENT4 "%d", axis.axisInfo.axis);
+ dump += StringPrintf(INDENT4 "%d", axis.axisInfo.axis);
}
if (axis.axisInfo.mode == AxisInfo::MODE_SPLIT) {
label = getAxisLabel(axis.axisInfo.highAxis);
if (label) {
- dump.appendFormat(" / %s (split at %d)", label, axis.axisInfo.splitValue);
+ dump += StringPrintf(" / %s (split at %d)", label, axis.axisInfo.splitValue);
} else {
- dump.appendFormat(" / %d (split at %d)", axis.axisInfo.highAxis,
+ dump += StringPrintf(" / %d (split at %d)", axis.axisInfo.highAxis,
axis.axisInfo.splitValue);
}
} else if (axis.axisInfo.mode == AxisInfo::MODE_INVERT) {
- dump.append(" (invert)");
+ dump += " (invert)";
}
- dump.appendFormat(": min=%0.5f, max=%0.5f, flat=%0.5f, fuzz=%0.5f, resolution=%0.5f\n",
+ dump += StringPrintf(": min=%0.5f, max=%0.5f, flat=%0.5f, fuzz=%0.5f, resolution=%0.5f\n",
axis.min, axis.max, axis.flat, axis.fuzz, axis.resolution);
- dump.appendFormat(INDENT4 " scale=%0.5f, offset=%0.5f, "
+ dump += StringPrintf(INDENT4 " scale=%0.5f, offset=%0.5f, "
"highScale=%0.5f, highOffset=%0.5f\n",
axis.scale, axis.offset, axis.highScale, axis.highOffset);
- dump.appendFormat(INDENT4 " rawAxis=%d, rawMin=%d, rawMax=%d, "
+ dump += StringPrintf(INDENT4 " rawAxis=%d, rawMin=%d, rawMax=%d, "
"rawFlat=%d, rawFuzz=%d, rawResolution=%d\n",
mAxes.keyAt(i), axis.rawAxisInfo.minValue, axis.rawAxisInfo.maxValue,
axis.rawAxisInfo.flat, axis.rawAxisInfo.fuzz, axis.rawAxisInfo.resolution);
diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h
index a6b9798..4f48262 100644
--- a/services/inputflinger/InputReader.h
+++ b/services/inputflinger/InputReader.h
@@ -32,7 +32,6 @@
#include <utils/Mutex.h>
#include <utils/Timers.h>
#include <utils/RefBase.h>
-#include <utils/String8.h>
#include <utils/BitSet.h>
#include <utils/SortedVector.h>
@@ -207,8 +206,8 @@
void setVirtualDisplayViewports(const Vector<DisplayViewport>& viewports);
- void dump(String8& dump) const;
- void dumpViewport(String8& dump, const DisplayViewport& viewport) const;
+ void dump(std::string& dump) const;
+ void dumpViewport(std::string& dump, const DisplayViewport& viewport) const;
private:
DisplayViewport mInternalDisplay;
@@ -292,7 +291,7 @@
/* Dumps the state of the input reader.
*
* This method may be called on any thread (usually by the input manager). */
- virtual void dump(String8& dump) = 0;
+ virtual void dump(std::string& dump) = 0;
/* Called by the heatbeat to ensures that the reader has not deadlocked. */
virtual void monitor() = 0;
@@ -412,7 +411,7 @@
const sp<InputListenerInterface>& listener);
virtual ~InputReader();
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
virtual void monitor();
virtual void loopOnce();
@@ -569,7 +568,7 @@
bool isEnabled();
void setEnabled(bool enabled, nsecs_t when);
- void dump(String8& dump);
+ void dump(std::string& dump);
void addMapper(InputMapper* mapper);
void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
void reset(nsecs_t when);
@@ -987,7 +986,7 @@
virtual uint32_t getSources() = 0;
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent) = 0;
@@ -1017,9 +1016,9 @@
status_t getAbsoluteAxisInfo(int32_t axis, RawAbsoluteAxisInfo* axisInfo);
void bumpGeneration();
- static void dumpRawAbsoluteAxisInfo(String8& dump,
+ static void dumpRawAbsoluteAxisInfo(std::string& dump,
const RawAbsoluteAxisInfo& axis, const char* name);
- static void dumpStylusState(String8& dump, const StylusState& state);
+ static void dumpStylusState(std::string& dump, const StylusState& state);
};
@@ -1032,7 +1031,7 @@
virtual void process(const RawEvent* rawEvent);
virtual int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode);
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
private:
uint32_t mSwitchValues;
@@ -1056,7 +1055,7 @@
int32_t token);
virtual void cancelVibrate(int32_t token);
virtual void timeoutExpired(nsecs_t when);
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
private:
bool mVibrating;
@@ -1079,7 +1078,7 @@
virtual uint32_t getSources();
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
@@ -1125,7 +1124,7 @@
} mParameters;
void configureParameters();
- void dumpParameters(String8& dump);
+ void dumpParameters(std::string& dump);
bool isKeyboardOrGamepadKey(int32_t scanCode);
bool isMediaKey(int32_t keyCode);
@@ -1151,7 +1150,7 @@
virtual uint32_t getSources();
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
@@ -1204,7 +1203,7 @@
nsecs_t mDownTime;
void configureParameters();
- void dumpParameters(String8& dump);
+ void dumpParameters(std::string& dump);
void sync(nsecs_t when);
};
@@ -1217,7 +1216,7 @@
virtual uint32_t getSources();
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
@@ -1239,7 +1238,7 @@
virtual uint32_t getSources();
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
@@ -1482,18 +1481,18 @@
Vector<VirtualKey> mVirtualKeys;
virtual void configureParameters();
- virtual void dumpParameters(String8& dump);
+ virtual void dumpParameters(std::string& dump);
virtual void configureRawPointerAxes();
- virtual void dumpRawPointerAxes(String8& dump);
+ virtual void dumpRawPointerAxes(std::string& dump);
virtual void configureSurface(nsecs_t when, bool* outResetNeeded);
- virtual void dumpSurface(String8& dump);
+ virtual void dumpSurface(std::string& dump);
virtual void configureVirtualKeys();
- virtual void dumpVirtualKeys(String8& dump);
+ virtual void dumpVirtualKeys(std::string& dump);
virtual void parseCalibration();
virtual void resolveCalibration();
- virtual void dumpCalibration(String8& dump);
+ virtual void dumpCalibration(std::string& dump);
virtual void updateAffineTransformation();
- virtual void dumpAffineTransformation(String8& dump);
+ virtual void dumpAffineTransformation(std::string& dump);
virtual void resolveExternalStylusPresence();
virtual bool hasStylus() const = 0;
virtual bool hasExternalStylus() const;
@@ -1904,7 +1903,7 @@
virtual uint32_t getSources();
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
@@ -1926,7 +1925,7 @@
virtual uint32_t getSources();
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
- virtual void dump(String8& dump);
+ virtual void dump(std::string& dump);
virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
diff --git a/services/inputflinger/InputWindow.h b/services/inputflinger/InputWindow.h
index 9eb2798..5a48375 100644
--- a/services/inputflinger/InputWindow.h
+++ b/services/inputflinger/InputWindow.h
@@ -23,7 +23,6 @@
#include <ui/Region.h>
#include <utils/RefBase.h>
#include <utils/Timers.h>
-#include <utils/String8.h>
#include "InputApplication.h"
@@ -116,7 +115,7 @@
};
sp<InputChannel> inputChannel;
- String8 name;
+ std::string name;
int32_t layoutParamsFlags;
int32_t layoutParamsType;
nsecs_t dispatchingTimeout;
@@ -173,8 +172,8 @@
return mInfo ? mInfo->inputChannel : NULL;
}
- inline String8 getName() const {
- return mInfo ? mInfo->name : String8("<invalid>");
+ inline std::string getName() const {
+ return mInfo ? mInfo->name : "<invalid>";
}
inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const {
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 7ae36d8..aa6df24 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -54,7 +54,7 @@
virtual nsecs_t notifyANR(const sp<InputApplicationHandle>&,
const sp<InputWindowHandle>&,
- const String8&) {
+ const std::string&) {
return 0;
}
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 76291a5..0344ead 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -798,7 +798,7 @@
return false;
}
- virtual void dump(String8&) {
+ virtual void dump(std::string&) {
}
virtual void monitor() {