Merge "emulator: update EGL emulation library path"
diff --git a/cmds/lshal/Android.bp b/cmds/lshal/Android.bp
index 67b5b46..2eed1ce 100644
--- a/cmds/lshal/Android.bp
+++ b/cmds/lshal/Android.bp
@@ -28,6 +28,7 @@
"Lshal.cpp",
"ListCommand.cpp",
"PipeRelay.cpp",
+ "TextTable.cpp",
"utils.cpp",
],
}
diff --git a/cmds/lshal/ListCommand.cpp b/cmds/lshal/ListCommand.cpp
index 7c6cfd9..31c42e7 100644
--- a/cmds/lshal/ListCommand.cpp
+++ b/cmds/lshal/ListCommand.cpp
@@ -35,6 +35,7 @@
#include "Lshal.h"
#include "PipeRelay.h"
+#include "TextTable.h"
#include "Timeout.h"
#include "utils.h"
@@ -206,42 +207,46 @@
}
}
-void ListCommand::printLine(
- const std::string &interfaceName,
- const std::string &transport,
- const std::string &arch,
- const std::string &threadUsage,
- const std::string &server,
- const std::string &serverCmdline,
- const std::string &address,
- const std::string &clients,
- const std::string &clientCmdlines) const {
- if (mSelectedColumns & ENABLE_INTERFACE_NAME)
- mOut << std::setw(80) << interfaceName << "\t";
- if (mSelectedColumns & ENABLE_TRANSPORT)
- mOut << std::setw(10) << transport << "\t";
- if (mSelectedColumns & ENABLE_ARCH)
- mOut << std::setw(5) << arch << "\t";
- if (mSelectedColumns & ENABLE_THREADS) {
- mOut << std::setw(8) << threadUsage << "\t";
- }
- if (mSelectedColumns & ENABLE_SERVER_PID) {
- if (mEnableCmdlines) {
- mOut << std::setw(15) << serverCmdline << "\t";
- } else {
- mOut << std::setw(5) << server << "\t";
+void ListCommand::addLine(TextTable *textTable, const std::string &interfaceName,
+ const std::string &transport, const std::string &arch,
+ const std::string &threadUsage, const std::string &server,
+ const std::string &serverCmdline, const std::string &address,
+ const std::string &clients, const std::string &clientCmdlines) const {
+ std::vector<std::string> columns;
+ for (TableColumnType type : mSelectedColumns) {
+ switch (type) {
+ case TableColumnType::INTERFACE_NAME: {
+ columns.push_back(interfaceName);
+ } break;
+ case TableColumnType::TRANSPORT: {
+ columns.push_back(transport);
+ } break;
+ case TableColumnType::ARCH: {
+ columns.push_back(arch);
+ } break;
+ case TableColumnType::THREADS: {
+ columns.push_back(threadUsage);
+ } break;
+ case TableColumnType::SERVER_ADDR: {
+ columns.push_back(address);
+ } break;
+ case TableColumnType::SERVER_PID: {
+ if (mEnableCmdlines) {
+ columns.push_back(serverCmdline);
+ } else {
+ columns.push_back(server);
+ }
+ } break;
+ case TableColumnType::CLIENT_PIDS: {
+ if (mEnableCmdlines) {
+ columns.push_back(clientCmdlines);
+ } else {
+ columns.push_back(clients);
+ }
+ } break;
}
}
- if (mSelectedColumns & ENABLE_SERVER_ADDR)
- mOut << std::setw(16) << address << "\t";
- if (mSelectedColumns & ENABLE_CLIENT_PIDS) {
- if (mEnableCmdlines) {
- mOut << std::setw(0) << clientCmdlines;
- } else {
- mOut << std::setw(0) << clients;
- }
- }
- mOut << std::endl;
+ textTable->add(std::move(columns));
}
static inline bool findAndBumpVersion(vintf::ManifestHal* hal, const vintf::Version& version) {
@@ -397,7 +402,25 @@
}
}
+void ListCommand::addLine(TextTable *table, const TableEntry &entry) {
+ addLine(table, entry.interfaceName, entry.transport, getArchString(entry.arch),
+ entry.getThreadUsage(),
+ entry.serverPid == NO_PID ? "N/A" : std::to_string(entry.serverPid),
+ entry.serverCmdline,
+ entry.serverObjectAddress == NO_PTR ? "N/A" : toHexString(entry.serverObjectAddress),
+ join(entry.clientPids, " "), join(entry.clientCmdlines, ";"));
+}
+
void ListCommand::dumpTable() {
+ if (mNeat) {
+ TextTable textTable;
+ forEachTable([this, &textTable](const Table &table) {
+ for (const auto &entry : table) addLine(&textTable, entry);
+ });
+ textTable.dump(mOut.buf());
+ return;
+ }
+
mServicesTable.description =
"All binderized services (registered services through hwservicemanager)";
mPassthroughRefTable.description =
@@ -409,42 +432,34 @@
"the library and successfully fetched the passthrough implementation.";
mImplementationsTable.description =
"All available passthrough implementations (all -impl.so files)";
- forEachTable([this] (const Table &table) {
- if (!mNeat) {
- mOut << table.description << std::endl;
- }
- mOut << std::left;
- if (!mNeat) {
- printLine("Interface", "Transport", "Arch", "Thread Use", "Server",
- "Server CMD", "PTR", "Clients", "Clients CMD");
- }
+
+ forEachTable([this](const Table &table) {
+ TextTable textTable;
+
+ textTable.add(table.description);
+ addLine(&textTable, "Interface", "Transport", "Arch", "Thread Use", "Server", "Server CMD",
+ "PTR", "Clients", "Clients CMD");
for (const auto &entry : table) {
- printLine(entry.interfaceName,
- entry.transport,
- getArchString(entry.arch),
- entry.getThreadUsage(),
- entry.serverPid == NO_PID ? "N/A" : std::to_string(entry.serverPid),
- entry.serverCmdline,
- entry.serverObjectAddress == NO_PTR ? "N/A" : toHexString(entry.serverObjectAddress),
- join(entry.clientPids, " "),
- join(entry.clientCmdlines, ";"));
-
+ addLine(&textTable, entry);
// We're only interested in dumping debug info for already
// instantiated services. There's little value in dumping the
// debug info for a service we create on the fly, so we only operate
// on the "mServicesTable".
if (mEmitDebugInfo && &table == &mServicesTable) {
+ std::stringstream out;
auto pair = splitFirst(entry.interfaceName, '/');
- mLshal.emitDebugInfo(pair.first, pair.second, {}, mOut.buf(),
- NullableOStream<std::ostream>(nullptr));
+ mLshal.emitDebugInfo(pair.first, pair.second, {}, out,
+ NullableOStream<std::ostream>(nullptr));
+ textTable.add(out.str());
}
}
- if (!mNeat) {
- mOut << std::endl;
- }
- });
+ // Add empty line after each table
+ textTable.add();
+
+ textTable.dump(mOut.buf());
+ });
}
void ListCommand::dump() {
@@ -713,31 +728,31 @@
mVintf = true;
}
case 'i': {
- mSelectedColumns |= ENABLE_INTERFACE_NAME;
+ mSelectedColumns.push_back(TableColumnType::INTERFACE_NAME);
break;
}
case 't': {
- mSelectedColumns |= ENABLE_TRANSPORT;
+ mSelectedColumns.push_back(TableColumnType::TRANSPORT);
break;
}
case 'r': {
- mSelectedColumns |= ENABLE_ARCH;
+ mSelectedColumns.push_back(TableColumnType::ARCH);
break;
}
case 'p': {
- mSelectedColumns |= ENABLE_SERVER_PID;
+ mSelectedColumns.push_back(TableColumnType::SERVER_PID);
break;
}
case 'a': {
- mSelectedColumns |= ENABLE_SERVER_ADDR;
+ mSelectedColumns.push_back(TableColumnType::SERVER_ADDR);
break;
}
case 'c': {
- mSelectedColumns |= ENABLE_CLIENT_PIDS;
+ mSelectedColumns.push_back(TableColumnType::CLIENT_PIDS);
break;
}
case 'e': {
- mSelectedColumns |= ENABLE_THREADS;
+ mSelectedColumns.push_back(TableColumnType::THREADS);
break;
}
case 'm': {
@@ -771,10 +786,19 @@
if (optind < arg.argc) {
// see non option
mErr << "Unrecognized option `" << arg.argv[optind] << "`" << std::endl;
+ mLshal.usage(command);
+ return USAGE;
}
- if (mSelectedColumns == 0) {
- mSelectedColumns = ENABLE_INTERFACE_NAME | ENABLE_SERVER_PID | ENABLE_CLIENT_PIDS | ENABLE_THREADS;
+ if (mNeat && mEmitDebugInfo) {
+ mErr << "Error: --neat should not be used with --debug." << std::endl;
+ mLshal.usage(command);
+ return USAGE;
+ }
+
+ if (mSelectedColumns.empty()) {
+ mSelectedColumns = {TableColumnType::INTERFACE_NAME, TableColumnType::THREADS,
+ TableColumnType::SERVER_PID, TableColumnType::CLIENT_PIDS};
}
return OK;
}
diff --git a/cmds/lshal/ListCommand.h b/cmds/lshal/ListCommand.h
index a75db04..176d5b9 100644
--- a/cmds/lshal/ListCommand.h
+++ b/cmds/lshal/ListCommand.h
@@ -28,6 +28,7 @@
#include "NullableOStream.h"
#include "TableEntry.h"
+#include "TextTable.h"
#include "utils.h"
namespace android {
@@ -58,16 +59,11 @@
void dumpTable();
void dumpVintf() const;
- void printLine(
- const std::string &interfaceName,
- const std::string &transport,
- const std::string &arch,
- const std::string &threadUsage,
- const std::string &server,
- const std::string &serverCmdline,
- const std::string &address,
- const std::string &clients,
- const std::string &clientCmdlines) const;
+ void addLine(TextTable *table, const std::string &interfaceName, const std::string &transport,
+ const std::string &arch, const std::string &threadUsage, const std::string &server,
+ const std::string &serverCmdline, const std::string &address,
+ const std::string &clients, const std::string &clientCmdlines) const;
+ void addLine(TextTable *table, const TableEntry &entry);
// Return /proc/{pid}/cmdline if it exists, else empty string.
const std::string &getCmdline(pid_t pid);
// Call getCmdline on all pid in pids. If it returns empty string, the process might
@@ -86,7 +82,7 @@
NullableOStream<std::ostream> mOut;
NullableOStream<std::ofstream> mFileOutput = nullptr;
TableEntryCompare mSortColumn = nullptr;
- TableEntrySelect mSelectedColumns = 0;
+ std::vector<TableColumnType> mSelectedColumns;
// If true, cmdlines will be printed instead of pid.
bool mEnableCmdlines = false;
diff --git a/cmds/lshal/Lshal.cpp b/cmds/lshal/Lshal.cpp
index 0d4a1d1..ac74775 100644
--- a/cmds/lshal/Lshal.cpp
+++ b/cmds/lshal/Lshal.cpp
@@ -63,7 +63,7 @@
"list:\n"
" lshal\n"
" lshal list\n"
- " List all hals with default ordering and columns (`lshal list -ipc`)\n"
+ " List all hals with default ordering and columns (`lshal list -iepc`)\n"
" lshal list [-h|--help]\n"
" -h, --help: Print help message for list (`lshal help list`)\n"
" lshal [list] [--interface|-i] [--transport|-t] [-r|--arch] [-e|--threads]\n"
@@ -81,10 +81,11 @@
" -c, --clients: print the client PIDs, or client cmdlines if -m is set\n"
" -m, --cmdline: print cmdline instead of PIDs\n"
" -d[=<output file>], --debug[=<output file>]: emit debug info from \n"
- " IBase::debug with empty options\n"
+ " IBase::debug with empty options. Cannot be used with --neat.\n"
" --sort=i, --sort=interface: sort by interface name\n"
" --sort=p, --sort=pid: sort by server pid\n"
" --neat: output is machine parsable (no explanatory text)\n"
+ " Cannot be used with --debug.\n"
" --init-vintf[=<output file>]: form a skeleton HAL manifest to specified\n"
" file, or stdout if no file specified.\n";
diff --git a/cmds/lshal/TableEntry.h b/cmds/lshal/TableEntry.h
index e04c3ca..f18f38a 100644
--- a/cmds/lshal/TableEntry.h
+++ b/cmds/lshal/TableEntry.h
@@ -84,18 +84,16 @@
using TableEntryCompare = std::function<bool(const TableEntry &, const TableEntry &)>;
-enum : unsigned int {
- ENABLE_INTERFACE_NAME = 1 << 0,
- ENABLE_TRANSPORT = 1 << 1,
- ENABLE_SERVER_PID = 1 << 2,
- ENABLE_SERVER_ADDR = 1 << 3,
- ENABLE_CLIENT_PIDS = 1 << 4,
- ENABLE_ARCH = 1 << 5,
- ENABLE_THREADS = 1 << 6,
+enum class TableColumnType : unsigned int {
+ INTERFACE_NAME,
+ TRANSPORT,
+ SERVER_PID,
+ SERVER_ADDR,
+ CLIENT_PIDS,
+ ARCH,
+ THREADS,
};
-using TableEntrySelect = unsigned int;
-
enum {
NO_PID = -1,
NO_PTR = 0
diff --git a/cmds/lshal/TextTable.cpp b/cmds/lshal/TextTable.cpp
new file mode 100644
index 0000000..a35917c
--- /dev/null
+++ b/cmds/lshal/TextTable.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#include <algorithm>
+#include <iomanip>
+
+#include "TextTable.h"
+
+namespace android {
+namespace lshal {
+
+void TextTable::computeWidth(const std::vector<std::string>& v) {
+ if (mWidths.size() < v.size()) {
+ mWidths.resize(v.size());
+ }
+ for (size_t i = 0; i < v.size(); ++i) {
+ mWidths[i] = std::max(mWidths[i], v[i].length());
+ }
+}
+
+void TextTable::dump(std::ostream& out) const {
+ out << std::left;
+ for (const auto& row : mTable) {
+ if (!row.isRow()) {
+ out << row.line() << std::endl;
+ continue;
+ }
+
+ for (size_t i = 0; i < row.fields().size(); ++i) {
+ if (i != 0) {
+ out << " ";
+ }
+ // last column does not std::setw to avoid printing unnecessary spaces.
+ if (i < row.fields().size() - 1) {
+ out << std::setw(mWidths[i]);
+ }
+ out << row.fields()[i];
+ }
+ out << std::endl;
+ }
+}
+
+} // namespace lshal
+} // namespace android
diff --git a/cmds/lshal/TextTable.h b/cmds/lshal/TextTable.h
new file mode 100644
index 0000000..4636f15
--- /dev/null
+++ b/cmds/lshal/TextTable.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_TEXT_TABLE_H_
+#define FRAMEWORK_NATIVE_CMDS_LSHAL_TEXT_TABLE_H_
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "TableEntry.h"
+
+namespace android {
+namespace lshal {
+
+// An element in TextTable. This is either an actual row (an array of cells
+// in this row), or a string of explanatory text.
+// To see if this is an actual row, test fields().empty().
+class TextTableRow {
+public:
+ // An empty line.
+ TextTableRow() {}
+
+ // A row of cells.
+ TextTableRow(std::vector<std::string>&& v) : mFields(std::move(v)) {}
+
+ // A single comment string.
+ TextTableRow(std::string&& s) : mLine(std::move(s)) {}
+ TextTableRow(const std::string& s) : mLine(s) {}
+
+ // Whether this row is an actual row of cells.
+ bool isRow() const { return !fields().empty(); }
+
+ // Get all cells.
+ const std::vector<std::string>& fields() const { return mFields; }
+
+ // Get the single comment string.
+ const std::string& line() const { return mLine; }
+
+private:
+ std::vector<std::string> mFields;
+ std::string mLine;
+};
+
+// A TextTable is a 2D array of strings.
+class TextTable {
+public:
+
+ // Add a TextTableRow.
+ void add() { mTable.emplace_back(); }
+ void add(std::vector<std::string>&& v) {
+ computeWidth(v);
+ mTable.emplace_back(std::move(v));
+ }
+ void add(const std::string& s) { mTable.emplace_back(s); }
+ void add(std::string&& s) { mTable.emplace_back(std::move(s)); }
+
+ // Prints the table to out, with column widths adjusted appropriately according
+ // to the content.
+ void dump(std::ostream& out) const;
+
+private:
+ void computeWidth(const std::vector<std::string>& v);
+ std::vector<size_t> mWidths;
+ std::vector<TextTableRow> mTable;
+};
+
+} // namespace lshal
+} // namespace android
+
+#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_TEXT_TABLE_H_
diff --git a/libs/binder/tests/binderDriverInterfaceTest.cpp b/libs/binder/tests/binderDriverInterfaceTest.cpp
index ff5912f..b14631d 100644
--- a/libs/binder/tests/binderDriverInterfaceTest.cpp
+++ b/libs/binder/tests/binderDriverInterfaceTest.cpp
@@ -139,6 +139,12 @@
ASSERT_EQ(BINDER_CURRENT_PROTOCOL_VERSION, version.protocol_version);
}
+TEST_F(BinderDriverInterfaceTest, OpenNoMmap) {
+ int binderFd = open(BINDER_DEV_NAME, O_RDWR | O_NONBLOCK | O_CLOEXEC);
+ ASSERT_GE(binderFd, 0);
+ close(binderFd);
+}
+
TEST_F(BinderDriverInterfaceTest, WriteReadNull) {
binderTestIoctlErr1(BINDER_WRITE_READ, NULL, EFAULT);
}
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 4ea20e3..e1ed661 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -387,7 +387,7 @@
static bool find(std::string& result,
const std::string& pattern, const char* const search, bool exact) {
if (exact) {
- std::string absolutePath = std::string(search) + "/" + pattern;
+ std::string absolutePath = std::string(search) + "/" + pattern + ".so";
if (!access(absolutePath.c_str(), R_OK)) {
result = absolutePath;
return true;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 29e7bd6..bcd7afe 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2144,7 +2144,7 @@
sp<const DisplayDevice> hw(mDisplays[dpy]);
if (hw->getLayerStack() == currentlayerStack) {
if (disp == NULL) {
- disp = hw;
+ disp = std::move(hw);
} else {
disp = NULL;
break;