Merge "Fix whitespace errors"
diff --git a/cmds/dumpstate/DumpstateUtil.cpp b/cmds/dumpstate/DumpstateUtil.cpp
index 97c8ae2..4b69607 100644
--- a/cmds/dumpstate/DumpstateUtil.cpp
+++ b/cmds/dumpstate/DumpstateUtil.cpp
@@ -378,34 +378,6 @@
return status;
}
-int GetPidByName(const std::string& ps_name) {
- DIR* proc_dir;
- struct dirent* ps;
- unsigned int pid;
- std::string cmdline;
-
- if (!(proc_dir = opendir("/proc"))) {
- MYLOGE("Can't open /proc\n");
- return -1;
- }
-
- while ((ps = readdir(proc_dir))) {
- if (!(pid = atoi(ps->d_name))) {
- continue;
- }
- android::base::ReadFileToString("/proc/" + std::string(ps->d_name) + "/cmdline", &cmdline);
- if (cmdline.find(ps_name) == std::string::npos) {
- continue;
- } else {
- closedir(proc_dir);
- return pid;
- }
- }
- MYLOGE("can't find the pid\n");
- closedir(proc_dir);
- return -1;
-}
-
} // namespace dumpstate
} // namespace os
} // namespace android
diff --git a/cmds/dumpstate/DumpstateUtil.h b/cmds/dumpstate/DumpstateUtil.h
index d75b08c..b7ac25c 100644
--- a/cmds/dumpstate/DumpstateUtil.h
+++ b/cmds/dumpstate/DumpstateUtil.h
@@ -205,12 +205,6 @@
*/
int DumpFileToFd(int fd, const std::string& title, const std::string& path);
-/*
- * Finds the process id by process name.
- * |ps_name| the process name we want to search for
- */
-int GetPidByName(const std::string& ps_name);
-
} // namespace dumpstate
} // namespace os
} // namespace android
diff --git a/cmds/dumpstate/tests/dumpstate_test.cpp b/cmds/dumpstate/tests/dumpstate_test.cpp
index 0e88e43..4e6b084 100644
--- a/cmds/dumpstate/tests/dumpstate_test.cpp
+++ b/cmds/dumpstate/tests/dumpstate_test.cpp
@@ -1406,14 +1406,6 @@
return status;
}
- // Find out the pid of the process_name
- int FindPidOfProcess(const std::string& process_name) {
- CaptureStderr();
- int status = GetPidByName(process_name);
- err = GetCapturedStderr();
- return status;
- }
-
int fd;
// 'fd` output and `stderr` from the last command ran.
@@ -1763,18 +1755,6 @@
EXPECT_THAT(out, EndsWith("skipped on dry run\n"));
}
-TEST_F(DumpstateUtilTest, FindingPidWithExistingProcess) {
- // init process always has pid 1.
- EXPECT_EQ(1, FindPidOfProcess("init"));
- EXPECT_THAT(err, IsEmpty());
-}
-
-TEST_F(DumpstateUtilTest, FindingPidWithNotExistingProcess) {
- // find the process with abnormal name.
- EXPECT_EQ(-1, FindPidOfProcess("abcdef12345-543"));
- EXPECT_THAT(err, StrEq("can't find the pid\n"));
-}
-
} // namespace dumpstate
} // namespace os
} // namespace android
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index 4cbf577..e08c806 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -725,7 +725,11 @@
return -1;
}
fcntl(s, F_SETFD, FD_CLOEXEC);
- if (listen(s, 4) < 0) {
+
+ // Set backlog to 0 to make sure that queue size will be minimum.
+ // In Linux, because the minimum queue will be 1, connect() will be blocked
+ // if the other clients already called connect() and the connection request was not accepted.
+ if (listen(s, 0) < 0) {
MYLOGE("listen(control socket): %s\n", strerror(errno));
return -1;
}
@@ -736,6 +740,9 @@
// Close socket just after accept(), to make sure that connect() by client will get error
// when the socket is used by the other services.
+ // There is still a race condition possibility between accept and close, but there is no way
+ // to close-on-accept atomically.
+ // See detail; b/123306389#comment25
close(s);
if (fd < 0) {
diff --git a/cmds/installd/otapreopt_chroot.cpp b/cmds/installd/otapreopt_chroot.cpp
index 0c4badf..b4bcd53 100644
--- a/cmds/installd/otapreopt_chroot.cpp
+++ b/cmds/installd/otapreopt_chroot.cpp
@@ -236,6 +236,18 @@
// the Android Runtime APEX, as it is required by otapreopt to run dex2oat.
std::vector<apex::ApexFile> active_packages = ActivateApexPackages();
+ // Check that an Android Runtime APEX has been activated; clean up and exit
+ // early otherwise.
+ if (std::none_of(active_packages.begin(),
+ active_packages.end(),
+ [](const apex::ApexFile& package){
+ return package.GetManifest().name() == "com.android.runtime";
+ })) {
+ LOG(FATAL_WITHOUT_ABORT) << "No activated com.android.runtime APEX package.";
+ DeactivateApexPackages(active_packages);
+ exit(217);
+ }
+
// Now go on and run otapreopt.
// Incoming: cmd + status-fd + target-slot + cmd... | Incoming | = argc
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index acc6bf4..3b889fb 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -953,7 +953,7 @@
if (err >= NO_ERROR) {
if (bwr.write_consumed > 0) {
if (bwr.write_consumed < mOut.dataSize())
- mOut.remove(0, bwr.write_consumed);
+ LOG_ALWAYS_FATAL("Driver did not consume write buffer");
else {
mOut.setDataSize(0);
processPostWriteDerefs();
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 7ccb171..a1ddec8 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -622,11 +622,6 @@
}
}
-const binder_size_t* Parcel::objects() const
-{
- return mObjects;
-}
-
size_t Parcel::objectsCount() const
{
return mObjectsSize;
@@ -1345,11 +1340,6 @@
return status.writeToParcel(this);
}
-void Parcel::remove(size_t /*start*/, size_t /*amt*/)
-{
- LOG_ALWAYS_FATAL("Parcel::remove() not yet implemented!");
-}
-
status_t Parcel::validateReadData(size_t upperBound) const
{
// Don't allow non-object reads on object data
@@ -2388,7 +2378,7 @@
} else if (dataSize() > 0) {
const uint8_t* DATA = data();
to << indent << HexDump(DATA, dataSize()) << dedent;
- const binder_size_t* OBJS = objects();
+ const binder_size_t* OBJS = mObjects;
const size_t N = objectsCount();
for (size_t i=0; i<N; i++) {
const flat_binder_object* flat
diff --git a/libs/binder/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h
index 7cd067e..117b90a 100644
--- a/libs/binder/include/binder/Parcel.h
+++ b/libs/binder/include/binder/Parcel.h
@@ -97,10 +97,6 @@
void freeData();
-private:
- const binder_size_t* objects() const;
-
-public:
size_t objectsCount() const;
status_t errorCheck() const;
@@ -237,8 +233,6 @@
// Currently the native implementation doesn't do any of the StrictMode
// stack gathering and serialization that the Java implementation does.
status_t writeNoException();
-
- void remove(size_t start, size_t amt);
status_t read(void* outData, size_t len) const;
const void* readInplace(size_t len) const;
diff --git a/libs/binder/tests/Android.bp b/libs/binder/tests/Android.bp
index b465681..edbe05e 100644
--- a/libs/binder/tests/Android.bp
+++ b/libs/binder/tests/Android.bp
@@ -71,6 +71,7 @@
"libbinder",
"libutils",
],
+ test_suites: ["device-tests"],
}
cc_test {
@@ -136,4 +137,5 @@
"liblog",
"libutils",
],
+ test_suites: ["device-tests"],
}