Clean up errno logs and sto* conversions

I learned that we should be using PLOG to log errno strings, and we
should be avoiding stoi, stol, etc... conversions and instead use the
built in Android ParseInt/ParseUint functions.

Bug: 150250606
Bug: 150245058
Test: Manual for CLI tools, VTS for everything else
Merged-In: Icdd8a6af8564d5de3bedd1bc934f7928eb5e66e9
Change-Id: Icdd8a6af8564d5de3bedd1bc934f7928eb5e66e9
(cherry picked from commit 1173a7253becba2b548057112372c8a94d9b6a41)
diff --git a/automotive/can/1.0/tools/canhalsend.cpp b/automotive/can/1.0/tools/canhalsend.cpp
index 7e6833a..b22ad4d 100644
--- a/automotive/can/1.0/tools/canhalsend.cpp
+++ b/automotive/can/1.0/tools/canhalsend.cpp
@@ -81,16 +81,17 @@
     const std::string msgidStr = msg.substr(0, hashpos);
     const std::string payloadStr = msg.substr(hashpos + 1);
 
-    size_t idx = 0;
-    V1_0::CanMessageId msgid = std::stoi(msgidStr, &idx, 16);
-    if (msgidStr[idx] != '\0') return std::nullopt;
+    V1_0::CanMessageId msgid;
+    // "0x" must be prepended to msgidStr, since ParseUint doesn't accept a base argument.
+    if (!android::base::ParseUint("0x" + msgidStr, &msgid)) return std::nullopt;
 
     std::vector<uint8_t> payload;
     if (payloadStr.size() % 2 != 0) return std::nullopt;
     for (size_t i = 0; i < payloadStr.size(); i += 2) {
         std::string byteStr(payloadStr, i, 2);
-        payload.emplace_back(std::stoi(byteStr, &idx, 16));
-        if (byteStr[idx] != '\0') return std::nullopt;
+        uint8_t byteBuf;
+        if (!android::base::ParseUint("0x" + byteStr, &byteBuf)) return std::nullopt;
+        payload.emplace_back(byteBuf);
     }
 
     return {{msgid, payload}};