libbase: Shim old StartsWith function prototype

* The str parameter StartsWith function in libbase got changed
  from std::string to std::string_view in later android versions [1].

* Create a shim that provides the older StartsWith function.

[1]: ef973cee17

Change-Id: I116a32a739d6fa34ecc0d1a4acf8b2e3756910ea
This commit is contained in:
bengris32 2023-09-30 14:34:20 +00:00 committed by R0rt1z2
parent d549dba0e3
commit 015d90baa5
2 changed files with 20 additions and 1 deletions

View file

@ -256,7 +256,10 @@ cc_defaults {
cc_library {
name: "libbase_shim",
shared_libs: ["libbase"],
srcs: ["libbase/logging.cpp"],
srcs: [
"libbase/logging.cpp",
"libbase/strings.cpp",
],
vendor: true
}

16
libbase/strings.cpp Normal file
View file

@ -0,0 +1,16 @@
/*
* Copyright (C) 2023 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include <string>
namespace android {
namespace base {
bool StartsWith(const std::string& s, const char* prefix) {
return strncmp(s.c_str(), prefix, strlen(prefix)) == 0;
}
} // namespace base
} // namespace android