Merge "ueventd: remove leftovers of the SELinux policy update mechanism"
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index 5f55ab9..b8f790d 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -68,20 +68,17 @@
static int install_app_legacy(TransportType t, const char* serial, int argc, const char** argv);
static int uninstall_app_legacy(TransportType t, const char* serial, int argc, const char** argv);
-static auto& gProductOutPath = *new std::string();
extern int gListenAll;
DefaultStandardStreamsCallback DEFAULT_STANDARD_STREAMS_CALLBACK(nullptr, nullptr);
-static std::string product_file(const char *extra) {
- if (gProductOutPath.empty()) {
- fprintf(stderr, "adb: Product directory not specified; "
- "use -p or define ANDROID_PRODUCT_OUT\n");
+static std::string product_file(const char* file) {
+ const char* ANDROID_PRODUCT_OUT = getenv("ANDROID_PRODUCT_OUT");
+ if (ANDROID_PRODUCT_OUT == nullptr) {
+ fprintf(stderr, "adb: product directory not specified; set $ANDROID_PRODUCT_OUT\n");
exit(1);
}
-
- return android::base::StringPrintf("%s%s%s",
- gProductOutPath.c_str(), OS_PATH_SEPARATOR_STR, extra);
+ return android::base::StringPrintf("%s%s%s", ANDROID_PRODUCT_OUT, OS_PATH_SEPARATOR_STR, file);
}
static void help() {
@@ -92,11 +89,7 @@
" -a listen on all network interfaces, not just localhost\n"
" -d use USB device (error if multiple devices connected)\n"
" -e use TCP/IP device (error if multiple TCP/IP devices available)\n"
- " -s SERIAL\n"
- " use device with given serial number (overrides $ANDROID_SERIAL)\n"
- " -p PRODUCT\n"
- " name or path ('angler'/'out/target/product/angler');\n"
- " default $ANDROID_PRODUCT_OUT\n"
+ " -s SERIAL use device with given serial (overrides $ANDROID_SERIAL)\n"
" -H name of adb server host [default=localhost]\n"
" -P port of adb server [default=5037]\n"
" -L SOCKET listen on given socket for adb server [default=tcp:localhost:5037]\n"
@@ -138,9 +131,8 @@
" pull [-a] REMOTE... LOCAL\n"
" copy files/dirs from device\n"
" -a: preserve file timestamp and mode\n"
- " sync [DIR]\n"
- " copy all changed files to device; if DIR is \"system\", \"vendor\", \"oem\",\n"
- " or \"data\", only sync that partition (default all)\n"
+ " sync [system|vendor|oem|data|all]\n"
+ " sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)\n"
" -l: list but don't copy\n"
"\n"
"shell:\n"
@@ -1254,66 +1246,6 @@
return 0;
}
-/* <hint> may be:
- * - A simple product name
- * e.g., "sooner"
- * - A relative path from the CWD to the ANDROID_PRODUCT_OUT dir
- * e.g., "out/target/product/sooner"
- * - An absolute path to the PRODUCT_OUT dir
- * e.g., "/src/device/out/target/product/sooner"
- *
- * Given <hint>, try to construct an absolute path to the
- * ANDROID_PRODUCT_OUT dir.
- */
-static std::string find_product_out_path(const std::string& hint) {
- if (hint.empty()) {
- return "";
- }
-
- // If it's already absolute, don't bother doing any work.
- if (adb_is_absolute_host_path(hint.c_str())) {
- return hint;
- }
-
- // If any of the OS_PATH_SEPARATORS is found, assume it's a relative path;
- // make it absolute.
- // NOLINT: Do not complain if OS_PATH_SEPARATORS has only one character.
- if (hint.find_first_of(OS_PATH_SEPARATORS) != std::string::npos) { // NOLINT
- std::string cwd;
- if (!getcwd(&cwd)) {
- perror("adb: getcwd failed");
- return "";
- }
- return android::base::StringPrintf("%s%c%s", cwd.c_str(), OS_PATH_SEPARATOR, hint.c_str());
- }
-
- // It's a string without any slashes. Try to do something with it.
- //
- // Try to find the root of the build tree, and build a PRODUCT_OUT
- // path from there.
- char* top = getenv("ANDROID_BUILD_TOP");
- if (top == nullptr) {
- fprintf(stderr, "adb: ANDROID_BUILD_TOP not set!\n");
- return "";
- }
-
- std::string path = top;
- path += OS_PATH_SEPARATOR_STR;
- path += "out";
- path += OS_PATH_SEPARATOR_STR;
- path += "target";
- path += OS_PATH_SEPARATOR_STR;
- path += "product";
- path += OS_PATH_SEPARATOR_STR;
- path += hint;
- if (!directory_exists(path)) {
- fprintf(stderr, "adb: Couldn't find a product dir based on -p %s; "
- "\"%s\" doesn't exist\n", hint.c_str(), path.c_str());
- return "";
- }
- return path;
-}
-
static void parse_push_pull_args(const char** arg, int narg,
std::vector<const char*>* srcs,
const char** dst, bool* copy_attrs) {
@@ -1404,17 +1336,6 @@
signal(SIGPIPE, SIG_IGN);
#endif
- // If defined, this should be an absolute path to
- // the directory containing all of the various system images
- // for a particular product. If not defined, and the adb
- // command requires this information, then the user must
- // specify the path using "-p".
- char* ANDROID_PRODUCT_OUT = getenv("ANDROID_PRODUCT_OUT");
- if (ANDROID_PRODUCT_OUT != nullptr) {
- gProductOutPath = ANDROID_PRODUCT_OUT;
- }
- // TODO: also try TARGET_PRODUCT/TARGET_DEVICE as a hint
-
const char* server_host_str = nullptr;
const char* server_port_str = nullptr;
const char* server_socket_str = nullptr;
@@ -1440,21 +1361,6 @@
fprintf(stderr, "adb: invalid reply fd \"%s\"\n", reply_fd_str);
return 1;
}
- } else if (!strncmp(argv[0], "-p", 2)) {
- const char* product = nullptr;
- if (argv[0][2] == '\0') {
- if (argc < 2) return syntax_error("-p requires an argument");
- product = argv[1];
- argc--;
- argv++;
- } else {
- product = argv[0] + 2;
- }
- gProductOutPath = find_product_out_path(product);
- if (gProductOutPath.empty()) {
- fprintf(stderr, "adb: could not resolve \"-p %s\"\n", product);
- return 1;
- }
} else if (argv[0][0]=='-' && argv[0][1]=='s') {
if (isdigit(argv[0][2])) {
serial = argv[0] + 2;
@@ -1833,6 +1739,8 @@
return syntax_error("adb sync [-l] [PARTITION]");
}
+ if (src == "all") src = "";
+
if (src != "" &&
src != "system" && src != "data" && src != "vendor" && src != "oem") {
return syntax_error("don't know how to sync %s partition", src.c_str());
diff --git a/base/utf8.cpp b/base/utf8.cpp
old mode 100755
new mode 100644
diff --git a/base/utf8_test.cpp b/base/utf8_test.cpp
old mode 100755
new mode 100644
diff --git a/init/ueventd.cpp b/init/ueventd.cpp
index 963cc4d..8c0c574 100644
--- a/init/ueventd.cpp
+++ b/init/ueventd.cpp
@@ -33,9 +33,6 @@
#include "log.h"
#include "util.h"
-template <bool sysfs>
-static bool ParseSingleLine(std::vector<std::string>&& line, std::string* err);
-
int ueventd_main(int argc, char **argv)
{
/*
diff --git a/libcutils/fs_config.c b/libcutils/fs_config.c
index e1e8c8d..e4541f7 100644
--- a/libcutils/fs_config.c
+++ b/libcutils/fs_config.c
@@ -140,8 +140,14 @@
{ 00600, AID_ROOT, AID_ROOT, 0, "odm/default.prop" },
{ 00444, AID_ROOT, AID_ROOT, 0, odm_conf_dir + 1 },
{ 00444, AID_ROOT, AID_ROOT, 0, odm_conf_file + 1 },
+ { 00600, AID_ROOT, AID_ROOT, 0, "system/odm/build.prop" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "system/odm/default.prop" },
+ { 00444, AID_ROOT, AID_ROOT, 0, "system/odm/etc/fs_config_dirs" },
+ { 00444, AID_ROOT, AID_ROOT, 0, "system/odm/etc/fs_config_files" },
{ 00444, AID_ROOT, AID_ROOT, 0, oem_conf_dir + 1 },
{ 00444, AID_ROOT, AID_ROOT, 0, oem_conf_file + 1 },
+ { 00444, AID_ROOT, AID_ROOT, 0, "system/oem/etc/fs_config_dirs" },
+ { 00444, AID_ROOT, AID_ROOT, 0, "system/oem/etc/fs_config_files" },
{ 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" },
{ 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump32" },
{ 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump64" },
@@ -158,6 +164,10 @@
{ 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" },
{ 00555, AID_ROOT, AID_ROOT, 0, "system/etc/rc.*" },
{ 00440, AID_ROOT, AID_ROOT, 0, "system/etc/recovery.img" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "system/vendor/build.prop" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "system/vendor/default.prop" },
+ { 00444, AID_ROOT, AID_ROOT, 0, "system/vendor/etc/fs_config_dirs" },
+ { 00444, AID_ROOT, AID_ROOT, 0, "system/vendor/etc/fs_config_files" },
{ 00600, AID_ROOT, AID_ROOT, 0, "vendor/build.prop" },
{ 00600, AID_ROOT, AID_ROOT, 0, "vendor/default.prop" },
{ 00444, AID_ROOT, AID_ROOT, 0, ven_conf_dir + 1 },
@@ -193,11 +203,17 @@
* Support RT scheduling in Bluetooth */
{ 00700, AID_BLUETOOTH, AID_BLUETOOTH, CAP_MASK_LONG(CAP_NET_ADMIN) |
CAP_MASK_LONG(CAP_SYS_NICE),
+ "system/vendor/bin/hw/android.hardware.bluetooth@1.0-service" },
+ { 00700, AID_BLUETOOTH, AID_BLUETOOTH, CAP_MASK_LONG(CAP_NET_ADMIN) |
+ CAP_MASK_LONG(CAP_SYS_NICE),
"vendor/bin/hw/android.hardware.bluetooth@1.0-service" },
/* Support wifi_hal_legacy administering a network interface. */
{ 00755, AID_WIFI, AID_WIFI, CAP_MASK_LONG(CAP_NET_ADMIN) |
CAP_MASK_LONG(CAP_NET_RAW),
+ "system/vendor/bin/hw/android.hardware.wifi@1.0-service" },
+ { 00755, AID_WIFI, AID_WIFI, CAP_MASK_LONG(CAP_NET_ADMIN) |
+ CAP_MASK_LONG(CAP_NET_RAW),
"vendor/bin/hw/android.hardware.wifi@1.0-service" },
/* A non-privileged zygote that spawns
diff --git a/libcutils/sched_policy.cpp b/libcutils/sched_policy.cpp
index 217733a..e29a844 100644
--- a/libcutils/sched_policy.cpp
+++ b/libcutils/sched_policy.cpp
@@ -343,16 +343,25 @@
static void set_timerslack_ns(int tid, unsigned long long slack) {
// v4.6+ kernels support the /proc/<tid>/timerslack_ns interface.
// TODO: once we've backported this, log if the open(2) fails.
- char buf[64];
- snprintf(buf, sizeof(buf), "/proc/%d/timerslack_ns", tid);
- int fd = open(buf, O_WRONLY | O_CLOEXEC);
- if (fd != -1) {
- int len = snprintf(buf, sizeof(buf), "%llu", slack);
- if (write(fd, buf, len) != len) {
- SLOGE("set_timerslack_ns write failed: %s\n", strerror(errno));
+ if (__sys_supports_timerslack) {
+ char buf[64];
+ snprintf(buf, sizeof(buf), "/proc/%d/timerslack_ns", tid);
+ int fd = open(buf, O_WRONLY | O_CLOEXEC);
+ if (fd != -1) {
+ int len = snprintf(buf, sizeof(buf), "%llu", slack);
+ if (write(fd, buf, len) != len) {
+ SLOGE("set_timerslack_ns write failed: %s\n", strerror(errno));
+ }
+ close(fd);
+ return;
}
- close(fd);
- return;
+ }
+
+ // TODO: Remove when /proc/<tid>/timerslack_ns interface is backported.
+ if ((tid == 0) || (tid == gettid())) {
+ if (prctl(PR_SET_TIMERSLACK, slack) == -1) {
+ SLOGE("set_timerslack_ns prctl failed: %s\n", strerror(errno));
+ }
}
}
@@ -431,10 +440,7 @@
}
- if (__sys_supports_timerslack) {
- set_timerslack_ns(tid, policy == SP_BACKGROUND ?
- TIMER_SLACK_BG : TIMER_SLACK_FG);
- }
+ set_timerslack_ns(tid, policy == SP_BACKGROUND ? TIMER_SLACK_BG : TIMER_SLACK_FG);
return 0;
}