Merge "clang-format: PointerAlignment LEFT"
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index 6d64e1e..da58251 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -1221,6 +1221,10 @@
return NO_ERROR;
}
+ ALOGE_IF(mProcess->mDriverFD >= 0,
+ "Driver returned error (%s). This is a bug in either libbinder or the driver. This "
+ "thread's connection to %s will no longer work.",
+ statusToString(err).c_str(), mProcess->mDriverName.c_str());
return err;
}
diff --git a/libs/binder/include/binder/ParcelFileDescriptor.h b/libs/binder/include/binder/ParcelFileDescriptor.h
index 9896fd7..08d8e43 100644
--- a/libs/binder/include/binder/ParcelFileDescriptor.h
+++ b/libs/binder/include/binder/ParcelFileDescriptor.h
@@ -42,6 +42,7 @@
android::status_t writeToParcel(android::Parcel* parcel) const override;
android::status_t readFromParcel(const android::Parcel* parcel) override;
+ inline std::string toString() const { return "ParcelFileDescriptor:" + std::to_string(get()); }
inline bool operator!=(const ParcelFileDescriptor& rhs) const {
return mFd.get() != rhs.mFd.get();
}
diff --git a/libs/binder/include/binder/ParcelableHolder.h b/libs/binder/include/binder/ParcelableHolder.h
index 88790a8..40fd30a 100644
--- a/libs/binder/include/binder/ParcelableHolder.h
+++ b/libs/binder/include/binder/ParcelableHolder.h
@@ -111,6 +111,11 @@
Stability getStability() const override { return mStability; }
+ inline std::string toString() const {
+ return "ParcelableHolder:" +
+ (mParcelableName ? std::string(String8(mParcelableName.value()).c_str())
+ : "<parceled>");
+ }
inline bool operator!=(const ParcelableHolder& rhs) const {
return this != &rhs;
}
diff --git a/libs/binder/ndk/include_cpp/android/binder_to_string.h b/libs/binder/ndk/include_cpp/android/binder_to_string.h
index e3ead11..9b0d222 100644
--- a/libs/binder/ndk/include_cpp/android/binder_to_string.h
+++ b/libs/binder/ndk/include_cpp/android/binder_to_string.h
@@ -58,8 +58,6 @@
#if __has_include(<binder/RpcSession.h>)
#include <binder/IBinder.h>
#include <binder/IInterface.h>
-#include <binder/ParcelFileDescriptor.h>
-#include <binder/ParcelableHolder.h>
#define HAS_CPP_INTERFACE
#endif
@@ -152,9 +150,7 @@
#endif // HAS_NDK_INTERFACE
#ifdef HAS_CPP_INTERFACE
|| std::is_base_of_v<IInterface, _U> ||
- std::is_same_v<IBinder, _U> ||
- std::is_same_v<os::ParcelFileDescriptor, _U> ||
- std::is_same_v<os::ParcelableHolder, _U>
+ std::is_same_v<IBinder, _U>
#endif
,
std::true_type>
diff --git a/libs/binder/tests/binderUtilsHostTest.cpp b/libs/binder/tests/binderUtilsHostTest.cpp
index 4330e3e..25e286c 100644
--- a/libs/binder/tests/binderUtilsHostTest.cpp
+++ b/libs/binder/tests/binderUtilsHostTest.cpp
@@ -37,17 +37,24 @@
EXPECT_EQ(result->stdoutStr, "foo\n");
}
+template <typename T>
+auto millisSince(std::chrono::time_point<T> now) {
+ auto elapsed = std::chrono::system_clock::now() - now;
+ return std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count();
+}
+
TEST(UtilsHost, ExecuteLongRunning) {
- auto now = std::chrono::system_clock::now();
+ auto start = std::chrono::system_clock::now();
{
- std::vector<std::string> args{"sh", "-c",
- "sleep 0.5 && echo -n f && sleep 0.5 && echo oo && sleep 1"};
- auto result = execute(std::move(args), [](const CommandResult& commandResult) {
+ std::vector<std::string>
+ args{"sh", "-c", "sleep 0.5 && echo -n f && sleep 0.5 && echo oo && sleep 100"};
+ auto result = execute(std::move(args), [&](const CommandResult& commandResult) {
+ std::cout << millisSince(start)
+ << "ms: GOT PARTIAL COMMAND RESULT:" << commandResult.stdoutStr << std::endl;
return android::base::EndsWith(commandResult.stdoutStr, "\n");
});
- auto elapsed = std::chrono::system_clock::now() - now;
- auto elapsedMs = std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count();
+ auto elapsedMs = millisSince(start);
EXPECT_GE(elapsedMs, 1000);
EXPECT_LT(elapsedMs, 2000);
@@ -58,22 +65,21 @@
// ~CommandResult() called, child process is killed.
// Assert that the second sleep does not finish.
- auto elapsed = std::chrono::system_clock::now() - now;
- auto elapsedMs = std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count();
- EXPECT_LT(elapsedMs, 2000);
+ EXPECT_LT(millisSince(start), 2000);
}
TEST(UtilsHost, ExecuteLongRunning2) {
- auto now = std::chrono::system_clock::now();
+ auto start = std::chrono::system_clock::now();
{
std::vector<std::string> args{"sh", "-c",
- "sleep 2 && echo -n f && sleep 2 && echo oo && sleep 2"};
- auto result = execute(std::move(args), [](const CommandResult& commandResult) {
+ "sleep 2 && echo -n f && sleep 2 && echo oo && sleep 100"};
+ auto result = execute(std::move(args), [&](const CommandResult& commandResult) {
+ std::cout << millisSince(start)
+ << "ms: GOT PARTIAL COMMAND RESULT:" << commandResult.stdoutStr << std::endl;
return android::base::EndsWith(commandResult.stdoutStr, "\n");
});
- auto elapsed = std::chrono::system_clock::now() - now;
- auto elapsedMs = std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count();
+ auto elapsedMs = millisSince(start);
EXPECT_GE(elapsedMs, 4000);
EXPECT_LT(elapsedMs, 6000);
@@ -84,9 +90,7 @@
// ~CommandResult() called, child process is killed.
// Assert that the second sleep does not finish.
- auto elapsed = std::chrono::system_clock::now() - now;
- auto elapsedMs = std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count();
- EXPECT_LT(elapsedMs, 6000);
+ EXPECT_LT(millisSince(start), 6000);
}
TEST(UtilsHost, KillWithSigKill) {