@@ -161,7 +161,7 @@ base::Result<std::shared_ptr<KeyLayoutMap>> KeyLayoutMap::load(Tokenizer* tokeni
161161#if DEBUG_PARSER_PERFORMANCE
162162 nsecs_t elapsedTime = systemTime (SYSTEM_TIME_MONOTONIC) - startTime;
163163 ALOGD (" Parsed key layout map file '%s' %d lines in %0.3fms." ,
164- tokenizer->getFilename ().string (), tokenizer->getLineNumber (),
164+ tokenizer->getFilename ().c_str (), tokenizer->getLineNumber (),
165165 elapsedTime / 1000000.0 );
166166#endif
167167 if (!status) {
@@ -289,8 +289,8 @@ KeyLayoutMap::Parser::~Parser() {
289289
290290status_t KeyLayoutMap::Parser::parse () {
291291 while (!mTokenizer ->isEof ()) {
292- ALOGD_IF (DEBUG_PARSER, " Parsing %s: '%s'." , mTokenizer ->getLocation ().string (),
293- mTokenizer ->peekRemainderOfLine ().string ());
292+ ALOGD_IF (DEBUG_PARSER, " Parsing %s: '%s'." , mTokenizer ->getLocation ().c_str (),
293+ mTokenizer ->peekRemainderOfLine ().c_str ());
294294
295295 mTokenizer ->skipDelimiters (WHITESPACE);
296296
@@ -317,16 +317,15 @@ status_t KeyLayoutMap::Parser::parse() {
317317 status_t status = parseRequiredKernelConfig ();
318318 if (status) return status;
319319 } else {
320- ALOGE (" %s: Expected keyword, got '%s'." , mTokenizer ->getLocation ().string (),
321- keywordToken.string ());
320+ ALOGE (" %s: Expected keyword, got '%s'." , mTokenizer ->getLocation ().c_str (),
321+ keywordToken.c_str ());
322322 return BAD_VALUE;
323323 }
324324
325325 mTokenizer ->skipDelimiters (WHITESPACE);
326326 if (!mTokenizer ->isEol () && mTokenizer ->peekChar () != ' #' ) {
327327 ALOGE (" %s: Expected end of line or trailing comment, got '%s'." ,
328- mTokenizer ->getLocation ().string (),
329- mTokenizer ->peekRemainderOfLine ().string ());
328+ mTokenizer ->getLocation ().c_str (), mTokenizer ->peekRemainderOfLine ().c_str ());
330329 return BAD_VALUE;
331330 }
332331 }
@@ -346,26 +345,26 @@ status_t KeyLayoutMap::Parser::parseKey() {
346345 }
347346
348347 char * end;
349- int32_t code = int32_t (strtol (codeToken.string (), &end, 0 ));
348+ int32_t code = int32_t (strtol (codeToken.c_str (), &end, 0 ));
350349 if (*end) {
351- ALOGE (" %s: Expected key %s number, got '%s'." , mTokenizer ->getLocation ().string (),
352- mapUsage ? " usage" : " scan code" , codeToken.string ());
350+ ALOGE (" %s: Expected key %s number, got '%s'." , mTokenizer ->getLocation ().c_str (),
351+ mapUsage ? " usage" : " scan code" , codeToken.c_str ());
353352 return BAD_VALUE;
354353 }
355354 std::unordered_map<int32_t , Key>& map =
356355 mapUsage ? mMap ->mKeysByUsageCode : mMap ->mKeysByScanCode ;
357356 if (map.find (code) != map.end ()) {
358- ALOGE (" %s: Duplicate entry for key %s '%s'." , mTokenizer ->getLocation ().string (),
359- mapUsage ? " usage" : " scan code" , codeToken.string ());
357+ ALOGE (" %s: Duplicate entry for key %s '%s'." , mTokenizer ->getLocation ().c_str (),
358+ mapUsage ? " usage" : " scan code" , codeToken.c_str ());
360359 return BAD_VALUE;
361360 }
362361
363362 mTokenizer ->skipDelimiters (WHITESPACE);
364363 String8 keyCodeToken = mTokenizer ->nextToken (WHITESPACE);
365- int32_t keyCode = InputEventLookup::getKeyCodeByLabel (keyCodeToken.string ());
364+ int32_t keyCode = InputEventLookup::getKeyCodeByLabel (keyCodeToken.c_str ());
366365 if (!keyCode) {
367- ALOGE (" %s: Expected key code label, got '%s'." , mTokenizer ->getLocation ().string (),
368- keyCodeToken.string ());
366+ ALOGE (" %s: Expected key code label, got '%s'." , mTokenizer ->getLocation ().c_str (),
367+ keyCodeToken.c_str ());
369368 return BAD_VALUE;
370369 }
371370
@@ -375,15 +374,15 @@ status_t KeyLayoutMap::Parser::parseKey() {
375374 if (mTokenizer ->isEol () || mTokenizer ->peekChar () == ' #' ) break ;
376375
377376 String8 flagToken = mTokenizer ->nextToken (WHITESPACE);
378- uint32_t flag = InputEventLookup::getKeyFlagByLabel (flagToken.string ());
377+ uint32_t flag = InputEventLookup::getKeyFlagByLabel (flagToken.c_str ());
379378 if (!flag) {
380- ALOGE (" %s: Expected key flag label, got '%s'." , mTokenizer ->getLocation ().string (),
381- flagToken.string ());
379+ ALOGE (" %s: Expected key flag label, got '%s'." , mTokenizer ->getLocation ().c_str (),
380+ flagToken.c_str ());
382381 return BAD_VALUE;
383382 }
384383 if (flags & flag) {
385- ALOGE (" %s: Duplicate key flag '%s'." , mTokenizer ->getLocation ().string (),
386- flagToken.string ());
384+ ALOGE (" %s: Duplicate key flag '%s'." , mTokenizer ->getLocation ().c_str (),
385+ flagToken.c_str ());
387386 return BAD_VALUE;
388387 }
389388 flags |= flag;
@@ -402,15 +401,15 @@ status_t KeyLayoutMap::Parser::parseKey() {
402401status_t KeyLayoutMap::Parser::parseAxis () {
403402 String8 scanCodeToken = mTokenizer ->nextToken (WHITESPACE);
404403 char * end;
405- int32_t scanCode = int32_t (strtol (scanCodeToken.string (), &end, 0 ));
404+ int32_t scanCode = int32_t (strtol (scanCodeToken.c_str (), &end, 0 ));
406405 if (*end) {
407- ALOGE (" %s: Expected axis scan code number, got '%s'." , mTokenizer ->getLocation ().string (),
408- scanCodeToken.string ());
406+ ALOGE (" %s: Expected axis scan code number, got '%s'." , mTokenizer ->getLocation ().c_str (),
407+ scanCodeToken.c_str ());
409408 return BAD_VALUE;
410409 }
411410 if (mMap ->mAxes .find (scanCode) != mMap ->mAxes .end ()) {
412- ALOGE (" %s: Duplicate entry for axis scan code '%s'." , mTokenizer ->getLocation ().string (),
413- scanCodeToken.string ());
411+ ALOGE (" %s: Duplicate entry for axis scan code '%s'." , mTokenizer ->getLocation ().c_str (),
412+ scanCodeToken.c_str ());
414413 return BAD_VALUE;
415414 }
416415
@@ -423,46 +422,46 @@ status_t KeyLayoutMap::Parser::parseAxis() {
423422
424423 mTokenizer ->skipDelimiters (WHITESPACE);
425424 String8 axisToken = mTokenizer ->nextToken (WHITESPACE);
426- axisInfo.axis = InputEventLookup::getAxisByLabel (axisToken.string ());
425+ axisInfo.axis = InputEventLookup::getAxisByLabel (axisToken.c_str ());
427426 if (axisInfo.axis < 0 ) {
428- ALOGE (" %s: Expected inverted axis label, got '%s'." ,
429- mTokenizer -> getLocation (). string (), axisToken.string ());
427+ ALOGE (" %s: Expected inverted axis label, got '%s'." , mTokenizer -> getLocation (). c_str (),
428+ axisToken.c_str ());
430429 return BAD_VALUE;
431430 }
432431 } else if (token == " split" ) {
433432 axisInfo.mode = AxisInfo::MODE_SPLIT;
434433
435434 mTokenizer ->skipDelimiters (WHITESPACE);
436435 String8 splitToken = mTokenizer ->nextToken (WHITESPACE);
437- axisInfo.splitValue = int32_t (strtol (splitToken.string (), &end, 0 ));
436+ axisInfo.splitValue = int32_t (strtol (splitToken.c_str (), &end, 0 ));
438437 if (*end) {
439- ALOGE (" %s: Expected split value, got '%s'." ,
440- mTokenizer -> getLocation (). string (), splitToken.string ());
438+ ALOGE (" %s: Expected split value, got '%s'." , mTokenizer -> getLocation (). c_str (),
439+ splitToken.c_str ());
441440 return BAD_VALUE;
442441 }
443442
444443 mTokenizer ->skipDelimiters (WHITESPACE);
445444 String8 lowAxisToken = mTokenizer ->nextToken (WHITESPACE);
446- axisInfo.axis = InputEventLookup::getAxisByLabel (lowAxisToken.string ());
445+ axisInfo.axis = InputEventLookup::getAxisByLabel (lowAxisToken.c_str ());
447446 if (axisInfo.axis < 0 ) {
448- ALOGE (" %s: Expected low axis label, got '%s'." ,
449- mTokenizer -> getLocation (). string (), lowAxisToken.string ());
447+ ALOGE (" %s: Expected low axis label, got '%s'." , mTokenizer -> getLocation (). c_str (),
448+ lowAxisToken.c_str ());
450449 return BAD_VALUE;
451450 }
452451
453452 mTokenizer ->skipDelimiters (WHITESPACE);
454453 String8 highAxisToken = mTokenizer ->nextToken (WHITESPACE);
455- axisInfo.highAxis = InputEventLookup::getAxisByLabel (highAxisToken.string ());
454+ axisInfo.highAxis = InputEventLookup::getAxisByLabel (highAxisToken.c_str ());
456455 if (axisInfo.highAxis < 0 ) {
457- ALOGE (" %s: Expected high axis label, got '%s'." ,
458- mTokenizer -> getLocation (). string (), highAxisToken.string ());
456+ ALOGE (" %s: Expected high axis label, got '%s'." , mTokenizer -> getLocation (). c_str (),
457+ highAxisToken.c_str ());
459458 return BAD_VALUE;
460459 }
461460 } else {
462- axisInfo.axis = InputEventLookup::getAxisByLabel (token.string ());
461+ axisInfo.axis = InputEventLookup::getAxisByLabel (token.c_str ());
463462 if (axisInfo.axis < 0 ) {
464463 ALOGE (" %s: Expected axis label, 'split' or 'invert', got '%s'." ,
465- mTokenizer ->getLocation ().string (), token.string ());
464+ mTokenizer ->getLocation ().c_str (), token.c_str ());
466465 return BAD_VALUE;
467466 }
468467 }
@@ -476,15 +475,15 @@ status_t KeyLayoutMap::Parser::parseAxis() {
476475 if (keywordToken == " flat" ) {
477476 mTokenizer ->skipDelimiters (WHITESPACE);
478477 String8 flatToken = mTokenizer ->nextToken (WHITESPACE);
479- axisInfo.flatOverride = int32_t (strtol (flatToken.string (), &end, 0 ));
478+ axisInfo.flatOverride = int32_t (strtol (flatToken.c_str (), &end, 0 ));
480479 if (*end) {
481- ALOGE (" %s: Expected flat value, got '%s'." ,
482- mTokenizer -> getLocation (). string (), flatToken.string ());
480+ ALOGE (" %s: Expected flat value, got '%s'." , mTokenizer -> getLocation (). c_str (),
481+ flatToken.c_str ());
483482 return BAD_VALUE;
484483 }
485484 } else {
486- ALOGE (" %s: Expected keyword 'flat', got '%s'." ,
487- mTokenizer -> getLocation (). string (), keywordToken.string ());
485+ ALOGE (" %s: Expected keyword 'flat', got '%s'." , mTokenizer -> getLocation (). c_str (),
486+ keywordToken.c_str ());
488487 return BAD_VALUE;
489488 }
490489 }
@@ -507,27 +506,27 @@ status_t KeyLayoutMap::Parser::parseLed() {
507506 codeToken = mTokenizer ->nextToken (WHITESPACE);
508507 }
509508 char * end;
510- int32_t code = int32_t (strtol (codeToken.string (), &end, 0 ));
509+ int32_t code = int32_t (strtol (codeToken.c_str (), &end, 0 ));
511510 if (*end) {
512- ALOGE (" %s: Expected led %s number, got '%s'." , mTokenizer ->getLocation ().string (),
513- mapUsage ? " usage" : " scan code" , codeToken.string ());
511+ ALOGE (" %s: Expected led %s number, got '%s'." , mTokenizer ->getLocation ().c_str (),
512+ mapUsage ? " usage" : " scan code" , codeToken.c_str ());
514513 return BAD_VALUE;
515514 }
516515
517516 std::unordered_map<int32_t , Led>& map =
518517 mapUsage ? mMap ->mLedsByUsageCode : mMap ->mLedsByScanCode ;
519518 if (map.find (code) != map.end ()) {
520- ALOGE (" %s: Duplicate entry for led %s '%s'." , mTokenizer ->getLocation ().string (),
521- mapUsage ? " usage" : " scan code" , codeToken.string ());
519+ ALOGE (" %s: Duplicate entry for led %s '%s'." , mTokenizer ->getLocation ().c_str (),
520+ mapUsage ? " usage" : " scan code" , codeToken.c_str ());
522521 return BAD_VALUE;
523522 }
524523
525524 mTokenizer ->skipDelimiters (WHITESPACE);
526525 String8 ledCodeToken = mTokenizer ->nextToken (WHITESPACE);
527- int32_t ledCode = InputEventLookup::getLedByLabel (ledCodeToken.string ());
526+ int32_t ledCode = InputEventLookup::getLedByLabel (ledCodeToken.c_str ());
528527 if (ledCode < 0 ) {
529- ALOGE (" %s: Expected LED code label, got '%s'." , mTokenizer ->getLocation ().string (),
530- ledCodeToken.string ());
528+ ALOGE (" %s: Expected LED code label, got '%s'." , mTokenizer ->getLocation ().c_str (),
529+ ledCodeToken.c_str ());
531530 return BAD_VALUE;
532531 }
533532
@@ -549,7 +548,7 @@ static std::optional<InputDeviceSensorType> getSensorType(const char* token) {
549548}
550549
551550static std::optional<int32_t > getSensorDataIndex (String8 token) {
552- std::string tokenStr (token.string ());
551+ std::string tokenStr (token.c_str ());
553552 if (tokenStr == " X" ) {
554553 return 0 ;
555554 } else if (tokenStr == " Y" ) {
@@ -575,35 +574,35 @@ static std::optional<int32_t> getSensorDataIndex(String8 token) {
575574status_t KeyLayoutMap::Parser::parseSensor () {
576575 String8 codeToken = mTokenizer ->nextToken (WHITESPACE);
577576 char * end;
578- int32_t code = int32_t (strtol (codeToken.string (), &end, 0 ));
577+ int32_t code = int32_t (strtol (codeToken.c_str (), &end, 0 ));
579578 if (*end) {
580- ALOGE (" %s: Expected sensor %s number, got '%s'." , mTokenizer ->getLocation ().string (),
581- " abs code" , codeToken.string ());
579+ ALOGE (" %s: Expected sensor %s number, got '%s'." , mTokenizer ->getLocation ().c_str (),
580+ " abs code" , codeToken.c_str ());
582581 return BAD_VALUE;
583582 }
584583
585584 std::unordered_map<int32_t , Sensor>& map = mMap ->mSensorsByAbsCode ;
586585 if (map.find (code) != map.end ()) {
587- ALOGE (" %s: Duplicate entry for sensor %s '%s'." , mTokenizer ->getLocation ().string (),
588- " abs code" , codeToken.string ());
586+ ALOGE (" %s: Duplicate entry for sensor %s '%s'." , mTokenizer ->getLocation ().c_str (),
587+ " abs code" , codeToken.c_str ());
589588 return BAD_VALUE;
590589 }
591590
592591 mTokenizer ->skipDelimiters (WHITESPACE);
593592 String8 sensorTypeToken = mTokenizer ->nextToken (WHITESPACE);
594- std::optional<InputDeviceSensorType> typeOpt = getSensorType (sensorTypeToken.string ());
593+ std::optional<InputDeviceSensorType> typeOpt = getSensorType (sensorTypeToken.c_str ());
595594 if (!typeOpt) {
596- ALOGE (" %s: Expected sensor code label, got '%s'." , mTokenizer ->getLocation ().string (),
597- sensorTypeToken.string ());
595+ ALOGE (" %s: Expected sensor code label, got '%s'." , mTokenizer ->getLocation ().c_str (),
596+ sensorTypeToken.c_str ());
598597 return BAD_VALUE;
599598 }
600599 InputDeviceSensorType sensorType = typeOpt.value ();
601600 mTokenizer ->skipDelimiters (WHITESPACE);
602601 String8 sensorDataIndexToken = mTokenizer ->nextToken (WHITESPACE);
603602 std::optional<int32_t > indexOpt = getSensorDataIndex (sensorDataIndexToken);
604603 if (!indexOpt) {
605- ALOGE (" %s: Expected sensor data index label, got '%s'." , mTokenizer ->getLocation ().string (),
606- sensorDataIndexToken.string ());
604+ ALOGE (" %s: Expected sensor data index label, got '%s'." , mTokenizer ->getLocation ().c_str (),
605+ sensorDataIndexToken.c_str ());
607606 return BAD_VALUE;
608607 }
609608 int32_t sensorDataIndex = indexOpt.value ();
@@ -624,12 +623,12 @@ status_t KeyLayoutMap::Parser::parseSensor() {
624623// requires_kernel_config CONFIG_HID_PLAYSTATION
625624status_t KeyLayoutMap::Parser::parseRequiredKernelConfig () {
626625 String8 codeToken = mTokenizer ->nextToken (WHITESPACE);
627- std::string configName = codeToken.string ();
626+ std::string configName = codeToken.c_str ();
628627
629628 const auto result = mMap ->mRequiredKernelConfigs .emplace (configName);
630629 if (!result.second ) {
631630 ALOGE (" %s: Duplicate entry for required kernel config %s." ,
632- mTokenizer ->getLocation ().string (), configName.c_str ());
631+ mTokenizer ->getLocation ().c_str (), configName.c_str ());
633632 return BAD_VALUE;
634633 }
635634
0 commit comments