Merge "init: reboot to bootloader on crash for development builds"
diff --git a/adb/bugreport.cpp b/adb/bugreport.cpp
index a5c312b..9dc9811 100644
--- a/adb/bugreport.cpp
+++ b/adb/bugreport.cpp
@@ -47,7 +47,8 @@
invalid_lines_(),
show_progress_(show_progress),
status_(0),
- line_() {
+ line_(),
+ last_progress_(0) {
SetLineMessage("generating");
}
@@ -66,6 +67,7 @@
void OnStderr(const char* buffer, int length) {
OnStream(nullptr, stderr, buffer, length);
}
+
int Done(int unused_) {
// Process remaining line, if any.
ProcessLine(line_);
@@ -145,6 +147,11 @@
size_t idx1 = line.rfind(BUGZ_PROGRESS_PREFIX) + strlen(BUGZ_PROGRESS_PREFIX);
size_t idx2 = line.rfind(BUGZ_PROGRESS_SEPARATOR);
int progress = std::stoi(line.substr(idx1, (idx2 - idx1)));
+ if (progress <= last_progress_) {
+ // Ignore.
+ return;
+ }
+ last_progress_ = progress;
int total = std::stoi(line.substr(idx2 + 1));
br_->UpdateProgress(line_message_, progress, total);
} else {
@@ -180,6 +187,10 @@
// Temporary buffer containing the characters read since the last newline (\n).
std::string line_;
+ // Last displayed progress.
+ // Since dumpstate progress can recede, only forward progress should be displayed
+ int last_progress_;
+
DISALLOW_COPY_AND_ASSIGN(BugreportStandardStreamsCallback);
};
diff --git a/adb/bugreport_test.cpp b/adb/bugreport_test.cpp
index 1129285..b500c49 100644
--- a/adb/bugreport_test.cpp
+++ b/adb/bugreport_test.cpp
@@ -50,9 +50,7 @@
// Empty functions so tests don't need to be linked against commandline.cpp
DefaultStandardStreamsCallback DEFAULT_STANDARD_STREAMS_CALLBACK(nullptr, nullptr);
-int usage() {
- return -42;
-}
+
int send_shell_command(TransportType transport_type, const char* serial, const std::string& command,
bool disable_shell_protocol, StandardStreamsCallbackInterface* callback) {
ADD_FAILURE() << "send_shell_command() should have been mocked";
@@ -155,7 +153,7 @@
// Tests when called with invalid number of arguments
TEST_F(BugreportTest, InvalidNumberArgs) {
const char* args[] = {"bugreport", "to", "principal"};
- ASSERT_EQ(-42, br_.DoIt(kTransportLocal, "HannibalLecter", 3, args));
+ ASSERT_EQ(1, br_.DoIt(kTransportLocal, "HannibalLecter", 3, args));
}
// Tests the 'adb bugreport' option when the device does not support 'bugreportz' - it falls back
@@ -282,6 +280,35 @@
ASSERT_EQ(0, br_.DoIt(kTransportLocal, "HannibalLecter", 2, args));
}
+// Tests 'adb bugreport file.zip' when it succeeds and displays progress, even if progress recedes.
+TEST_F(BugreportTest, OkProgressAlwaysForward) {
+ ExpectBugreportzVersion("1.1");
+ ExpectProgress(1, 100);
+ ExpectProgress(50, 100);
+ ExpectProgress(75, 100);
+ // clang-format off
+ EXPECT_CALL(br_, SendShellCommand(kTransportLocal, "HannibalLecter", "bugreportz -p", false, _))
+ // NOTE: DoAll accepts at most 10 arguments, and we're almost reached that limit...
+ .WillOnce(DoAll(
+ WithArg<4>(WriteOnStdout("BEGIN:/device/bugreport.zip\n")),
+ WithArg<4>(WriteOnStdout("PROGRESS:1/100\n")),
+ WithArg<4>(WriteOnStdout("PROGRESS:50/100\n")),
+ // 25 should be ignored becaused it receded.
+ WithArg<4>(WriteOnStdout("PROGRESS:25/100\n")),
+ WithArg<4>(WriteOnStdout("PROGRESS:75/100\n")),
+ // 75 should be ignored becaused it didn't change.
+ WithArg<4>(WriteOnStdout("PROGRESS:75/100\n")),
+ WithArg<4>(WriteOnStdout("OK:/device/bugreport.zip")),
+ WithArg<4>(ReturnCallbackDone())));
+ // clang-format on
+ EXPECT_CALL(br_, DoSyncPull(ElementsAre(StrEq("/device/bugreport.zip")), StrEq("file.zip"),
+ true, StrEq("pulling file.zip")))
+ .WillOnce(Return(true));
+
+ const char* args[] = {"bugreport", "file.zip"};
+ ASSERT_EQ(0, br_.DoIt(kTransportLocal, "HannibalLecter", 2, args));
+}
+
// Tests 'adb bugreport dir' when it succeeds and destination is a directory.
TEST_F(BugreportTest, OkDirectory) {
ExpectBugreportzVersion("1.1");
diff --git a/adb/jdwp_service.cpp b/adb/jdwp_service.cpp
index 9589d88..f0dff06 100644
--- a/adb/jdwp_service.cpp
+++ b/adb/jdwp_service.cpp
@@ -179,8 +179,6 @@
fdevent* fde = nullptr;
std::vector<unique_fd> out_fds;
- char in_buf[PID_LEN + 1];
- ssize_t in_len = 0;
};
static size_t jdwp_process_list(char* buffer, size_t bufferlen) {
@@ -224,33 +222,16 @@
if (events & FDE_READ) {
if (proc->pid < 0) {
/* read the PID as a 4-hexchar string */
- if (proc->in_len < 0) {
- fatal("attempting to read JDWP pid again?");
- }
-
- char* p = proc->in_buf + proc->in_len;
- size_t size = PID_LEN - proc->in_len;
-
- ssize_t rc = TEMP_FAILURE_RETRY(recv(socket, p, size, 0));
- if (rc < 0) {
- if (errno == EAGAIN) {
- return;
- }
-
+ char buf[PID_LEN + 1];
+ ssize_t rc = TEMP_FAILURE_RETRY(recv(socket, buf, PID_LEN, 0));
+ if (rc != PID_LEN) {
D("failed to read jdwp pid: %s", strerror(errno));
goto CloseProcess;
}
+ buf[PID_LEN] = '\0';
- proc->in_len += rc;
- if (proc->in_len != PID_LEN) {
- return;
- }
-
- proc->in_buf[PID_LEN] = '\0';
- proc->in_len = -1;
-
- if (sscanf(proc->in_buf, "%04x", &proc->pid) != 1) {
- D("could not decode JDWP %p PID number: '%s'", proc, p);
+ if (sscanf(buf, "%04x", &proc->pid) != 1) {
+ D("could not decode JDWP %p PID number: '%s'", proc, buf);
goto CloseProcess;
}
@@ -405,7 +386,7 @@
addr.sun_family = AF_UNIX;
memcpy(addr.sun_path, sockname, socknamelen);
- s = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ s = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
if (s < 0) {
D("could not create vm debug control socket. %d: %s", errno, strerror(errno));
return -1;
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 6c84d73..6636be2 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -45,8 +45,7 @@
#include <linux/fs.h>
#include <linux/loop.h>
#include <logwrap/logwrap.h>
-#include <private/android_filesystem_config.h>
-#include <private/android_logger.h>
+#include <private/android_logger.h> // for __android_log_is_debuggable()
#include "fs_mgr_priv.h"
#include "fs_mgr_priv_avb.h"
diff --git a/fs_mgr/fs_mgr_verity.cpp b/fs_mgr/fs_mgr_verity.cpp
index 54a6f71..8c7a8ca 100644
--- a/fs_mgr/fs_mgr_verity.cpp
+++ b/fs_mgr/fs_mgr_verity.cpp
@@ -39,7 +39,6 @@
#include <openssl/obj_mac.h>
#include <openssl/rsa.h>
#include <openssl/sha.h>
-#include <private/android_filesystem_config.h>
#include "fec/io.h"
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
index 48a0e61..d200070 100644
--- a/include/private/android_filesystem_config.h
+++ b/include/private/android_filesystem_config.h
@@ -129,6 +129,7 @@
#define AID_TOMBSTONED 1058 /* tombstoned user */
#define AID_MEDIA_OBB 1059 /* GID for OBB files on internal media storage */
#define AID_ESE 1060 /* embedded secure element (eSE) subsystem */
+#define AID_OTA_UPDATE 1061 /* resource tracking UID for OTA updates */
/* Changes to this file must be made in AOSP, *not* in internal branches. */
#define AID_SHELL 2000 /* adb and debug shell user */
diff --git a/init/util.cpp b/init/util.cpp
index 888a366..c987181 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -163,7 +163,7 @@
bool read_file(const char* path, std::string* content) {
content->clear();
- int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY|O_NOFOLLOW|O_CLOEXEC));
+ android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_NOFOLLOW | O_CLOEXEC)));
if (fd == -1) {
return false;
}
@@ -176,17 +176,16 @@
return false;
}
if ((sb.st_mode & (S_IWGRP | S_IWOTH)) != 0) {
- PLOG(ERROR) << "skipping insecure file '" << path << "'";
+ LOG(ERROR) << "skipping insecure file '" << path << "'";
return false;
}
- bool okay = android::base::ReadFdToString(fd, content);
- close(fd);
- return okay;
+ return android::base::ReadFdToString(fd, content);
}
bool write_file(const char* path, const char* content) {
- int fd = TEMP_FAILURE_RETRY(open(path, O_WRONLY|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0600));
+ android::base::unique_fd fd(
+ TEMP_FAILURE_RETRY(open(path, O_WRONLY | O_CREAT | O_NOFOLLOW | O_CLOEXEC, 0600)));
if (fd == -1) {
PLOG(ERROR) << "write_file: Unable to open '" << path << "'";
return false;
@@ -195,7 +194,6 @@
if (!success) {
PLOG(ERROR) << "write_file: Unable to write to '" << path << "'";
}
- close(fd);
return success;
}
diff --git a/libcutils/fs_config.c b/libcutils/fs_config.c
index 1915ced..f99519a 100644
--- a/libcutils/fs_config.c
+++ b/libcutils/fs_config.c
@@ -52,21 +52,17 @@
} __attribute__((__aligned__(sizeof(uint64_t))));
/* My kingdom for <endian.h> */
-static inline uint16_t get2LE(const uint8_t* src)
-{
- return src[0] | (src[1] << 8);
-}
+static inline uint16_t get2LE(const uint8_t* src) { return src[0] | (src[1] << 8); }
-static inline uint64_t get8LE(const uint8_t* src)
-{
+static inline uint64_t get8LE(const uint8_t* src) {
uint32_t low, high;
low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
- return ((uint64_t) high << 32) | (uint64_t) low;
+ return ((uint64_t)high << 32) | (uint64_t)low;
}
-#define ALIGN(x, alignment) ( ((x) + ((alignment) - 1)) & ~((alignment) - 1) )
+#define ALIGN(x, alignment) (((x) + ((alignment)-1)) & ~((alignment)-1))
/* Rules for directories.
** These rules are applied based on "first match", so they
@@ -75,35 +71,37 @@
*/
static const struct fs_path_config android_dirs[] = {
- { 00770, AID_SYSTEM, AID_CACHE, 0, "cache" },
- { 00500, AID_ROOT, AID_ROOT, 0, "config" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-ephemeral" },
- { 00771, AID_ROOT, AID_ROOT, 0, "data/dalvik-cache" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/data" },
- { 00771, AID_SHELL, AID_SHELL, 0, "data/local/tmp" },
- { 00771, AID_SHELL, AID_SHELL, 0, "data/local" },
- { 01771, AID_SYSTEM, AID_MISC, 0, "data/misc" },
- { 00770, AID_DHCP, AID_DHCP, 0, "data/misc/dhcp" },
+ /* clang-format off */
+ { 00770, AID_SYSTEM, AID_CACHE, 0, "cache" },
+ { 00500, AID_ROOT, AID_ROOT, 0, "config" },
+ { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app" },
+ { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private" },
+ { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-ephemeral" },
+ { 00771, AID_ROOT, AID_ROOT, 0, "data/dalvik-cache" },
+ { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/data" },
+ { 00771, AID_SHELL, AID_SHELL, 0, "data/local/tmp" },
+ { 00771, AID_SHELL, AID_SHELL, 0, "data/local" },
+ { 00770, AID_DHCP, AID_DHCP, 0, "data/misc/dhcp" },
{ 00771, AID_SHARED_RELRO, AID_SHARED_RELRO, 0, "data/misc/shared_relro" },
- { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media" },
- { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/Music" },
- { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest" },
- { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest64" },
- { 00775, AID_ROOT, AID_ROOT, 0, "data/preloads" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" },
- { 00755, AID_ROOT, AID_SYSTEM, 0, "mnt" },
- { 00755, AID_ROOT, AID_ROOT, 0, "root" },
- { 00750, AID_ROOT, AID_SHELL, 0, "sbin" },
- { 00751, AID_ROOT, AID_SDCARD_R, 0, "storage" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/bin" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin" },
- { 00755, AID_ROOT, AID_ROOT, 0, "system/etc/ppp" },
- { 00755, AID_ROOT, AID_SHELL, 0, "vendor" },
- { 00777, AID_ROOT, AID_ROOT, 0, "sdcard" },
- { 00755, AID_ROOT, AID_ROOT, 0, 0 },
+ { 01771, AID_SYSTEM, AID_MISC, 0, "data/misc" },
+ { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/Music" },
+ { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest64" },
+ { 00775, AID_ROOT, AID_ROOT, 0, "data/preloads" },
+ { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" },
+ { 00755, AID_ROOT, AID_SYSTEM, 0, "mnt" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "root" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "sbin" },
+ { 00777, AID_ROOT, AID_ROOT, 0, "sdcard" },
+ { 00751, AID_ROOT, AID_SDCARD_R, 0, "storage" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/bin" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/etc/ppp" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "vendor" },
+ { 00755, AID_ROOT, AID_ROOT, 0, 0 },
+ /* clang-format on */
};
/* Rules for files.
@@ -112,34 +110,70 @@
** way up to the root. Prefixes ending in * denotes wildcard
** and will allow partial matches.
*/
-static const char conf_dir[] = "/system/etc/fs_config_dirs";
-static const char conf_file[] = "/system/etc/fs_config_files";
+static const char sys_conf_dir[] = "/system/etc/fs_config_dirs";
+static const char sys_conf_file[] = "/system/etc/fs_config_files";
+/* No restrictions are placed on the vendor and oem file-system config files,
+ * although the developer is advised to restrict the scope to the /vendor or
+ * oem/ file-system since the intent is to provide support for customized
+ * portions of a separate vendor.img or oem.img. Has to remain open so that
+ * customization can also land on /system/vendor or /system/orm. We expect
+ * build-time checking or filtering when constructing the associated
+ * fs_config_* files.
+ */
+static const char ven_conf_dir[] = "/vendor/etc/fs_config_dirs";
+static const char ven_conf_file[] = "/vendor/etc/fs_config_files";
+static const char oem_conf_dir[] = "/oem/etc/fs_config_dirs";
+static const char oem_conf_file[] = "/oem/etc/fs_config_files";
+static const char* conf[][2] = {
+ {sys_conf_file, sys_conf_dir}, {ven_conf_file, ven_conf_dir}, {oem_conf_file, oem_conf_dir},
+};
static const struct fs_path_config android_files[] = {
+ /* clang-format off */
+ { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app/*" },
+ { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app-ephemeral/*" },
+ { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private/*" },
+ { 00644, AID_APP, AID_APP, 0, "data/data/*" },
+ { 00644, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/*" },
+ { 00640, AID_ROOT, AID_SHELL, 0, "data/nativetest/tests.txt" },
+ { 00640, AID_ROOT, AID_SHELL, 0, "data/nativetest64/tests.txt" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest/*" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest64/*" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "default.prop" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "odm/build.prop" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "odm/default.prop" },
+ { 00444, AID_ROOT, AID_ROOT, 0, oem_conf_dir + 1 },
+ { 00444, AID_ROOT, AID_ROOT, 0, oem_conf_file + 1 },
+ { 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" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/debuggerd" },
+ { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/install-recovery.sh" },
+ { 00700, AID_ROOT, AID_ROOT, 0, "system/bin/secilc" },
+ { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/uncrypt" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "system/build.prop" },
+ { 00444, AID_ROOT, AID_ROOT, 0, sys_conf_dir + 1 },
+ { 00444, AID_ROOT, AID_ROOT, 0, sys_conf_file + 1 },
{ 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.rc" },
{ 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.sh" },
{ 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.ril" },
{ 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" },
- { 00444, AID_ROOT, AID_ROOT, 0, conf_dir + 1 },
- { 00444, AID_ROOT, AID_ROOT, 0, conf_file + 1 },
- { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app/*" },
- { 00644, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/*" },
- { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private/*" },
- { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app-ephemeral/*" },
- { 00644, AID_APP, AID_APP, 0, "data/data/*" },
- { 00640, AID_ROOT, AID_SHELL, 0, "data/nativetest/tests.txt" },
- { 00640, AID_ROOT, AID_SHELL, 0, "data/nativetest64/tests.txt" },
- { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest/*" },
- { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest64/*" },
+ { 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 },
+ { 00444, AID_ROOT, AID_ROOT, 0, ven_conf_file + 1 },
/* the following two files are INTENTIONALLY set-uid, but they
* are NOT included on user builds. */
- { 04750, AID_ROOT, AID_SHELL, 0, "system/xbin/su" },
{ 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procmem" },
+ { 04750, AID_ROOT, AID_SHELL, 0, "system/xbin/su" },
- /* the following files have enhanced capabilities and ARE included in user builds. */
+ /* the following files have enhanced capabilities and ARE included
+ * in user builds. */
+ { 00700, AID_SYSTEM, AID_SHELL, CAP_MASK_LONG(CAP_BLOCK_SUSPEND),
+ "system/bin/inputflinger" },
{ 00550, AID_LOGD, AID_LOGD, CAP_MASK_LONG(CAP_SYSLOG) |
CAP_MASK_LONG(CAP_AUDIT_CONTROL) |
CAP_MASK_LONG(CAP_SETGID),
@@ -147,27 +181,27 @@
{ 00750, AID_ROOT, AID_SHELL, CAP_MASK_LONG(CAP_SETUID) |
CAP_MASK_LONG(CAP_SETGID),
"system/bin/run-as" },
- { 00700, AID_SYSTEM, AID_SHELL, CAP_MASK_LONG(CAP_BLOCK_SUSPEND),
- "system/bin/inputflinger" },
/* Support FIFO scheduling mode in SurfaceFlinger. */
- { 00755, AID_SYSTEM, AID_GRAPHICS, CAP_MASK_LONG(CAP_SYS_NICE), "system/bin/surfaceflinger" },
+ { 00755, AID_SYSTEM, AID_GRAPHICS, CAP_MASK_LONG(CAP_SYS_NICE),
+ "system/bin/surfaceflinger" },
/* Support hostapd administering a network interface. */
{ 00755, AID_WIFI, AID_WIFI, CAP_MASK_LONG(CAP_NET_ADMIN) |
CAP_MASK_LONG(CAP_NET_RAW),
"system/bin/hostapd" },
+ /* Support Bluetooth legacy hal accessing /sys/class/rfkill */
+ { 00700, AID_BLUETOOTH, AID_BLUETOOTH, CAP_MASK_LONG(CAP_NET_ADMIN),
+ "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),
"vendor/bin/hw/android.hardware.wifi@1.0-service" },
- /* Support Bluetooth legacy hal accessing /sys/class/rfkill */
- { 00700, AID_BLUETOOTH, AID_BLUETOOTH, CAP_MASK_LONG(CAP_NET_ADMIN),
- "vendor/bin/hw/android.hardware.bluetooth@1.0-service" },
-
- /* A non-privileged zygote that spawns isolated processes for web rendering. */
+ /* A non-privileged zygote that spawns
+ * isolated processes for web rendering. */
{ 0750, AID_ROOT, AID_ROOT, CAP_MASK_LONG(CAP_SETUID) |
CAP_MASK_LONG(CAP_SETGID) |
CAP_MASK_LONG(CAP_SETPCAP),
@@ -177,62 +211,49 @@
CAP_MASK_LONG(CAP_SETPCAP),
"system/bin/webview_zygote64" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump32" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump64" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/debuggerd" },
- { 00700, AID_ROOT, AID_ROOT, 0, "system/bin/secilc" },
- { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/uncrypt" },
- { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/install-recovery.sh" },
+ /* generic defaults */
+ { 00755, AID_ROOT, AID_ROOT, 0, "bin/*" },
+ { 00640, AID_ROOT, AID_SHELL, 0, "fstab.*" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "init*" },
+ { 00750, AID_ROOT, AID_SHELL, 0, "sbin/*" },
{ 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" },
{ 00755, AID_ROOT, AID_ROOT, 0, "system/lib/valgrind/*" },
{ 00755, AID_ROOT, AID_ROOT, 0, "system/lib64/valgrind/*" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" },
{ 00755, AID_ROOT, AID_SHELL, 0, "system/vendor/bin/*" },
{ 00755, AID_ROOT, AID_SHELL, 0, "system/vendor/xbin/*" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" },
{ 00755, AID_ROOT, AID_SHELL, 0, "vendor/bin/*" },
{ 00755, AID_ROOT, AID_SHELL, 0, "vendor/xbin/*" },
- { 00750, AID_ROOT, AID_SHELL, 0, "sbin/*" },
- { 00755, AID_ROOT, AID_ROOT, 0, "bin/*" },
- { 00750, AID_ROOT, AID_SHELL, 0, "init*" },
- { 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" },
- { 00640, AID_ROOT, AID_SHELL, 0, "fstab.*" },
- { 00600, AID_ROOT, AID_ROOT, 0, "system/build.prop" },
- { 00600, AID_ROOT, AID_ROOT, 0, "vendor/build.prop" },
- { 00600, AID_ROOT, AID_ROOT, 0, "odm/build.prop" },
- { 00600, AID_ROOT, AID_ROOT, 0, "default.prop" },
- { 00600, AID_ROOT, AID_ROOT, 0, "vendor/default.prop" },
- { 00600, AID_ROOT, AID_ROOT, 0, "odm/default.prop" },
{ 00644, AID_ROOT, AID_ROOT, 0, 0 },
+ /* clang-format on */
};
-static int fs_config_open(int dir, const char *target_out_path)
-{
+static int fs_config_open(int dir, int which, const char* target_out_path) {
int fd = -1;
if (target_out_path && *target_out_path) {
- /* target_out_path is the path to the directory holding content of system partition
- but as we cannot guaranty it ends with '/system' we need this below skip_len logic */
- char *name = NULL;
+ /* target_out_path is the path to the directory holding content of
+ * system partition but as we cannot guaranty it ends with '/system'
+ * we need this below skip_len logic */
+ char* name = NULL;
int target_out_path_len = strlen(target_out_path);
int skip_len = strlen("/system");
if (target_out_path[target_out_path_len] == '/') {
skip_len++;
}
- if (asprintf(&name, "%s%s", target_out_path, (dir ? conf_dir : conf_file) + skip_len) != -1) {
+ if (asprintf(&name, "%s%s", target_out_path, conf[which][dir] + skip_len) != -1) {
fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_BINARY));
free(name);
}
}
if (fd < 0) {
- fd = TEMP_FAILURE_RETRY(open(dir ? conf_dir : conf_file, O_RDONLY | O_BINARY));
+ fd = TEMP_FAILURE_RETRY(open(conf[which][dir], O_RDONLY | O_BINARY));
}
return fd;
}
-static bool fs_config_cmp(bool dir, const char *prefix, size_t len,
- const char *path, size_t plen)
-{
+static bool fs_config_cmp(bool dir, const char* prefix, size_t len, const char* path, size_t plen) {
if (dir) {
if (plen < len) {
return false;
@@ -249,11 +270,10 @@
return !strncmp(prefix, path, len);
}
-void fs_config(const char *path, int dir, const char *target_out_path,
- unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities)
-{
- const struct fs_path_config *pc;
- int fd, plen;
+void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid,
+ unsigned* mode, uint64_t* capabilities) {
+ const struct fs_path_config* pc;
+ size_t which, plen;
if (path[0] == '/') {
path++;
@@ -261,41 +281,43 @@
plen = strlen(path);
- fd = fs_config_open(dir, target_out_path);
- if (fd >= 0) {
+ for (which = 0; which < (sizeof(conf) / sizeof(conf[0])); ++which) {
struct fs_path_config_from_file header;
+ int fd = fs_config_open(dir, which, target_out_path);
+ if (fd < 0) continue;
+
while (TEMP_FAILURE_RETRY(read(fd, &header, sizeof(header))) == sizeof(header)) {
- char *prefix;
- uint16_t host_len = get2LE((const uint8_t *)&header.len);
+ char* prefix;
+ uint16_t host_len = get2LE((const uint8_t*)&header.len);
ssize_t len, remainder = host_len - sizeof(header);
if (remainder <= 0) {
- ALOGE("%s len is corrupted", dir ? conf_dir : conf_file);
+ ALOGE("%s len is corrupted", conf[which][dir]);
break;
}
prefix = calloc(1, remainder);
if (!prefix) {
- ALOGE("%s out of memory", dir ? conf_dir : conf_file);
+ ALOGE("%s out of memory", conf[which][dir]);
break;
}
if (TEMP_FAILURE_RETRY(read(fd, prefix, remainder)) != remainder) {
free(prefix);
- ALOGE("%s prefix is truncated", dir ? conf_dir : conf_file);
+ ALOGE("%s prefix is truncated", conf[which][dir]);
break;
}
len = strnlen(prefix, remainder);
if (len >= remainder) { /* missing a terminating null */
free(prefix);
- ALOGE("%s is corrupted", dir ? conf_dir : conf_file);
+ ALOGE("%s is corrupted", conf[which][dir]);
break;
}
if (fs_config_cmp(dir, prefix, len, path, plen)) {
free(prefix);
close(fd);
- *uid = get2LE((const uint8_t *)&(header.uid));
- *gid = get2LE((const uint8_t *)&(header.gid));
- *mode = (*mode & (~07777)) | get2LE((const uint8_t *)&(header.mode));
- *capabilities = get8LE((const uint8_t *)&(header.capabilities));
+ *uid = get2LE((const uint8_t*)&(header.uid));
+ *gid = get2LE((const uint8_t*)&(header.gid));
+ *mode = (*mode & (~07777)) | get2LE((const uint8_t*)&(header.mode));
+ *capabilities = get8LE((const uint8_t*)&(header.capabilities));
return;
}
free(prefix);
@@ -303,8 +325,7 @@
close(fd);
}
- pc = dir ? android_dirs : android_files;
- for(; pc->prefix; pc++){
+ for (pc = dir ? android_dirs : android_files; pc->prefix; pc++) {
if (fs_config_cmp(dir, pc->prefix, strlen(pc->prefix), path, plen)) {
break;
}
@@ -315,9 +336,8 @@
*capabilities = pc->capabilities;
}
-ssize_t fs_config_generate(char *buffer, size_t length, const struct fs_path_config *pc)
-{
- struct fs_path_config_from_file *p = (struct fs_path_config_from_file *)buffer;
+ssize_t fs_config_generate(char* buffer, size_t length, const struct fs_path_config* pc) {
+ struct fs_path_config_from_file* p = (struct fs_path_config_from_file*)buffer;
size_t len = ALIGN(sizeof(*p) + strlen(pc->prefix) + 1, sizeof(uint64_t));
if ((length < len) || (len > UINT16_MAX)) {
@@ -325,11 +345,11 @@
}
memset(p, 0, len);
uint16_t host_len = len;
- p->len = get2LE((const uint8_t *)&host_len);
- p->mode = get2LE((const uint8_t *)&(pc->mode));
- p->uid = get2LE((const uint8_t *)&(pc->uid));
- p->gid = get2LE((const uint8_t *)&(pc->gid));
- p->capabilities = get8LE((const uint8_t *)&(pc->capabilities));
+ p->len = get2LE((const uint8_t*)&host_len);
+ p->mode = get2LE((const uint8_t*)&(pc->mode));
+ p->uid = get2LE((const uint8_t*)&(pc->uid));
+ p->gid = get2LE((const uint8_t*)&(pc->gid));
+ p->capabilities = get8LE((const uint8_t*)&(pc->capabilities));
strcpy(p->prefix, pc->prefix);
return len;
}
diff --git a/libcutils/sched_policy.cpp b/libcutils/sched_policy.cpp
index 7e3ad59..40144cf 100644
--- a/libcutils/sched_policy.cpp
+++ b/libcutils/sched_policy.cpp
@@ -464,7 +464,7 @@
break;
}
- if (add_tid_to_cgroup(tid, fd) != 0) {
+ if (fd > 0 && add_tid_to_cgroup(tid, fd) != 0) {
if (errno != ESRCH && errno != ENOENT)
return -errno;
}
diff --git a/libunwindstack/.clang-format b/libunwindstack/.clang-format
new file mode 120000
index 0000000..fd0645f
--- /dev/null
+++ b/libunwindstack/.clang-format
@@ -0,0 +1 @@
+../.clang-format-2
\ No newline at end of file
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 25cea7f..dcb3b25 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -150,15 +150,6 @@
write /dev/cpuctl/cpu.rt_period_us 1000000
write /dev/cpuctl/cpu.rt_runtime_us 950000
- mkdir /dev/cpuctl/bg_non_interactive
- chown system system /dev/cpuctl/bg_non_interactive/tasks
- chmod 0666 /dev/cpuctl/bg_non_interactive/tasks
- # 5.0 %
- write /dev/cpuctl/bg_non_interactive/cpu.shares 52
- write /dev/cpuctl/bg_non_interactive/cpu.rt_period_us 1000000
- # active FIFO threads will never be in BG
- write /dev/cpuctl/bg_non_interactive/cpu.rt_runtime_us 10000
-
# sets up initial cpusets for ActivityManager
mkdir /dev/cpuset
mount cpuset none /dev/cpuset