Merge "Fix incorrect match when looking for files."
diff --git a/Android.mk b/Android.mk
index 0b78c87..8e69e18 100644
--- a/Android.mk
+++ b/Android.mk
@@ -11,7 +11,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-ifneq ($(filter vsoc_arm vsoc_arm64 vsoc_x86 vsoc_x86_64 vsoc_x86_noapex, $(TARGET_DEVICE)),)
+ifneq ($(filter vsoc_arm64 vsoc_x86 vsoc_x86_64, $(TARGET_BOARD_PLATFORM)),)
 LOCAL_PATH:= $(call my-dir)
 include $(call first-makefiles-under,$(LOCAL_PATH))
 endif
diff --git a/common/frontend/socket_vsock_proxy/Android.bp b/common/frontend/socket_vsock_proxy/Android.bp
index 0a2f572..d079e20 100644
--- a/common/frontend/socket_vsock_proxy/Android.bp
+++ b/common/frontend/socket_vsock_proxy/Android.bp
@@ -23,7 +23,6 @@
         "libbase",
         "libcuttlefish_fs",
         "libcuttlefish_utils",
-        "libcuttlefish_strings",
         "liblog",
     ],
     static_libs: [
diff --git a/common/libs/net/netlink_request.cpp b/common/libs/net/netlink_request.cpp
index ebd84bb..501b2c3 100644
--- a/common/libs/net/netlink_request.cpp
+++ b/common/libs/net/netlink_request.cpp
@@ -20,6 +20,7 @@
 #include <net/if.h>
 #include <string.h>
 
+#include <algorithm>
 #include <string>
 #include <vector>
 
@@ -35,11 +36,10 @@
 }
 
 void* NetlinkRequest::AppendRaw(const void* data, size_t length) {
-  size_t original_size = request_.size();
-  request_.resize(original_size + RTA_ALIGN(length), '\0');
-  memcpy(request_.data() + original_size, data, length);
-
-  return reinterpret_cast<void*>(request_.data() + original_size);
+  auto* output = static_cast<char*>(ReserveRaw(length));
+  const auto* input = static_cast<const char*>(data);
+  std::copy(input, input + length, output);
+  return output;
 }
 
 void* NetlinkRequest::ReserveRaw(size_t length) {
diff --git a/common/libs/utils/Android.bp b/common/libs/utils/Android.bp
index 1bd252d..f2a5aff 100644
--- a/common/libs/utils/Android.bp
+++ b/common/libs/utils/Android.bp
@@ -31,7 +31,6 @@
         shared_libs: [
             "libbase",
             "libcuttlefish_fs",
-            "libcuttlefish_strings",
             "cuttlefish_auto_resources",
         ],
     },
@@ -39,7 +38,6 @@
         static_libs: [
             "libbase",
             "libcuttlefish_fs",
-            "libcuttlefish_strings",
             "cuttlefish_auto_resources",
         ],
     },
diff --git a/common/libs/utils/archive.cpp b/common/libs/utils/archive.cpp
index a22db4f..c1c496d 100644
--- a/common/libs/utils/archive.cpp
+++ b/common/libs/utils/archive.cpp
@@ -19,9 +19,9 @@
 #include <string>
 #include <vector>
 
+#include <android-base/strings.h>
 #include <glog/logging.h>
 
-#include "common/libs/strings/str_split.h"
 #include "common/libs/utils/subprocess.h"
 
 namespace cvd {
@@ -43,7 +43,7 @@
     LOG(ERROR) << "`bsdtar -tf \"" << file << "\"` returned " << bsdtar_ret;
   }
   return bsdtar_ret == 0
-      ? cvd::StrSplit(bsdtar_output, '\n')
+      ? android::base::Split(bsdtar_output, "\n")
       : std::vector<std::string>();
 }
 
diff --git a/host/commands/assemble_cvd/Android.bp b/host/commands/assemble_cvd/Android.bp
index 10f4e31..c5ac4c9 100644
--- a/host/commands/assemble_cvd/Android.bp
+++ b/host/commands/assemble_cvd/Android.bp
@@ -46,7 +46,6 @@
         "cdisk_spec",
         "vsoc_lib",
         "libcuttlefish_fs",
-        "libcuttlefish_strings",
         "libcuttlefish_utils",
         "cuttlefish_auto_resources",
         "libbase",
diff --git a/host/commands/assemble_cvd/assemble_cvd.cc b/host/commands/assemble_cvd/assemble_cvd.cc
index 6eab814..c829395 100644
--- a/host/commands/assemble_cvd/assemble_cvd.cc
+++ b/host/commands/assemble_cvd/assemble_cvd.cc
@@ -15,11 +15,11 @@
 
 #include <iostream>
 
+#include <android-base/strings.h>
 #include <glog/logging.h>
 
 #include "common/libs/fs/shared_buf.h"
 #include "common/libs/fs/shared_fd.h"
-#include "common/libs/strings/str_split.h"
 #include "host/commands/assemble_cvd/assembler_defs.h"
 #include "host/commands/assemble_cvd/flags.h"
 #include "host/libs/config/fetcher_config.h"
@@ -68,7 +68,7 @@
       LOG(FATAL) << "Failed to read input files. Error was \"" << input_fd->StrError() << "\"";
     }
   }
-  std::vector<std::string> input_files = cvd::StrSplit(input_files_str, '\n');
+  std::vector<std::string> input_files = android::base::Split(input_files_str, "\n");
 
   auto config = InitFilesystemAndCreateConfig(&argc, &argv, FindFetcherConfig(input_files));
 
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index 38fada3..5ae5a91 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -3,10 +3,10 @@
 #include <iostream>
 #include <fstream>
 
+#include <android-base/strings.h>
 #include <gflags/gflags.h>
 #include <glog/logging.h>
 
-#include "common/libs/strings/str_split.h"
 #include "common/libs/utils/environment.h"
 #include "common/libs/utils/files.h"
 #include "common/vsoc/lib/vsoc_memory.h"
@@ -316,7 +316,7 @@
   tmp_config_obj.set_num_screen_buffers(FLAGS_num_screen_buffers);
   tmp_config_obj.set_refresh_rate_hz(FLAGS_refresh_rate_hz);
   tmp_config_obj.set_gdb_flag(FLAGS_qemu_gdb);
-  std::vector<std::string> adb = cvd::StrSplit(FLAGS_adb_mode, ',');
+  std::vector<std::string> adb = android::base::Split(FLAGS_adb_mode, ",");
   tmp_config_obj.set_adb_mode(std::set<std::string>(adb.begin(), adb.end()));
   tmp_config_obj.set_host_port(GetHostPort());
   tmp_config_obj.set_adb_ip_and_port("127.0.0.1:" + std::to_string(GetHostPort()));
diff --git a/host/commands/fetcher/Android.bp b/host/commands/fetcher/Android.bp
index 786455f..6af562c 100644
--- a/host/commands/fetcher/Android.bp
+++ b/host/commands/fetcher/Android.bp
@@ -31,7 +31,6 @@
         "libbase",
         "libcuttlefish_host_config",
         "libcuttlefish_fs",
-        "libcuttlefish_strings",
         "libcuttlefish_utils",
         "libcurl",
         "libcrypto",
diff --git a/host/commands/kernel_log_monitor/Android.bp b/host/commands/kernel_log_monitor/Android.bp
index 7bc29e0..a7197e5 100644
--- a/host/commands/kernel_log_monitor/Android.bp
+++ b/host/commands/kernel_log_monitor/Android.bp
@@ -24,7 +24,6 @@
     ],
     shared_libs: [
         "libcuttlefish_fs",
-        "libcuttlefish_strings",
         "libcuttlefish_utils",
         "cuttlefish_auto_resources",
         "libbase",
diff --git a/host/commands/kernel_log_monitor/main.cc b/host/commands/kernel_log_monitor/main.cc
index 1f0ead3..6956e68 100644
--- a/host/commands/kernel_log_monitor/main.cc
+++ b/host/commands/kernel_log_monitor/main.cc
@@ -20,12 +20,12 @@
 #include <string>
 #include <vector>
 
+#include <android-base/strings.h>
 #include <gflags/gflags.h>
 #include <glog/logging.h>
 
 #include <common/libs/fs/shared_fd.h>
 #include <common/libs/fs/shared_select.h>
-#include <common/libs/strings/str_split.h>
 #include <host/libs/config/cuttlefish_config.h>
 #include "host/commands/kernel_log_monitor/kernel_log_server.h"
 
@@ -47,7 +47,7 @@
     }
   }
 
-  auto fds = cvd::StrSplit(FLAGS_subscriber_fds, ',');
+  auto fds = android::base::Split(FLAGS_subscriber_fds, ",");
   std::vector<cvd::SharedFD> shared_fds;
   for (auto& fd_str: fds) {
     auto fd = std::stoi(fd_str);
diff --git a/host/commands/launch/Android.bp b/host/commands/launch/Android.bp
index a40a07d..e2db615 100644
--- a/host/commands/launch/Android.bp
+++ b/host/commands/launch/Android.bp
@@ -26,7 +26,6 @@
     shared_libs: [
         "vsoc_lib",
         "libcuttlefish_fs",
-        "libcuttlefish_strings",
         "libcuttlefish_utils",
         "cuttlefish_auto_resources",
         "libbase",
diff --git a/host/commands/run_cvd/Android.bp b/host/commands/run_cvd/Android.bp
index 5629d6a..29238c9 100644
--- a/host/commands/run_cvd/Android.bp
+++ b/host/commands/run_cvd/Android.bp
@@ -28,7 +28,6 @@
     shared_libs: [
         "vsoc_lib",
         "libcuttlefish_fs",
-        "libcuttlefish_strings",
         "libcuttlefish_utils",
         "cuttlefish_auto_resources",
         "libbase",
diff --git a/host/commands/run_cvd/main.cc b/host/commands/run_cvd/main.cc
index 663b7f0..dd5ed4d 100644
--- a/host/commands/run_cvd/main.cc
+++ b/host/commands/run_cvd/main.cc
@@ -35,13 +35,13 @@
 #include <thread>
 #include <vector>
 
+#include <android-base/strings.h>
 #include <gflags/gflags.h>
 #include <glog/logging.h>
 
 #include "common/libs/fs/shared_buf.h"
 #include "common/libs/fs/shared_fd.h"
 #include "common/libs/fs/shared_select.h"
-#include "common/libs/strings/str_split.h"
 #include "common/libs/utils/environment.h"
 #include "common/libs/utils/files.h"
 #include "common/libs/utils/subprocess.h"
@@ -351,7 +351,7 @@
       LOG(FATAL) << "Failed to read input files. Error was \"" << input_fd->StrError() << "\"";
     }
   }
-  std::vector<std::string> input_files = cvd::StrSplit(input_files_str, '\n');
+  std::vector<std::string> input_files = android::base::Split(input_files_str, "\n");
   bool found_config = false;
   for (const auto& file : input_files) {
     if (file.find("cuttlefish_config.json") != std::string::npos) {
diff --git a/host/frontend/adb_connector/Android.bp b/host/frontend/adb_connector/Android.bp
index 3af5ef1..41fa1f6 100644
--- a/host/frontend/adb_connector/Android.bp
+++ b/host/frontend/adb_connector/Android.bp
@@ -28,7 +28,6 @@
     shared_libs: [
         "libbase",
         "libcuttlefish_fs",
-        "libcuttlefish_strings",
         "liblog",
     ],
     defaults: ["cuttlefish_host_only"],
diff --git a/tests/hidl/hidl_implementation_test.cpp b/tests/hidl/hidl_implementation_test.cpp
index 85a58fe..562950b 100644
--- a/tests/hidl/hidl_implementation_test.cpp
+++ b/tests/hidl/hidl_implementation_test.cpp
@@ -42,8 +42,6 @@
     "android.hardware.bluetooth.a2dp@1.0",
     "android.hardware.broadcastradio@1.1",
     "android.hardware.broadcastradio@2.0",
-    "android.hardware.camera.device@1.0",
-    "android.hardware.camera.device@3.5",
     "android.hardware.camera.provider@2.5",
     "android.hardware.cas@1.2",
     "android.hardware.cas.native@1.0",
@@ -84,7 +82,7 @@
     "android.hardware.tv.tuner@1.0",
     "android.hardware.usb@1.2",
     "android.hardware.usb.gadget@1.0",
-    "android.hardware.vibrator@1.4",
+    "android.hardware.vibrator@1.3",
     "android.hardware.vr@1.0",
     "android.hardware.weaver@1.0",
     "android.hardware.wifi@1.3",
@@ -100,6 +98,8 @@
     static std::vector<std::string> gAospExclude = {
         // packages not implemented now that we never expect to be implemented
         "android.hardware.tests",
+        // packages not registered with hwservicemanager, usually sub-interfaces
+        "android.hardware.camera.device",
     };
     for (const std::string& package : gAospExclude) {
         if (name.inPackage(package)) {
diff --git a/tools/create_base_image_arm.sh b/tools/create_base_image_arm.sh
index d79334b..87756df 100755
--- a/tools/create_base_image_arm.sh
+++ b/tools/create_base_image_arm.sh
@@ -219,11 +219,11 @@
 	setenv serverip ${TftpServer}
 	setenv loadaddr 0x00200000
 	mmc dev 0 0;
-	file=$TplSplImg; offset=0x40; size=0x1f80; run tftpget1; setenv TplSplImg
-	file=$UbootItb;  offset=0x4000; size=0x2000; run tftpget1; setenv UbootItb
-	file=$TrustImg; offset=0x6000; size=0x2000; run tftpget1; setenv TrustImg
-	file=$RootfsImg; offset=0x8000; size=0; run tftpget1; setenv RootfsImg
-	file=$UbootEnv; offset=0x1fc0; size=0x40; run tftpget1; setenv UbootEnv
+	setenv file $TplSplImg; offset=0x40; size=0x1f80; run tftpget1; setenv TplSplImg
+	setenv file $UbootItb;  offset=0x4000; size=0x2000; run tftpget1; setenv UbootItb
+	setenv file $TrustImg; offset=0x6000; size=0x2000; run tftpget1; setenv TrustImg
+	setenv file $RootfsImg; offset=0x8000; size=0; run tftpget1; setenv RootfsImg
+	setenv file $UbootEnv; offset=0x1fc0; size=0x40; run tftpget1; setenv UbootEnv
 	mw.b ${scriptaddr} 0 0x8000
 	env export -b ${scriptaddr} 0x8000
 	mmc write ${scriptaddr} 0x1fc0 0x40
@@ -237,11 +237,11 @@
 		setenv serverip ${TftpServer}
 		setenv loadaddr 0x00200000
 		mmc dev 0 0;
-		file=$TplSplImg; offset=0x40; size=0x1f80; run tftpget1; setenv TplSplImg
-		file=$UbootItb;  offset=0x4000; size=0x2000; run tftpget1; setenv UbootItb
-		file=$TrustImg; offset=0x6000; size=0x2000; run tftpget1; setenv TrustImg
-		file=$RootfsImg; offset=0x8000; size=0; run tftpget1; setenv RootfsImg
-		file=$UbootEnv; offset=0x1fc0; size=0x40; run tftpget1; setenv UbootEnv
+		setenv file $TplSplImg; offset=0x40; size=0x1f80; run tftpget1; setenv TplSplImg
+		setenv file $UbootItb;  offset=0x4000; size=0x2000; run tftpget1; setenv UbootItb
+		setenv file $TrustImg; offset=0x6000; size=0x2000; run tftpget1; setenv TrustImg
+		setenv file $RootfsImg; offset=0x8000; size=0; run tftpget1; setenv RootfsImg
+		setenv file $UbootEnv; offset=0x1fc0; size=0x40; run tftpget1; setenv UbootEnv
 		mw.b ${scriptaddr} 0 0x8000
 		env export -b ${scriptaddr} 0x8000
 		mmc write ${scriptaddr} 0x1fc0 0x40
@@ -249,32 +249,39 @@
 		echo "Already have ${Sha}. Booting..."
 	fi
 else
-	echo "Update ${Sha} isn't for me. Booting..."
+	echo "Update ${Sha} is not for me. Booting..."
 fi'
-setenv tftpget1 "
-mw.b ${loadaddr} 0 0x400000
-&& tftp ${file}
-&& isGz=0 && setexpr isGz sub .*\\.gz\$ 1 ${file}
-&& if test $isGz = 1; then
-	setexpr boffset ${offset} * 0x200
-	&& gzwrite mmc 0 ${loadaddr} 0x${filesize} 100000 ${boffset}
-	&& echo Updated: ${bootfile}
-elif test ${file} = boot.env; then
-	env import -b ${loadaddr}
-	&& echo Updated: boot.env
-else
-	&& if test $size = 0; then
-		setexpr x $filesize - 1
-		&& setexpr x $x / 0x1000
-		&& setexpr x $x + 1
-		&& setexpr x $x * 0x1000
-		&& setexpr x $x / 0x200
-		&& size=0x${x}
+setenv tftpget1 '
+if test "$file" != ""; then
+	mw.b ${loadaddr} 0 0x400000
+	tftp ${file}
+	if test $? = 0; then
+		setenv isGz 0 && setexpr isGz sub .*\\.gz\$ 1 ${file}
+		if test $isGz = 1; then
+			if test ${file} = ${UbootEnv}; then
+				echo "** gzipped env unsupported **"
+			else
+				setexpr boffset ${offset} * 0x200
+				gzwrite mmc 0 ${loadaddr} 0x${filesize} 100000 ${boffset} && echo Updated: ${file}
+			fi
+		elif test ${file} = ${UbootEnv}; then
+			env import -b ${loadaddr} && echo Updated: ${file}
+		else
+			if test $size = 0; then
+				setexpr x $filesize - 1
+				setexpr x $x / 0x1000
+				setexpr x $x + 1
+				setexpr x $x * 0x1000
+				setexpr x $x / 0x200
+				size=0x${x}
+			fi
+			mmc write ${loadaddr} ${offset} ${size} && echo Updated: ${file}
+		fi
 	fi
-	&& mmc write ${loadaddr} ${offset} ${size}
-	&& echo Updated: ${bootfile}
-fi
-|| echo ** UPDATE FAILED: ${bootfile} **"
+	if test $? != 0; then
+		echo ** UPDATE FAILED: ${file} **
+	fi
+fi'
 if mmc dev 1 0; then; else
 	run bootcmd_dhcp;
 fi
@@ -481,7 +488,7 @@
 #!/bin/bash
 echo "Installing cuttlefish-common package..."
 echo "nameserver 8.8.8.8" > /etc/resolv.conf
-MAC=`ip link | grep eth0 -A1 | grep ether | sed 's/.*\(..:..:..:..:..:..\) .*/\1/'`
+MAC=`ip link | grep eth0 -A1 | grep ether | sed 's/.*\(..:..:..:..:..:..\) .*/\1/' | tr -d :`
 sed -i " 1 s/.*/& rockpi-${MAC}/" /etc/hosts
 sudo hostnamectl set-hostname "rockpi-${MAC}"
 
diff --git a/tools/make_manifest.sh b/tools/make_manifest.sh
index 3babc33..5b07d5d 100755
--- a/tools/make_manifest.sh
+++ b/tools/make_manifest.sh
@@ -69,19 +69,19 @@
 		echo "${key}=${value}" >> manifest.txt
 }
 
-addSHAToManifest() {
-	key="SHA"
+addShaToManifest() {
+	key="Sha"
 	cd "${ANDROID_BUILD_TOP}/device/google/cuttlefish_common"
-	SHA=`git rev-parse HEAD`
+	Sha=`git rev-parse HEAD`
 	cd -
 	cd "${ANDROID_BUILD_TOP}/external/u-boot"
-	SHA="$SHA,`git rev-parse HEAD`"
+	Sha="$Sha,`git rev-parse HEAD`"
 	cd -
 	cd "${ANDROID_BUILD_TOP}/external/arm-trusted-firmware"
-	SHA="$SHA,`git rev-parse HEAD`"
+	Sha="$Sha,`git rev-parse HEAD`"
 	cd -
 
-	addKVToManifest "${key}" "${SHA}"
+	addKVToManifest "${key}" "${Sha}"
 }
 
 addPathToManifest() {
@@ -116,4 +116,4 @@
 addPathToManifest UbootEnv ${FLAGS_env}
 addPathToManifest TplSplImg ${FLAGS_loader1}
 addPathToManifest UbootItb ${FLAGS_loader2}
-addSHAToManifest
+addShaToManifest