Merge "libbinder: support exporting fewer symbols" into main
diff --git a/cmds/dumpstate/DumpstateUtil.h b/cmds/dumpstate/DumpstateUtil.h
index 9e955e3..ae7152a 100644
--- a/cmds/dumpstate/DumpstateUtil.h
+++ b/cmds/dumpstate/DumpstateUtil.h
@@ -18,6 +18,7 @@
#include <cstdint>
#include <string>
+#include <vector>
/*
* Converts seconds to milliseconds.
diff --git a/cmds/dumpstate/TEST_MAPPING b/cmds/dumpstate/TEST_MAPPING
index 649a13e..a24546a 100644
--- a/cmds/dumpstate/TEST_MAPPING
+++ b/cmds/dumpstate/TEST_MAPPING
@@ -10,6 +10,14 @@
},
{
"name": "dumpstate_test"
+ },
+ {
+ "name": "CtsSecurityHostTestCases",
+ "options": [
+ {
+ "include-filter": "android.security.cts.SELinuxHostTest#testNoBugreportDenials"
+ }
+ ]
}
],
"postsubmit": [
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index 39573ec..fbcf823 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -20,6 +20,7 @@
#include <inttypes.h>
#include <unistd.h>
+#include <condition_variable>
#include <android-base/properties.h>
#include <android/os/BnServiceCallback.h>
@@ -642,7 +643,7 @@
protected:
// Override realGetService for ServiceManagerShim::waitForService.
- Status realGetService(const std::string& name, sp<IBinder>* _aidl_return) {
+ Status realGetService(const std::string& name, sp<IBinder>* _aidl_return) override {
*_aidl_return = getDeviceService({"-g", name}, mOptions);
return Status::ok();
}
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 84ef489..77b3275 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -2768,7 +2768,7 @@
}
if (type == BINDER_TYPE_FD) {
// FDs from the kernel are always owned
- FdTag(flat->handle, 0, this);
+ FdTag(flat->handle, nullptr, this);
}
minOffset = offset + sizeof(flat_binder_object);
}
diff --git a/libs/binder/RecordedTransaction.cpp b/libs/binder/RecordedTransaction.cpp
index de2a69f..924537e 100644
--- a/libs/binder/RecordedTransaction.cpp
+++ b/libs/binder/RecordedTransaction.cpp
@@ -230,8 +230,8 @@
}
size_t memoryMappedSize = chunkPayloadSize + mmapPayloadStartOffset;
- void* mappedMemory =
- mmap(NULL, memoryMappedSize, PROT_READ, MAP_SHARED, fd.get(), mmapPageAlignedStart);
+ void* mappedMemory = mmap(nullptr, memoryMappedSize, PROT_READ, MAP_SHARED, fd.get(),
+ mmapPageAlignedStart);
auto mmap_guard = make_scope_guard(
[mappedMemory, memoryMappedSize] { munmap(mappedMemory, memoryMappedSize); });
@@ -382,7 +382,7 @@
return UNKNOWN_ERROR;
}
- if (NO_ERROR != writeChunk(fd, END_CHUNK, 0, NULL)) {
+ if (NO_ERROR != writeChunk(fd, END_CHUNK, 0, nullptr)) {
ALOGE("Failed to write end chunk to fd %d", fd.get());
return UNKNOWN_ERROR;
}
diff --git a/libs/binder/Stability.cpp b/libs/binder/Stability.cpp
index 665dfea..4fb8fa0 100644
--- a/libs/binder/Stability.cpp
+++ b/libs/binder/Stability.cpp
@@ -70,7 +70,7 @@
}
void Stability::tryMarkCompilationUnit(IBinder* binder) {
- (void)setRepr(binder, getLocalLevel(), REPR_NONE);
+ std::ignore = setRepr(binder, getLocalLevel(), REPR_NONE);
}
// after deprecation of the VNDK, these should be aliases. At some point
diff --git a/libs/binder/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h
index 298b2f4..5cc0830 100644
--- a/libs/binder/include/binder/Parcel.h
+++ b/libs/binder/include/binder/Parcel.h
@@ -1045,7 +1045,7 @@
typename std::enable_if_t<is_specialization_v<CT, std::vector>, bool> = true>
status_t writeData(const CT& c) {
using T = first_template_type_t<CT>; // The T in CT == C<T, ...>
- if (c.size() > std::numeric_limits<int32_t>::max()) return BAD_VALUE;
+ if (c.size() > static_cast<size_t>(std::numeric_limits<int32_t>::max())) return BAD_VALUE;
const auto size = static_cast<int32_t>(c.size());
writeData(size);
if constexpr (is_pointer_equivalent_array_v<T>) {
diff --git a/libs/binder/ndk/include_cpp/android/binder_auto_utils.h b/libs/binder/ndk/include_cpp/android/binder_auto_utils.h
index 18769b1..8c62924 100644
--- a/libs/binder/ndk/include_cpp/android/binder_auto_utils.h
+++ b/libs/binder/ndk/include_cpp/android/binder_auto_utils.h
@@ -377,7 +377,7 @@
namespace internal {
-static void closeWithError(int fd) {
+inline void closeWithError(int fd) {
if (fd == -1) return;
int ret = close(fd);
if (ret != 0) {
diff --git a/libs/binder/rust/Android.bp b/libs/binder/rust/Android.bp
index ef556d7..725744c 100644
--- a/libs/binder/rust/Android.bp
+++ b/libs/binder/rust/Android.bp
@@ -59,6 +59,7 @@
],
host_supported: true,
vendor_available: true,
+ product_available: true,
target: {
darwin: {
enabled: false,
diff --git a/libs/binder/tests/Android.bp b/libs/binder/tests/Android.bp
index 6800a8d..bd24a20 100644
--- a/libs/binder/tests/Android.bp
+++ b/libs/binder/tests/Android.bp
@@ -28,6 +28,11 @@
cflags: [
"-Wall",
"-Werror",
+ "-Wformat",
+ "-Wpessimizing-move",
+ "-Wsign-compare",
+ "-Wunused-result",
+ "-Wzero-as-null-pointer-constant",
],
}
diff --git a/libs/binder/tests/RpcTlsUtilsTest.cpp b/libs/binder/tests/RpcTlsUtilsTest.cpp
index 530606c..48e3345 100644
--- a/libs/binder/tests/RpcTlsUtilsTest.cpp
+++ b/libs/binder/tests/RpcTlsUtilsTest.cpp
@@ -52,9 +52,9 @@
<< "\nactual: " << toDebugString(deserializedPkey.get());
}
-INSTANTIATE_TEST_CASE_P(RpcTlsUtilsTest, RpcTlsUtilsKeyTest,
- testing::Values(RpcKeyFormat::PEM, RpcKeyFormat::DER),
- RpcTlsUtilsKeyTest::PrintParamInfo);
+INSTANTIATE_TEST_SUITE_P(RpcTlsUtilsTest, RpcTlsUtilsKeyTest,
+ testing::Values(RpcKeyFormat::PEM, RpcKeyFormat::DER),
+ RpcTlsUtilsKeyTest::PrintParamInfo);
class RpcTlsUtilsCertTest : public testing::TestWithParam<RpcCertificateFormat> {
public:
@@ -75,9 +75,9 @@
EXPECT_EQ(0, X509_cmp(cert.get(), deserializedCert.get()));
}
-INSTANTIATE_TEST_CASE_P(RpcTlsUtilsTest, RpcTlsUtilsCertTest,
- testing::Values(RpcCertificateFormat::PEM, RpcCertificateFormat::DER),
- RpcTlsUtilsCertTest::PrintParamInfo);
+INSTANTIATE_TEST_SUITE_P(RpcTlsUtilsTest, RpcTlsUtilsCertTest,
+ testing::Values(RpcCertificateFormat::PEM, RpcCertificateFormat::DER),
+ RpcTlsUtilsCertTest::PrintParamInfo);
class RpcTlsUtilsKeyAndCertTest
: public testing::TestWithParam<std::tuple<RpcKeyFormat, RpcCertificateFormat>> {
@@ -105,10 +105,10 @@
EXPECT_EQ(0, X509_cmp(cert.get(), deserializedCert.get()));
}
-INSTANTIATE_TEST_CASE_P(RpcTlsUtilsTest, RpcTlsUtilsKeyAndCertTest,
- testing::Combine(testing::Values(RpcKeyFormat::PEM, RpcKeyFormat::DER),
- testing::Values(RpcCertificateFormat::PEM,
- RpcCertificateFormat::DER)),
- RpcTlsUtilsKeyAndCertTest::PrintParamInfo);
+INSTANTIATE_TEST_SUITE_P(RpcTlsUtilsTest, RpcTlsUtilsKeyAndCertTest,
+ testing::Combine(testing::Values(RpcKeyFormat::PEM, RpcKeyFormat::DER),
+ testing::Values(RpcCertificateFormat::PEM,
+ RpcCertificateFormat::DER)),
+ RpcTlsUtilsKeyAndCertTest::PrintParamInfo);
} // namespace android
diff --git a/libs/binder/tests/binderAllocationLimits.cpp b/libs/binder/tests/binderAllocationLimits.cpp
index 7e0b594..c0c0aae 100644
--- a/libs/binder/tests/binderAllocationLimits.cpp
+++ b/libs/binder/tests/binderAllocationLimits.cpp
@@ -114,12 +114,12 @@
{
const auto on_malloc = OnMalloc([&](size_t bytes) {
mallocs++;
- EXPECT_EQ(bytes, 40);
+ EXPECT_EQ(bytes, 40u);
});
imaginary_use = new int[10];
}
- EXPECT_EQ(mallocs, 1);
+ EXPECT_EQ(mallocs, 1u);
}
@@ -196,9 +196,9 @@
// Happens to be SM package length. We could switch to forking
// and registering our own service if it became an issue.
#if defined(__LP64__)
- EXPECT_EQ(bytes, 78);
+ EXPECT_EQ(bytes, 78u);
#else
- EXPECT_EQ(bytes, 70);
+ EXPECT_EQ(bytes, 70u);
#endif
});
@@ -206,7 +206,7 @@
a_binder->getInterfaceDescriptor();
a_binder->getInterfaceDescriptor();
- EXPECT_EQ(mallocs, 1);
+ EXPECT_EQ(mallocs, 1u);
}
TEST(BinderAllocation, SmallTransaction) {
@@ -217,11 +217,11 @@
const auto on_malloc = OnMalloc([&](size_t bytes) {
mallocs++;
// Parcel should allocate a small amount by default
- EXPECT_EQ(bytes, 128);
+ EXPECT_EQ(bytes, 128u);
});
manager->checkService(empty_descriptor);
- EXPECT_EQ(mallocs, 1);
+ EXPECT_EQ(mallocs, 1u);
}
TEST(RpcBinderAllocation, SetupRpcServer) {
@@ -250,8 +250,8 @@
});
ASSERT_EQ(OK, remoteBinder->pingBinder());
}
- EXPECT_EQ(mallocs, 1);
- EXPECT_EQ(totalBytes, 40);
+ EXPECT_EQ(mallocs, 1u);
+ EXPECT_EQ(totalBytes, 40u);
}
int main(int argc, char** argv) {
diff --git a/libs/binder/tests/binderClearBufTest.cpp b/libs/binder/tests/binderClearBufTest.cpp
index e43ee5f..3230a3f 100644
--- a/libs/binder/tests/binderClearBufTest.cpp
+++ b/libs/binder/tests/binderClearBufTest.cpp
@@ -88,7 +88,7 @@
// the buffer must have at least some length for the string, but we will
// just check it has some length, to avoid assuming anything about the
// format
- EXPECT_GT(replyBuffer.size(), 0);
+ EXPECT_GT(replyBuffer.size(), 0u);
for (size_t i = 0; i < replyBuffer.size(); i++) {
EXPECT_EQ(replyBuffer[i], '0') << "reply buffer at " << i;
diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp
index 1f61f18..9788d9d 100644
--- a/libs/binder/tests/binderLibTest.cpp
+++ b/libs/binder/tests/binderLibTest.cpp
@@ -528,8 +528,8 @@
EXPECT_EQ(NO_ERROR, IPCThreadState::self()->getProcessFreezeInfo(pid, &sync_received,
&async_received));
- EXPECT_EQ(sync_received, 1);
- EXPECT_EQ(async_received, 0);
+ EXPECT_EQ(sync_received, 1u);
+ EXPECT_EQ(async_received, 0u);
EXPECT_EQ(NO_ERROR, IPCThreadState::self()->freeze(pid, false, 0));
EXPECT_EQ(NO_ERROR, m_server->transact(BINDER_LIB_TEST_NOP_TRANSACTION, data, &reply));
@@ -1238,13 +1238,13 @@
data.setDataCapacity(1024);
// Write a bogus object at offset 0 to get an entry in the offset table
data.writeFileDescriptor(0);
- EXPECT_EQ(data.objectsCount(), 1);
+ EXPECT_EQ(data.objectsCount(), 1u);
uint8_t *parcelData = const_cast<uint8_t*>(data.data());
// And now, overwrite it with the buffer object
memcpy(parcelData, &obj, sizeof(obj));
data.setDataSize(sizeof(obj));
- EXPECT_EQ(data.objectsCount(), 1);
+ EXPECT_EQ(data.objectsCount(), 1u);
// Either the kernel should reject this transaction (if it's correct), but
// if it's not, the server implementation should return an error if it
@@ -1269,7 +1269,7 @@
data.setDataCapacity(1024);
// Write a bogus object at offset 0 to get an entry in the offset table
data.writeFileDescriptor(0);
- EXPECT_EQ(data.objectsCount(), 1);
+ EXPECT_EQ(data.objectsCount(), 1u);
uint8_t *parcelData = const_cast<uint8_t *>(data.data());
// And now, overwrite it with the weak binder
memcpy(parcelData, &obj, sizeof(obj));
@@ -1279,7 +1279,7 @@
// test with an object that libbinder will actually try to release
EXPECT_EQ(OK, data.writeStrongBinder(sp<BBinder>::make()));
- EXPECT_EQ(data.objectsCount(), 2);
+ EXPECT_EQ(data.objectsCount(), 2u);
// send it many times, since previous error was memory corruption, make it
// more likely that the server crashes
@@ -1648,8 +1648,8 @@
EXPECT_THAT(binder->setRpcClientDebug(std::move(socket), nullptr),
Debuggable(StatusEq(UNEXPECTED_NULL)));
}
-INSTANTIATE_TEST_CASE_P(BinderLibTest, BinderLibRpcTestP, testing::Bool(),
- BinderLibRpcTestP::ParamToString);
+INSTANTIATE_TEST_SUITE_P(BinderLibTest, BinderLibRpcTestP, testing::Bool(),
+ BinderLibRpcTestP::ParamToString);
class BinderLibTestService : public BBinder {
public:
diff --git a/libs/binder/tests/binderRpcBenchmark.cpp b/libs/binder/tests/binderRpcBenchmark.cpp
index 4f10d74..865f0ec 100644
--- a/libs/binder/tests/binderRpcBenchmark.cpp
+++ b/libs/binder/tests/binderRpcBenchmark.cpp
@@ -216,7 +216,7 @@
// by how many binder calls work together (and by factors like the scheduler,
// thermal throttling, core choice, etc..).
std::string str = std::string(getpagesize() * 2, 'a');
- CHECK_EQ(str.size(), getpagesize() * 2);
+ CHECK_EQ(static_cast<ssize_t>(str.size()), getpagesize() * 2);
while (state.KeepRunning()) {
std::string out;
diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp
index 2769a88..c044d39 100644
--- a/libs/binder/tests/binderRpcTest.cpp
+++ b/libs/binder/tests/binderRpcTest.cpp
@@ -64,12 +64,12 @@
static std::string WaitStatusToString(int wstatus) {
if (WIFEXITED(wstatus)) {
- return std::format("exit status {}", WEXITSTATUS(wstatus));
+ return "exit status " + std::to_string(WEXITSTATUS(wstatus));
}
if (WIFSIGNALED(wstatus)) {
- return std::format("term signal {}", WTERMSIG(wstatus));
+ return "term signal " + std::to_string(WTERMSIG(wstatus));
}
- return std::format("unexpected state {}", wstatus);
+ return "unexpected state " + std::to_string(wstatus);
}
static void debugBacktrace(pid_t pid) {
@@ -177,7 +177,7 @@
EXPECT_NE(nullptr, session);
EXPECT_NE(nullptr, session->state());
- EXPECT_EQ(0, session->state()->countBinders()) << (session->state()->dump(), "dump:");
+ EXPECT_EQ(0u, session->state()->countBinders()) << (session->state()->dump(), "dump:");
wp<RpcSession> weakSession = session;
session = nullptr;
@@ -235,7 +235,7 @@
if (binder::os::sendMessageOnSocket(transportFd, &iov, 1, &fds) < 0) {
PLOGF("Failed sendMessageOnSocket");
}
- return std::move(sockClient);
+ return sockClient;
}
#endif // BINDER_RPC_TO_TRUSTY_TEST
@@ -263,9 +263,8 @@
bool noKernel = GetParam().noKernel;
std::string path = GetExecutableDirectory();
- auto servicePath =
- std::format("{}/binder_rpc_test_service{}{}", path,
- singleThreaded ? "_single_threaded" : "", noKernel ? "_no_kernel" : "");
+ auto servicePath = path + "/binder_rpc_test_service" +
+ (singleThreaded ? "_single_threaded" : "") + (noKernel ? "_no_kernel" : "");
unique_fd bootstrapClientFd, socketFd;
@@ -623,7 +622,7 @@
for (size_t i = 0; i + 1 < kNumQueued; i++) {
int n;
proc.rootIface->blockingRecvInt(&n);
- EXPECT_EQ(n, i);
+ EXPECT_EQ(n, static_cast<ssize_t>(i));
}
saturateThreadPool(1 + kNumExtraServerThreads, proc.rootIface);
@@ -1148,8 +1147,8 @@
return ret;
}
-INSTANTIATE_TEST_CASE_P(Trusty, BinderRpc, ::testing::ValuesIn(getTrustyBinderRpcParams()),
- BinderRpc::PrintParamInfo);
+INSTANTIATE_TEST_SUITE_P(Trusty, BinderRpc, ::testing::ValuesIn(getTrustyBinderRpcParams()),
+ BinderRpc::PrintParamInfo);
#else // BINDER_RPC_TO_TRUSTY_TEST
bool testSupportVsockLoopback() {
// We don't need to enable TLS to know if vsock is supported.
@@ -1308,8 +1307,8 @@
return ret;
}
-INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc, ::testing::ValuesIn(getBinderRpcParams()),
- BinderRpc::PrintParamInfo);
+INSTANTIATE_TEST_SUITE_P(PerSocket, BinderRpc, ::testing::ValuesIn(getBinderRpcParams()),
+ BinderRpc::PrintParamInfo);
class BinderRpcServerRootObject
: public ::testing::TestWithParam<std::tuple<bool, bool, RpcSecurity>> {};
@@ -1337,9 +1336,9 @@
EXPECT_EQ((isStrong2 ? binderRaw2 : nullptr), server->getRootObject());
}
-INSTANTIATE_TEST_CASE_P(BinderRpc, BinderRpcServerRootObject,
- ::testing::Combine(::testing::Bool(), ::testing::Bool(),
- ::testing::ValuesIn(RpcSecurityValues())));
+INSTANTIATE_TEST_SUITE_P(BinderRpc, BinderRpcServerRootObject,
+ ::testing::Combine(::testing::Bool(), ::testing::Bool(),
+ ::testing::ValuesIn(RpcSecurityValues())));
class OneOffSignal {
public:
@@ -1384,7 +1383,7 @@
auto binder = sm->checkService(String16("batteryproperties"));
ASSERT_NE(nullptr, binder);
auto descriptor = binder->getInterfaceDescriptor();
- ASSERT_GE(descriptor.size(), 0);
+ ASSERT_GE(descriptor.size(), 0u);
ASSERT_EQ(OK, binder->pingBinder());
auto rpcServer = RpcServer::make();
@@ -1468,10 +1467,10 @@
<< "After server->shutdown() returns true, join() did not stop after 2s";
}
-INSTANTIATE_TEST_CASE_P(BinderRpc, BinderRpcServerOnly,
- ::testing::Combine(::testing::ValuesIn(RpcSecurityValues()),
- ::testing::ValuesIn(testVersions())),
- BinderRpcServerOnly::PrintTestParam);
+INSTANTIATE_TEST_SUITE_P(BinderRpc, BinderRpcServerOnly,
+ ::testing::Combine(::testing::ValuesIn(RpcSecurityValues()),
+ ::testing::ValuesIn(testVersions())),
+ BinderRpcServerOnly::PrintTestParam);
class RpcTransportTestUtils {
public:
@@ -2018,9 +2017,9 @@
server->shutdown();
}
-INSTANTIATE_TEST_CASE_P(BinderRpc, RpcTransportTest,
- ::testing::ValuesIn(RpcTransportTest::getRpcTranportTestParams()),
- RpcTransportTest::PrintParamInfo);
+INSTANTIATE_TEST_SUITE_P(BinderRpc, RpcTransportTest,
+ ::testing::ValuesIn(RpcTransportTest::getRpcTranportTestParams()),
+ RpcTransportTest::PrintParamInfo);
class RpcTransportTlsKeyTest
: public testing::TestWithParam<
@@ -2075,7 +2074,7 @@
client.run();
}
-INSTANTIATE_TEST_CASE_P(
+INSTANTIATE_TEST_SUITE_P(
BinderRpc, RpcTransportTlsKeyTest,
testing::Combine(testing::ValuesIn(testSocketTypes(false /* hasPreconnected*/)),
testing::Values(RpcCertificateFormat::PEM, RpcCertificateFormat::DER),
diff --git a/libs/binder/tests/binderRpcTestCommon.h b/libs/binder/tests/binderRpcTestCommon.h
index 8832f1a..acc0373 100644
--- a/libs/binder/tests/binderRpcTestCommon.h
+++ b/libs/binder/tests/binderRpcTestCommon.h
@@ -60,7 +60,6 @@
#include "../FdUtils.h"
#include "../RpcState.h" // for debugging
#include "FileUtils.h"
-#include "format.h"
#include "utils/Errors.h"
namespace android {
@@ -99,7 +98,7 @@
}
static inline std::string trustyIpcPort(uint32_t serverVersion) {
- return std::format("com.android.trusty.binderRpcTestService.V{}", serverVersion);
+ return "com.android.trusty.binderRpcTestService.V" + std::to_string(serverVersion);
}
enum class SocketType {
@@ -210,7 +209,7 @@
return RpcTransportCtxFactoryTls::make(std::move(verifier), std::move(auth));
}
default:
- LOG_ALWAYS_FATAL("Unknown RpcSecurity %d", rpcSecurity);
+ LOG_ALWAYS_FATAL("Unknown RpcSecurity %d", static_cast<int>(rpcSecurity));
}
}
@@ -256,7 +255,7 @@
mValue.reset();
lock.unlock();
mCvEmpty.notify_all();
- return std::move(v);
+ return v;
}
private:
diff --git a/libs/binder/tests/binderRpcTestTrusty.cpp b/libs/binder/tests/binderRpcTestTrusty.cpp
index 18751cc..31c0eba 100644
--- a/libs/binder/tests/binderRpcTestTrusty.cpp
+++ b/libs/binder/tests/binderRpcTestTrusty.cpp
@@ -45,7 +45,7 @@
case RpcSecurity::RAW:
return RpcTransportCtxFactoryTipcTrusty::make();
default:
- LOG_ALWAYS_FATAL("Unknown RpcSecurity %d", rpcSecurity);
+ LOG_ALWAYS_FATAL("Unknown RpcSecurity %d", static_cast<int>(rpcSecurity));
}
}
@@ -110,8 +110,8 @@
return ret;
}
-INSTANTIATE_TEST_CASE_P(Trusty, BinderRpc, ::testing::ValuesIn(getTrustyBinderRpcParams()),
- BinderRpc::PrintParamInfo);
+INSTANTIATE_TEST_SUITE_P(Trusty, BinderRpc, ::testing::ValuesIn(getTrustyBinderRpcParams()),
+ BinderRpc::PrintParamInfo);
} // namespace android
diff --git a/libs/binder/tests/format.h b/libs/binder/tests/format.h
deleted file mode 100644
index c588de7..0000000
--- a/libs/binder/tests/format.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-// TODO(b/302723053): remove this header and replace with <format> once b/175635923 is done
-// ETA for this blocker is 2023-10-27~2023-11-10.
-// Also, remember to remove fmtlib's format.cc from trusty makefiles.
-
-#if __has_include(<format>) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
-#include <format>
-#else
-#include <fmt/format.h>
-
-namespace std {
-using fmt::format;
-}
-#endif
\ No newline at end of file
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
index 20b3538..400ca9f 100644
--- a/libs/input/Android.bp
+++ b/libs/input/Android.bp
@@ -80,10 +80,6 @@
visibility: ["//frameworks/native/services/inputflinger"],
wrapper_src: "InputWrapper.hpp",
- include_dirs: [
- "frameworks/native/include",
- ],
-
source_stem: "bindings",
bindgen_flags: [
diff --git a/libs/ui/DisplayIdentification.cpp b/libs/ui/DisplayIdentification.cpp
index 82e5427..ed7f193 100644
--- a/libs/ui/DisplayIdentification.cpp
+++ b/libs/ui/DisplayIdentification.cpp
@@ -374,6 +374,11 @@
std::optional<DisplayIdentificationInfo> parseDisplayIdentificationData(
uint8_t port, const DisplayIdentificationData& data) {
+ if (data.empty()) {
+ ALOGI("Display identification data is empty.");
+ return {};
+ }
+
if (!isEdid(data)) {
ALOGE("Display identification data has unknown format.");
return {};
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index 1ada33e..5b5afd3 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -254,6 +254,7 @@
}
}
+ std::vector<std::string> extensionStrings;
{ // scope for lock
std::lock_guard<std::mutex> _l(lock);
@@ -315,16 +316,14 @@
}
mClientApiString = sClientApiString;
- mExtensionString = gBuiltinExtensionString;
-
// b/269060366 Conditionally enabled EGL_ANDROID_get_frame_timestamps extension if the
// device's present timestamps are reliable (which may not be the case on emulators).
if (cnx->angleLoaded) {
if (android::base::GetBoolProperty("service.sf.present_timestamp", false)) {
- mExtensionString.append("EGL_ANDROID_get_frame_timestamps ");
+ extensionStrings.push_back("EGL_ANDROID_get_frame_timestamps");
}
} else {
- mExtensionString.append("EGL_ANDROID_get_frame_timestamps ");
+ extensionStrings.push_back("EGL_ANDROID_get_frame_timestamps");
}
hasColorSpaceSupport = findExtension(disp.queryString.extensions, "EGL_KHR_gl_colorspace");
@@ -335,10 +334,12 @@
// Add wide-color extensions if device can support wide-color
if (wideColorBoardConfig && hasColorSpaceSupport) {
- mExtensionString.append(
- "EGL_EXT_gl_colorspace_scrgb EGL_EXT_gl_colorspace_scrgb_linear "
- "EGL_EXT_gl_colorspace_display_p3_linear EGL_EXT_gl_colorspace_display_p3 "
- "EGL_EXT_gl_colorspace_display_p3_passthrough ");
+ std::vector<std::string> wideColorExtensions =
+ {"EGL_EXT_gl_colorspace_scrgb", "EGL_EXT_gl_colorspace_scrgb_linear",
+ "EGL_EXT_gl_colorspace_display_p3_linear", "EGL_EXT_gl_colorspace_display_p3",
+ "EGL_EXT_gl_colorspace_display_p3_passthrough"};
+ extensionStrings.insert(extensionStrings.end(), wideColorExtensions.begin(),
+ wideColorExtensions.end());
}
bool hasHdrBoardConfig = android::sysprop::has_HDR_display(false);
@@ -348,9 +349,11 @@
// Typically that means there is an HDR capable display attached, but could be
// support for attaching an HDR display. In either case, advertise support for
// HDR color spaces.
- mExtensionString.append("EGL_EXT_gl_colorspace_bt2020_hlg "
- "EGL_EXT_gl_colorspace_bt2020_linear "
- "EGL_EXT_gl_colorspace_bt2020_pq ");
+ std::vector<std::string> hdrExtensions = {"EGL_EXT_gl_colorspace_bt2020_hlg",
+ "EGL_EXT_gl_colorspace_bt2020_linear",
+ "EGL_EXT_gl_colorspace_bt2020_pq"};
+ extensionStrings.insert(extensionStrings.end(), hdrExtensions.begin(),
+ hdrExtensions.end());
}
char const* start = gExtensionString;
@@ -361,7 +364,7 @@
// NOTE: we could avoid the copy if we had strnstr.
const std::string ext(start, len);
if (findExtension(disp.queryString.extensions, ext.c_str(), len)) {
- mExtensionString.append(ext + " ");
+ extensionStrings.push_back(ext);
}
// advance to the next extension name, skipping the space.
start += len;
@@ -388,6 +391,14 @@
refCond.notify_all();
}
+ auto mergeExtensionStrings = [](const std::vector<std::string>& strings) {
+ std::ostringstream combinedStringStream;
+ std::copy(strings.begin(), strings.end(),
+ std::ostream_iterator<std::string>(combinedStringStream, " "));
+ // gBuiltinExtensionString already has a trailing space so is added here
+ return gBuiltinExtensionString + combinedStringStream.str();
+ };
+ mExtensionString = mergeExtensionStrings(extensionStrings);
return EGL_TRUE;
}
diff --git a/opengl/tests/EGLTest/Android.bp b/opengl/tests/EGLTest/Android.bp
index d96a895..aebd3f2 100644
--- a/opengl/tests/EGLTest/Android.bp
+++ b/opengl/tests/EGLTest/Android.bp
@@ -37,6 +37,11 @@
"libSurfaceFlingerProp",
],
+ static_libs: [
+ "libgmock",
+ "libgtest",
+ ],
+
include_dirs: [
"frameworks/native/opengl/libs",
"frameworks/native/opengl/libs/EGL",
diff --git a/opengl/tests/EGLTest/EGL_test.cpp b/opengl/tests/EGLTest/EGL_test.cpp
index cbe4ef9..503d7df 100644
--- a/opengl/tests/EGLTest/EGL_test.cpp
+++ b/opengl/tests/EGLTest/EGL_test.cpp
@@ -15,6 +15,7 @@
*/
#include <gtest/gtest.h>
+#include <gmock/gmock.h>
#include <SurfaceFlingerProperties.h>
#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
@@ -29,6 +30,8 @@
#include <gui/IGraphicBufferConsumer.h>
#include <gui/BufferQueue.h>
+#include "egl_display.h"
+
bool hasEglExtension(EGLDisplay dpy, const char* extensionName) {
const char* exts = eglQueryString(dpy, EGL_EXTENSIONS);
size_t cropExtLen = strlen(extensionName);
@@ -1011,4 +1014,57 @@
EXPECT_TRUE(eglDestroySurface(mEglDisplay, eglSurface));
}
+
+TEST_F(EGLTest, EGLCheckExtensionString) {
+ // check that the format of the extension string is correct
+
+ egl_display_t* display = egl_display_t::get(mEglDisplay);
+ ASSERT_NE(display, nullptr);
+
+ std::string extensionStrRegex = "((EGL_ANDROID_front_buffer_auto_refresh|"
+ "EGL_ANDROID_get_native_client_buffer|"
+ "EGL_ANDROID_presentation_time|"
+ "EGL_EXT_surface_CTA861_3_metadata|"
+ "EGL_EXT_surface_SMPTE2086_metadata|"
+ "EGL_KHR_get_all_proc_addresses|"
+ "EGL_KHR_swap_buffers_with_damage|"
+ "EGL_ANDROID_get_frame_timestamps|"
+ "EGL_EXT_gl_colorspace_scrgb|"
+ "EGL_EXT_gl_colorspace_scrgb_linear|"
+ "EGL_EXT_gl_colorspace_display_p3_linear|"
+ "EGL_EXT_gl_colorspace_display_p3|"
+ "EGL_EXT_gl_colorspace_display_p3_passthrough|"
+ "EGL_EXT_gl_colorspace_bt2020_hlg|"
+ "EGL_EXT_gl_colorspace_bt2020_linear|"
+ "EGL_EXT_gl_colorspace_bt2020_pq|"
+ "EGL_ANDROID_image_native_buffer|"
+ "EGL_ANDROID_native_fence_sync|"
+ "EGL_ANDROID_recordable|"
+ "EGL_EXT_create_context_robustness|"
+ "EGL_EXT_image_gl_colorspace|"
+ "EGL_EXT_pixel_format_float|"
+ "EGL_EXT_protected_content|"
+ "EGL_EXT_yuv_surface|"
+ "EGL_IMG_context_priority|"
+ "EGL_KHR_config_attribs|"
+ "EGL_KHR_create_context|"
+ "EGL_KHR_fence_sync|"
+ "EGL_KHR_gl_colorspace|"
+ "EGL_KHR_gl_renderbuffer_image|"
+ "EGL_KHR_gl_texture_2D_image|"
+ "EGL_KHR_gl_texture_3D_image|"
+ "EGL_KHR_gl_texture_cubemap_image|"
+ "EGL_KHR_image|"
+ "EGL_KHR_image_base|"
+ "EGL_KHR_mutable_render_buffer|"
+ "EGL_KHR_no_config_context|"
+ "EGL_KHR_partial_update|"
+ "EGL_KHR_surfaceless_context|"
+ "EGL_KHR_wait_sync|"
+ "EGL_EXT_buffer_age|"
+ "EGL_KHR_reusable_sync|"
+ "EGL_NV_context_priority_realtime) )+";
+ EXPECT_THAT(display->getExtensionString(), testing::MatchesRegex(extensionStrRegex));
+}
+
}
diff --git a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
index 5a74a42..82f9276 100644
--- a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
@@ -140,13 +140,14 @@
// Assign pointer id using tracking id if available.
if (mHavePointerIds) {
- int32_t trackingId = inSlot.getTrackingId();
+ const int32_t trackingId = inSlot.getTrackingId();
int32_t id = -1;
if (trackingId >= 0) {
for (BitSet32 idBits(mPointerIdBits); !idBits.isEmpty();) {
uint32_t n = idBits.clearFirstMarkedBit();
if (mPointerTrackingIdMap[n] == trackingId) {
id = n;
+ break;
}
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index b980a65..ab0598d 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -6270,12 +6270,17 @@
uint8_t port;
DisplayIdentificationData data;
if (!getHwComposer().getDisplayIdentificationData(*hwcDisplayId, &port, &data)) {
- result.append("no identification data\n");
+ result.append("no display identification data\n");
+ continue;
+ }
+
+ if (data.empty()) {
+ result.append("empty display identification data\n");
continue;
}
if (!isEdid(data)) {
- result.append("unknown identification data\n");
+ result.append("unknown format for display identification data\n");
continue;
}