diff options
author | 2023-08-16 15:04:36 +0000 | |
---|---|---|
committer | 2023-08-16 16:35:57 +0000 | |
commit | 00eac29d8c5e3ec07ff586edb99e7a06902379cb (patch) | |
tree | c385dfe00f6171ef3c09ac566984ead87bf5eba7 | |
parent | 180f95b4641e4bdf66a6586d2fbf43c1defb2d81 (diff) |
Use String8/16 c_str [input]
Bug: 295394788
Test: make checkbuild
Change-Id: Iffbcff6f58e30c0bd40e699ba6e1f917addc5ade
-rw-r--r-- | libs/input/KeyCharacterMap.cpp | 123 | ||||
-rw-r--r-- | libs/input/KeyLayoutMap.cpp | 119 | ||||
-rw-r--r-- | libs/input/PropertyMap.cpp | 16 | ||||
-rw-r--r-- | libs/input/VirtualKeyMap.cpp | 17 | ||||
-rw-r--r-- | services/inputflinger/host/InputDriver.cpp | 6 | ||||
-rw-r--r-- | services/inputflinger/host/InputFlinger.cpp | 2 | ||||
-rw-r--r-- | services/vr/virtual_touchpad/VirtualTouchpadService.cpp | 2 |
7 files changed, 138 insertions, 147 deletions
diff --git a/libs/input/KeyCharacterMap.cpp b/libs/input/KeyCharacterMap.cpp index 12c9e533c3..d571917ff9 100644 --- a/libs/input/KeyCharacterMap.cpp +++ b/libs/input/KeyCharacterMap.cpp @@ -140,7 +140,7 @@ status_t KeyCharacterMap::load(Tokenizer* tokenizer, Format format) { #if DEBUG_PARSER_PERFORMANCE nsecs_t elapsedTime = systemTime(SYSTEM_TIME_MONOTONIC) - startTime; ALOGD("Parsed key character map file '%s' %d lines in %0.3fms.", - tokenizer->getFilename().string(), tokenizer->getLineNumber(), elapsedTime / 1000000.0); + tokenizer->getFilename().c_str(), tokenizer->getLineNumber(), elapsedTime / 1000000.0); #endif if (status != OK) { ALOGE("Loading KeyCharacterMap failed with status %s", statusToString(status).c_str()); @@ -297,7 +297,7 @@ bool KeyCharacterMap::getEvents(int32_t deviceId, const char16_t* chars, size_t if (!findKey(ch, &keyCode, &metaState)) { #if DEBUG_MAPPING ALOGD("getEvents: deviceId=%d, chars=[%s] ~ Failed to find mapping for character %d.", - deviceId, toString(chars, numChars).string(), ch); + deviceId, toString(chars, numChars).c_str(), ch); #endif return false; } @@ -309,8 +309,8 @@ bool KeyCharacterMap::getEvents(int32_t deviceId, const char16_t* chars, size_t addMetaKeys(outEvents, deviceId, metaState, false, now, ¤tMetaState); } #if DEBUG_MAPPING - ALOGD("getEvents: deviceId=%d, chars=[%s] ~ Generated %d events.", - deviceId, toString(chars, numChars).string(), int32_t(outEvents.size())); + ALOGD("getEvents: deviceId=%d, chars=[%s] ~ Generated %d events.", deviceId, + toString(chars, numChars).c_str(), int32_t(outEvents.size())); for (size_t i = 0; i < outEvents.size(); i++) { ALOGD(" Key: keyCode=%d, metaState=0x%08x, %s.", outEvents[i].getKeyCode(), outEvents[i].getMetaState(), @@ -756,8 +756,8 @@ KeyCharacterMap::Parser::Parser(KeyCharacterMap* map, Tokenizer* tokenizer, Form status_t KeyCharacterMap::Parser::parse() { while (!mTokenizer->isEof()) { #if DEBUG_PARSER - ALOGD("Parsing %s: '%s'.", mTokenizer->getLocation().string(), - mTokenizer->peekRemainderOfLine().string()); + ALOGD("Parsing %s: '%s'.", mTokenizer->getLocation().c_str(), + mTokenizer->peekRemainderOfLine().c_str()); #endif mTokenizer->skipDelimiters(WHITESPACE); @@ -779,8 +779,8 @@ status_t KeyCharacterMap::Parser::parse() { status_t status = parseKey(); if (status) return status; } else { - ALOGE("%s: Expected keyword, got '%s'.", mTokenizer->getLocation().string(), - keywordToken.string()); + ALOGE("%s: Expected keyword, got '%s'.", mTokenizer->getLocation().c_str(), + keywordToken.c_str()); return BAD_VALUE; } break; @@ -795,10 +795,9 @@ status_t KeyCharacterMap::Parser::parse() { mTokenizer->skipDelimiters(WHITESPACE); if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') { - ALOGE("%s: Expected end of line or trailing comment, got '%s'.", - mTokenizer->getLocation().string(), - mTokenizer->peekRemainderOfLine().string()); - return BAD_VALUE; + ALOGE("%s: Expected end of line or trailing comment, got '%s'.", + mTokenizer->getLocation().c_str(), mTokenizer->peekRemainderOfLine().c_str()); + return BAD_VALUE; } } @@ -807,27 +806,27 @@ status_t KeyCharacterMap::Parser::parse() { if (mState != STATE_TOP) { ALOGE("%s: Unterminated key description at end of file.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } if (mMap->mType == KeyboardType::UNKNOWN) { ALOGE("%s: Keyboard layout missing required keyboard 'type' declaration.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } if (mFormat == Format::BASE) { if (mMap->mType == KeyboardType::OVERLAY) { ALOGE("%s: Base keyboard layout must specify a keyboard 'type' other than 'OVERLAY'.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } } else if (mFormat == Format::OVERLAY) { if (mMap->mType != KeyboardType::OVERLAY) { ALOGE("%s: Overlay keyboard layout missing required keyboard " - "'type OVERLAY' declaration.", - mTokenizer->getLocation().string()); + "'type OVERLAY' declaration.", + mTokenizer->getLocation().c_str()); return BAD_VALUE; } } @@ -837,8 +836,7 @@ status_t KeyCharacterMap::Parser::parse() { status_t KeyCharacterMap::Parser::parseType() { if (mMap->mType != KeyboardType::UNKNOWN) { - ALOGE("%s: Duplicate keyboard 'type' declaration.", - mTokenizer->getLocation().string()); + ALOGE("%s: Duplicate keyboard 'type' declaration.", mTokenizer->getLocation().c_str()); return BAD_VALUE; } @@ -860,8 +858,8 @@ status_t KeyCharacterMap::Parser::parseType() { } else if (typeToken == "OVERLAY") { type = KeyboardType::OVERLAY; } else { - ALOGE("%s: Expected keyboard type label, got '%s'.", mTokenizer->getLocation().string(), - typeToken.string()); + ALOGE("%s: Expected keyboard type label, got '%s'.", mTokenizer->getLocation().c_str(), + typeToken.c_str()); return BAD_VALUE; } @@ -878,8 +876,8 @@ status_t KeyCharacterMap::Parser::parseMap() { mTokenizer->skipDelimiters(WHITESPACE); return parseMapKey(); } - ALOGE("%s: Expected keyword after 'map', got '%s'.", mTokenizer->getLocation().string(), - keywordToken.string()); + ALOGE("%s: Expected keyword after 'map', got '%s'.", mTokenizer->getLocation().c_str(), + keywordToken.c_str()); return BAD_VALUE; } @@ -893,26 +891,26 @@ status_t KeyCharacterMap::Parser::parseMapKey() { } char* end; - int32_t code = int32_t(strtol(codeToken.string(), &end, 0)); + int32_t code = int32_t(strtol(codeToken.c_str(), &end, 0)); if (*end) { - ALOGE("%s: Expected key %s number, got '%s'.", mTokenizer->getLocation().string(), - mapUsage ? "usage" : "scan code", codeToken.string()); + ALOGE("%s: Expected key %s number, got '%s'.", mTokenizer->getLocation().c_str(), + mapUsage ? "usage" : "scan code", codeToken.c_str()); return BAD_VALUE; } std::map<int32_t, int32_t>& map = mapUsage ? mMap->mKeysByUsageCode : mMap->mKeysByScanCode; const auto it = map.find(code); if (it != map.end()) { - ALOGE("%s: Duplicate entry for key %s '%s'.", mTokenizer->getLocation().string(), - mapUsage ? "usage" : "scan code", codeToken.string()); + ALOGE("%s: Duplicate entry for key %s '%s'.", mTokenizer->getLocation().c_str(), + mapUsage ? "usage" : "scan code", codeToken.c_str()); return BAD_VALUE; } mTokenizer->skipDelimiters(WHITESPACE); String8 keyCodeToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> keyCode = InputEventLookup::getKeyCodeByLabel(keyCodeToken.string()); + std::optional<int> keyCode = InputEventLookup::getKeyCodeByLabel(keyCodeToken.c_str()); if (!keyCode) { - ALOGE("%s: Expected key code label, got '%s'.", mTokenizer->getLocation().string(), - keyCodeToken.string()); + ALOGE("%s: Expected key code label, got '%s'.", mTokenizer->getLocation().c_str(), + keyCodeToken.c_str()); return BAD_VALUE; } @@ -926,23 +924,23 @@ status_t KeyCharacterMap::Parser::parseMapKey() { status_t KeyCharacterMap::Parser::parseKey() { String8 keyCodeToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> keyCode = InputEventLookup::getKeyCodeByLabel(keyCodeToken.string()); + std::optional<int> keyCode = InputEventLookup::getKeyCodeByLabel(keyCodeToken.c_str()); if (!keyCode) { - ALOGE("%s: Expected key code label, got '%s'.", mTokenizer->getLocation().string(), - keyCodeToken.string()); + ALOGE("%s: Expected key code label, got '%s'.", mTokenizer->getLocation().c_str(), + keyCodeToken.c_str()); return BAD_VALUE; } if (mMap->mKeys.find(*keyCode) != mMap->mKeys.end()) { - ALOGE("%s: Duplicate entry for key code '%s'.", mTokenizer->getLocation().string(), - keyCodeToken.string()); + ALOGE("%s: Duplicate entry for key code '%s'.", mTokenizer->getLocation().c_str(), + keyCodeToken.c_str()); return BAD_VALUE; } mTokenizer->skipDelimiters(WHITESPACE); String8 openBraceToken = mTokenizer->nextToken(WHITESPACE); if (openBraceToken != "{") { - ALOGE("%s: Expected '{' after key code label, got '%s'.", - mTokenizer->getLocation().string(), openBraceToken.string()); + ALOGE("%s: Expected '{' after key code label, got '%s'.", mTokenizer->getLocation().c_str(), + openBraceToken.c_str()); return BAD_VALUE; } @@ -971,10 +969,10 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() { properties.emplace_back(PROPERTY_NUMBER); } else { int32_t metaState; - status_t status = parseModifier(token.string(), &metaState); + status_t status = parseModifier(token.c_str(), &metaState); if (status) { ALOGE("%s: Expected a property name or modifier, got '%s'.", - mTokenizer->getLocation().string(), token.string()); + mTokenizer->getLocation().c_str(), token.c_str()); return status; } properties.emplace_back(PROPERTY_META, metaState); @@ -992,8 +990,7 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() { } } - ALOGE("%s: Expected ',' or ':' after property name.", - mTokenizer->getLocation().string()); + ALOGE("%s: Expected ',' or ':' after property name.", mTokenizer->getLocation().c_str()); return BAD_VALUE; } @@ -1011,18 +1008,17 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() { char16_t character; status_t status = parseCharacterLiteral(&character); if (status || !character) { - ALOGE("%s: Invalid character literal for key.", - mTokenizer->getLocation().string()); + ALOGE("%s: Invalid character literal for key.", mTokenizer->getLocation().c_str()); return BAD_VALUE; } if (haveCharacter) { ALOGE("%s: Cannot combine multiple character literals or 'none'.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } if (haveReplacement) { ALOGE("%s: Cannot combine character literal with replace action.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } behavior.character = character; @@ -1032,28 +1028,27 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() { if (token == "none") { if (haveCharacter) { ALOGE("%s: Cannot combine multiple character literals or 'none'.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } if (haveReplacement) { ALOGE("%s: Cannot combine 'none' with replace action.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } haveCharacter = true; } else if (token == "fallback") { mTokenizer->skipDelimiters(WHITESPACE); token = mTokenizer->nextToken(WHITESPACE); - std::optional<int> keyCode = InputEventLookup::getKeyCodeByLabel(token.string()); + std::optional<int> keyCode = InputEventLookup::getKeyCodeByLabel(token.c_str()); if (!keyCode) { ALOGE("%s: Invalid key code label for fallback behavior, got '%s'.", - mTokenizer->getLocation().string(), - token.string()); + mTokenizer->getLocation().c_str(), token.c_str()); return BAD_VALUE; } if (haveFallback || haveReplacement) { ALOGE("%s: Cannot combine multiple fallback/replacement key codes.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } behavior.fallbackKeyCode = *keyCode; @@ -1061,29 +1056,27 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() { } else if (token == "replace") { mTokenizer->skipDelimiters(WHITESPACE); token = mTokenizer->nextToken(WHITESPACE); - std::optional<int> keyCode = InputEventLookup::getKeyCodeByLabel(token.string()); + std::optional<int> keyCode = InputEventLookup::getKeyCodeByLabel(token.c_str()); if (!keyCode) { ALOGE("%s: Invalid key code label for replace, got '%s'.", - mTokenizer->getLocation().string(), - token.string()); + mTokenizer->getLocation().c_str(), token.c_str()); return BAD_VALUE; } if (haveCharacter) { ALOGE("%s: Cannot combine character literal with replace action.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } if (haveFallback || haveReplacement) { ALOGE("%s: Cannot combine multiple fallback/replacement key codes.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } behavior.replacementKeyCode = *keyCode; haveReplacement = true; } else { - ALOGE("%s: Expected a key behavior after ':'.", - mTokenizer->getLocation().string()); + ALOGE("%s: Expected a key behavior after ':'.", mTokenizer->getLocation().c_str()); return BAD_VALUE; } } @@ -1096,7 +1089,7 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() { switch (property.property) { case PROPERTY_LABEL: if (key.label) { - ALOGE("%s: Duplicate label for key.", mTokenizer->getLocation().string()); + ALOGE("%s: Duplicate label for key.", mTokenizer->getLocation().c_str()); return BAD_VALUE; } key.label = behavior.character; @@ -1106,7 +1099,7 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() { break; case PROPERTY_NUMBER: if (key.number) { - ALOGE("%s: Duplicate number for key.", mTokenizer->getLocation().string()); + ALOGE("%s: Duplicate number for key.", mTokenizer->getLocation().c_str()); return BAD_VALUE; } key.number = behavior.character; @@ -1118,7 +1111,7 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() { for (const Behavior& b : key.behaviors) { if (b.metaState == property.metaState) { ALOGE("%s: Duplicate key behavior for modifier.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } } @@ -1185,8 +1178,8 @@ status_t KeyCharacterMap::Parser::parseModifier(const std::string& token, int32_ return BAD_VALUE; } if (combinedMeta & metaState) { - ALOGE("%s: Duplicate modifier combination '%s'.", - mTokenizer->getLocation().string(), token.c_str()); + ALOGE("%s: Duplicate modifier combination '%s'.", mTokenizer->getLocation().c_str(), + token.c_str()); return BAD_VALUE; } @@ -1259,7 +1252,7 @@ status_t KeyCharacterMap::Parser::parseCharacterLiteral(char16_t* outCharacter) } Error: - ALOGE("%s: Malformed character literal.", mTokenizer->getLocation().string()); + ALOGE("%s: Malformed character literal.", mTokenizer->getLocation().c_str()); return BAD_VALUE; } diff --git a/libs/input/KeyLayoutMap.cpp b/libs/input/KeyLayoutMap.cpp index a194513953..ddc9ea457e 100644 --- a/libs/input/KeyLayoutMap.cpp +++ b/libs/input/KeyLayoutMap.cpp @@ -177,7 +177,7 @@ base::Result<std::shared_ptr<KeyLayoutMap>> KeyLayoutMap::load(Tokenizer* tokeni #if DEBUG_PARSER_PERFORMANCE nsecs_t elapsedTime = systemTime(SYSTEM_TIME_MONOTONIC) - startTime; ALOGD("Parsed key layout map file '%s' %d lines in %0.3fms.", - tokenizer->getFilename().string(), tokenizer->getLineNumber(), + tokenizer->getFilename().c_str(), tokenizer->getLineNumber(), elapsedTime / 1000000.0); #endif if (!status) { @@ -306,8 +306,8 @@ KeyLayoutMap::Parser::~Parser() { status_t KeyLayoutMap::Parser::parse() { while (!mTokenizer->isEof()) { - ALOGD_IF(DEBUG_PARSER, "Parsing %s: '%s'.", mTokenizer->getLocation().string(), - mTokenizer->peekRemainderOfLine().string()); + ALOGD_IF(DEBUG_PARSER, "Parsing %s: '%s'.", mTokenizer->getLocation().c_str(), + mTokenizer->peekRemainderOfLine().c_str()); mTokenizer->skipDelimiters(WHITESPACE); @@ -334,16 +334,15 @@ status_t KeyLayoutMap::Parser::parse() { status_t status = parseRequiredKernelConfig(); if (status) return status; } else { - ALOGE("%s: Expected keyword, got '%s'.", mTokenizer->getLocation().string(), - keywordToken.string()); + ALOGE("%s: Expected keyword, got '%s'.", mTokenizer->getLocation().c_str(), + keywordToken.c_str()); return BAD_VALUE; } mTokenizer->skipDelimiters(WHITESPACE); if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') { ALOGE("%s: Expected end of line or trailing comment, got '%s'.", - mTokenizer->getLocation().string(), - mTokenizer->peekRemainderOfLine().string()); + mTokenizer->getLocation().c_str(), mTokenizer->peekRemainderOfLine().c_str()); return BAD_VALUE; } } @@ -362,26 +361,26 @@ status_t KeyLayoutMap::Parser::parseKey() { codeToken = mTokenizer->nextToken(WHITESPACE); } - std::optional<int> code = parseInt(codeToken.string()); + std::optional<int> code = parseInt(codeToken.c_str()); if (!code) { - ALOGE("%s: Expected key %s number, got '%s'.", mTokenizer->getLocation().string(), - mapUsage ? "usage" : "scan code", codeToken.string()); + ALOGE("%s: Expected key %s number, got '%s'.", mTokenizer->getLocation().c_str(), + mapUsage ? "usage" : "scan code", codeToken.c_str()); return BAD_VALUE; } std::unordered_map<int32_t, Key>& map = mapUsage ? mMap->mKeysByUsageCode : mMap->mKeysByScanCode; if (map.find(*code) != map.end()) { - ALOGE("%s: Duplicate entry for key %s '%s'.", mTokenizer->getLocation().string(), - mapUsage ? "usage" : "scan code", codeToken.string()); + ALOGE("%s: Duplicate entry for key %s '%s'.", mTokenizer->getLocation().c_str(), + mapUsage ? "usage" : "scan code", codeToken.c_str()); return BAD_VALUE; } mTokenizer->skipDelimiters(WHITESPACE); String8 keyCodeToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> keyCode = InputEventLookup::getKeyCodeByLabel(keyCodeToken.string()); + std::optional<int> keyCode = InputEventLookup::getKeyCodeByLabel(keyCodeToken.c_str()); if (!keyCode) { - ALOGE("%s: Expected key code label, got '%s'.", mTokenizer->getLocation().string(), - keyCodeToken.string()); + ALOGE("%s: Expected key code label, got '%s'.", mTokenizer->getLocation().c_str(), + keyCodeToken.c_str()); return BAD_VALUE; } @@ -391,15 +390,15 @@ status_t KeyLayoutMap::Parser::parseKey() { if (mTokenizer->isEol() || mTokenizer->peekChar() == '#') break; String8 flagToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> flag = InputEventLookup::getKeyFlagByLabel(flagToken.string()); + std::optional<int> flag = InputEventLookup::getKeyFlagByLabel(flagToken.c_str()); if (!flag) { - ALOGE("%s: Expected key flag label, got '%s'.", mTokenizer->getLocation().string(), - flagToken.string()); + ALOGE("%s: Expected key flag label, got '%s'.", mTokenizer->getLocation().c_str(), + flagToken.c_str()); return BAD_VALUE; } if (flags & *flag) { - ALOGE("%s: Duplicate key flag '%s'.", mTokenizer->getLocation().string(), - flagToken.string()); + ALOGE("%s: Duplicate key flag '%s'.", mTokenizer->getLocation().c_str(), + flagToken.c_str()); return BAD_VALUE; } flags |= *flag; @@ -417,15 +416,15 @@ status_t KeyLayoutMap::Parser::parseKey() { status_t KeyLayoutMap::Parser::parseAxis() { String8 scanCodeToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> scanCode = parseInt(scanCodeToken.string()); + std::optional<int> scanCode = parseInt(scanCodeToken.c_str()); if (!scanCode) { - ALOGE("%s: Expected axis scan code number, got '%s'.", mTokenizer->getLocation().string(), - scanCodeToken.string()); + ALOGE("%s: Expected axis scan code number, got '%s'.", mTokenizer->getLocation().c_str(), + scanCodeToken.c_str()); return BAD_VALUE; } if (mMap->mAxes.find(*scanCode) != mMap->mAxes.end()) { - ALOGE("%s: Duplicate entry for axis scan code '%s'.", mTokenizer->getLocation().string(), - scanCodeToken.string()); + ALOGE("%s: Duplicate entry for axis scan code '%s'.", mTokenizer->getLocation().c_str(), + scanCodeToken.c_str()); return BAD_VALUE; } @@ -438,10 +437,10 @@ status_t KeyLayoutMap::Parser::parseAxis() { mTokenizer->skipDelimiters(WHITESPACE); String8 axisToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> axis = InputEventLookup::getAxisByLabel(axisToken.string()); + std::optional<int> axis = InputEventLookup::getAxisByLabel(axisToken.c_str()); if (!axis) { ALOGE("%s: Expected inverted axis label, got '%s'.", - mTokenizer->getLocation().string(), axisToken.string()); + mTokenizer->getLocation().c_str(), axisToken.c_str()); return BAD_VALUE; } axisInfo.axis = *axis; @@ -450,38 +449,38 @@ status_t KeyLayoutMap::Parser::parseAxis() { mTokenizer->skipDelimiters(WHITESPACE); String8 splitToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> splitValue = parseInt(splitToken.string()); + std::optional<int> splitValue = parseInt(splitToken.c_str()); if (!splitValue) { ALOGE("%s: Expected split value, got '%s'.", - mTokenizer->getLocation().string(), splitToken.string()); + mTokenizer->getLocation().c_str(), splitToken.c_str()); return BAD_VALUE; } axisInfo.splitValue = *splitValue; mTokenizer->skipDelimiters(WHITESPACE); String8 lowAxisToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> axis = InputEventLookup::getAxisByLabel(lowAxisToken.string()); + std::optional<int> axis = InputEventLookup::getAxisByLabel(lowAxisToken.c_str()); if (!axis) { ALOGE("%s: Expected low axis label, got '%s'.", - mTokenizer->getLocation().string(), lowAxisToken.string()); + mTokenizer->getLocation().c_str(), lowAxisToken.c_str()); return BAD_VALUE; } axisInfo.axis = *axis; mTokenizer->skipDelimiters(WHITESPACE); String8 highAxisToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> highAxis = InputEventLookup::getAxisByLabel(highAxisToken.string()); + std::optional<int> highAxis = InputEventLookup::getAxisByLabel(highAxisToken.c_str()); if (!highAxis) { ALOGE("%s: Expected high axis label, got '%s'.", - mTokenizer->getLocation().string(), highAxisToken.string()); + mTokenizer->getLocation().c_str(), highAxisToken.c_str()); return BAD_VALUE; } axisInfo.highAxis = *highAxis; } else { - std::optional<int> axis = InputEventLookup::getAxisByLabel(token.string()); + std::optional<int> axis = InputEventLookup::getAxisByLabel(token.c_str()); if (!axis) { ALOGE("%s: Expected axis label, 'split' or 'invert', got '%s'.", - mTokenizer->getLocation().string(), token.string()); + mTokenizer->getLocation().c_str(), token.c_str()); return BAD_VALUE; } axisInfo.axis = *axis; @@ -496,16 +495,16 @@ status_t KeyLayoutMap::Parser::parseAxis() { if (keywordToken == "flat") { mTokenizer->skipDelimiters(WHITESPACE); String8 flatToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> flatOverride = parseInt(flatToken.string()); + std::optional<int> flatOverride = parseInt(flatToken.c_str()); if (!flatOverride) { ALOGE("%s: Expected flat value, got '%s'.", - mTokenizer->getLocation().string(), flatToken.string()); + mTokenizer->getLocation().c_str(), flatToken.c_str()); return BAD_VALUE; } axisInfo.flatOverride = *flatOverride; } else { - ALOGE("%s: Expected keyword 'flat', got '%s'.", - mTokenizer->getLocation().string(), keywordToken.string()); + ALOGE("%s: Expected keyword 'flat', got '%s'.", mTokenizer->getLocation().c_str(), + keywordToken.c_str()); return BAD_VALUE; } } @@ -527,27 +526,27 @@ status_t KeyLayoutMap::Parser::parseLed() { mTokenizer->skipDelimiters(WHITESPACE); codeToken = mTokenizer->nextToken(WHITESPACE); } - std::optional<int> code = parseInt(codeToken.string()); + std::optional<int> code = parseInt(codeToken.c_str()); if (!code) { - ALOGE("%s: Expected led %s number, got '%s'.", mTokenizer->getLocation().string(), - mapUsage ? "usage" : "scan code", codeToken.string()); + ALOGE("%s: Expected led %s number, got '%s'.", mTokenizer->getLocation().c_str(), + mapUsage ? "usage" : "scan code", codeToken.c_str()); return BAD_VALUE; } std::unordered_map<int32_t, Led>& map = mapUsage ? mMap->mLedsByUsageCode : mMap->mLedsByScanCode; if (map.find(*code) != map.end()) { - ALOGE("%s: Duplicate entry for led %s '%s'.", mTokenizer->getLocation().string(), - mapUsage ? "usage" : "scan code", codeToken.string()); + ALOGE("%s: Duplicate entry for led %s '%s'.", mTokenizer->getLocation().c_str(), + mapUsage ? "usage" : "scan code", codeToken.c_str()); return BAD_VALUE; } mTokenizer->skipDelimiters(WHITESPACE); String8 ledCodeToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> ledCode = InputEventLookup::getLedByLabel(ledCodeToken.string()); + std::optional<int> ledCode = InputEventLookup::getLedByLabel(ledCodeToken.c_str()); if (!ledCode) { - ALOGE("%s: Expected LED code label, got '%s'.", mTokenizer->getLocation().string(), - ledCodeToken.string()); + ALOGE("%s: Expected LED code label, got '%s'.", mTokenizer->getLocation().c_str(), + ledCodeToken.c_str()); return BAD_VALUE; } @@ -569,7 +568,7 @@ static std::optional<InputDeviceSensorType> getSensorType(const char* token) { } static std::optional<int32_t> getSensorDataIndex(String8 token) { - std::string tokenStr(token.string()); + std::string tokenStr(token.c_str()); if (tokenStr == "X") { return 0; } else if (tokenStr == "Y") { @@ -594,26 +593,26 @@ static std::optional<int32_t> getSensorDataIndex(String8 token) { // sensor 0x05 GYROSCOPE Z status_t KeyLayoutMap::Parser::parseSensor() { String8 codeToken = mTokenizer->nextToken(WHITESPACE); - std::optional<int> code = parseInt(codeToken.string()); + std::optional<int> code = parseInt(codeToken.c_str()); if (!code) { - ALOGE("%s: Expected sensor %s number, got '%s'.", mTokenizer->getLocation().string(), - "abs code", codeToken.string()); + ALOGE("%s: Expected sensor %s number, got '%s'.", mTokenizer->getLocation().c_str(), + "abs code", codeToken.c_str()); return BAD_VALUE; } std::unordered_map<int32_t, Sensor>& map = mMap->mSensorsByAbsCode; if (map.find(*code) != map.end()) { - ALOGE("%s: Duplicate entry for sensor %s '%s'.", mTokenizer->getLocation().string(), - "abs code", codeToken.string()); + ALOGE("%s: Duplicate entry for sensor %s '%s'.", mTokenizer->getLocation().c_str(), + "abs code", codeToken.c_str()); return BAD_VALUE; } mTokenizer->skipDelimiters(WHITESPACE); String8 sensorTypeToken = mTokenizer->nextToken(WHITESPACE); - std::optional<InputDeviceSensorType> typeOpt = getSensorType(sensorTypeToken.string()); + std::optional<InputDeviceSensorType> typeOpt = getSensorType(sensorTypeToken.c_str()); if (!typeOpt) { - ALOGE("%s: Expected sensor code label, got '%s'.", mTokenizer->getLocation().string(), - sensorTypeToken.string()); + ALOGE("%s: Expected sensor code label, got '%s'.", mTokenizer->getLocation().c_str(), + sensorTypeToken.c_str()); return BAD_VALUE; } InputDeviceSensorType sensorType = typeOpt.value(); @@ -621,8 +620,8 @@ status_t KeyLayoutMap::Parser::parseSensor() { String8 sensorDataIndexToken = mTokenizer->nextToken(WHITESPACE); std::optional<int32_t> indexOpt = getSensorDataIndex(sensorDataIndexToken); if (!indexOpt) { - ALOGE("%s: Expected sensor data index label, got '%s'.", mTokenizer->getLocation().string(), - sensorDataIndexToken.string()); + ALOGE("%s: Expected sensor data index label, got '%s'.", mTokenizer->getLocation().c_str(), + sensorDataIndexToken.c_str()); return BAD_VALUE; } int32_t sensorDataIndex = indexOpt.value(); @@ -643,12 +642,12 @@ status_t KeyLayoutMap::Parser::parseSensor() { // requires_kernel_config CONFIG_HID_PLAYSTATION status_t KeyLayoutMap::Parser::parseRequiredKernelConfig() { String8 codeToken = mTokenizer->nextToken(WHITESPACE); - std::string configName = codeToken.string(); + std::string configName = codeToken.c_str(); const auto result = mMap->mRequiredKernelConfigs.emplace(configName); if (!result.second) { ALOGE("%s: Duplicate entry for required kernel config %s.", - mTokenizer->getLocation().string(), configName.c_str()); + mTokenizer->getLocation().c_str(), configName.c_str()); return BAD_VALUE; } diff --git a/libs/input/PropertyMap.cpp b/libs/input/PropertyMap.cpp index 548f894d22..315f5a6d4f 100644 --- a/libs/input/PropertyMap.cpp +++ b/libs/input/PropertyMap.cpp @@ -163,8 +163,8 @@ PropertyMap::Parser::~Parser() {} status_t PropertyMap::Parser::parse() { while (!mTokenizer->isEof()) { #if DEBUG_PARSER - ALOGD("Parsing %s: '%s'.", mTokenizer->getLocation().string(), - mTokenizer->peekRemainderOfLine().string()); + ALOGD("Parsing %s: '%s'.", mTokenizer->getLocation().c_str(), + mTokenizer->peekRemainderOfLine().c_str()); #endif mTokenizer->skipDelimiters(WHITESPACE); @@ -172,7 +172,7 @@ status_t PropertyMap::Parser::parse() { if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') { String8 keyToken = mTokenizer->nextToken(WHITESPACE_OR_PROPERTY_DELIMITER); if (keyToken.isEmpty()) { - ALOGE("%s: Expected non-empty property key.", mTokenizer->getLocation().string()); + ALOGE("%s: Expected non-empty property key.", mTokenizer->getLocation().c_str()); return BAD_VALUE; } @@ -180,7 +180,7 @@ status_t PropertyMap::Parser::parse() { if (mTokenizer->nextChar() != '=') { ALOGE("%s: Expected '=' between property key and value.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } @@ -189,20 +189,20 @@ status_t PropertyMap::Parser::parse() { String8 valueToken = mTokenizer->nextToken(WHITESPACE); if (valueToken.find("\\", 0) >= 0 || valueToken.find("\"", 0) >= 0) { ALOGE("%s: Found reserved character '\\' or '\"' in property value.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } mTokenizer->skipDelimiters(WHITESPACE); if (!mTokenizer->isEol()) { - ALOGE("%s: Expected end of line, got '%s'.", mTokenizer->getLocation().string(), - mTokenizer->peekRemainderOfLine().string()); + ALOGE("%s: Expected end of line, got '%s'.", mTokenizer->getLocation().c_str(), + mTokenizer->peekRemainderOfLine().c_str()); return BAD_VALUE; } if (mMap->hasProperty(keyToken.string())) { ALOGE("%s: Duplicate property value for key '%s'.", - mTokenizer->getLocation().string(), keyToken.string()); + mTokenizer->getLocation().c_str(), keyToken.c_str()); return BAD_VALUE; } diff --git a/libs/input/VirtualKeyMap.cpp b/libs/input/VirtualKeyMap.cpp index 865366bcb2..de62c870ff 100644 --- a/libs/input/VirtualKeyMap.cpp +++ b/libs/input/VirtualKeyMap.cpp @@ -79,8 +79,8 @@ VirtualKeyMap::Parser::~Parser() { status_t VirtualKeyMap::Parser::parse() { while (!mTokenizer->isEof()) { #if DEBUG_PARSER - ALOGD("Parsing %s: '%s'.", mTokenizer->getLocation().string(), - mTokenizer->peekRemainderOfLine().string()); + ALOGD("Parsing %s: '%s'.", mTokenizer->getLocation().c_str(), + mTokenizer->peekRemainderOfLine().c_str()); #endif mTokenizer->skipDelimiters(WHITESPACE); @@ -91,7 +91,7 @@ status_t VirtualKeyMap::Parser::parse() { String8 token = mTokenizer->nextToken(WHITESPACE_OR_FIELD_DELIMITER); if (token != "0x01") { ALOGE("%s: Unknown virtual key type, expected 0x01.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } @@ -103,7 +103,7 @@ status_t VirtualKeyMap::Parser::parse() { && parseNextIntField(&defn.height); if (!success) { ALOGE("%s: Expected 5 colon-delimited integers in virtual key definition.", - mTokenizer->getLocation().string()); + mTokenizer->getLocation().c_str()); return BAD_VALUE; } @@ -116,9 +116,8 @@ status_t VirtualKeyMap::Parser::parse() { } while (consumeFieldDelimiterAndSkipWhitespace()); if (!mTokenizer->isEol()) { - ALOGE("%s: Expected end of line, got '%s'.", - mTokenizer->getLocation().string(), - mTokenizer->peekRemainderOfLine().string()); + ALOGE("%s: Expected end of line, got '%s'.", mTokenizer->getLocation().c_str(), + mTokenizer->peekRemainderOfLine().c_str()); return BAD_VALUE; } } @@ -146,9 +145,9 @@ bool VirtualKeyMap::Parser::parseNextIntField(int32_t* outValue) { String8 token = mTokenizer->nextToken(WHITESPACE_OR_FIELD_DELIMITER); char* end; - *outValue = strtol(token.string(), &end, 0); + *outValue = strtol(token.c_str(), &end, 0); if (token.isEmpty() || *end != '\0') { - ALOGE("Expected an integer, got '%s'.", token.string()); + ALOGE("Expected an integer, got '%s'.", token.c_str()); return false; } return true; diff --git a/services/inputflinger/host/InputDriver.cpp b/services/inputflinger/host/InputDriver.cpp index ec0388d500..de99fc73ec 100644 --- a/services/inputflinger/host/InputDriver.cpp +++ b/services/inputflinger/host/InputDriver.cpp @@ -256,14 +256,14 @@ input_property_t* InputDriver::inputGetDeviceProperty(input_property_map_t* map, const char* InputDriver::inputGetPropertyKey(input_property_t* property) { if (property != nullptr) { - return property->key.string(); + return property->key.c_str(); } return nullptr; } const char* InputDriver::inputGetPropertyValue(input_property_t* property) { if (property != nullptr) { - return property->value.string(); + return property->value.c_str(); } return nullptr; } @@ -281,7 +281,7 @@ void InputDriver::inputFreeDevicePropertyMap(input_property_map_t* map) { } void InputDriver::dump(String8& result) { - result.appendFormat(INDENT2 "HAL Input Driver (%s)\n", mName.string()); + result.appendFormat(INDENT2 "HAL Input Driver (%s)\n", mName.c_str()); } } // namespace android diff --git a/services/inputflinger/host/InputFlinger.cpp b/services/inputflinger/host/InputFlinger.cpp index 2da2a70c03..d974c43d78 100644 --- a/services/inputflinger/host/InputFlinger.cpp +++ b/services/inputflinger/host/InputFlinger.cpp @@ -57,7 +57,7 @@ status_t InputFlinger::dump(int fd, const Vector<String16>& args) { } else { dumpInternal(result); } - write(fd, result.string(), result.size()); + write(fd, result.c_str(), result.size()); return OK; } diff --git a/services/vr/virtual_touchpad/VirtualTouchpadService.cpp b/services/vr/virtual_touchpad/VirtualTouchpadService.cpp index 523f890ce7..d0a9da1ff5 100644 --- a/services/vr/virtual_touchpad/VirtualTouchpadService.cpp +++ b/services/vr/virtual_touchpad/VirtualTouchpadService.cpp @@ -113,7 +113,7 @@ status_t VirtualTouchpadService::dump( static_cast<long>(client_pid_)); touchpad_->dumpInternal(result); } - write(fd, result.string(), result.size()); + write(fd, result.c_str(), result.size()); return OK; } |