summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--healthd/healthd_mode_charger.cpp36
-rw-r--r--init/devices.h1
-rw-r--r--init/firmware_handler.cpp10
-rw-r--r--init/firmware_handler.h5
-rw-r--r--init/init.cpp5
-rw-r--r--init/ueventd.cpp53
-rw-r--r--init/ueventd_parser.cpp52
-rw-r--r--init/ueventd_parser.h24
-rw-r--r--liblog/tests/libc_test.cpp4
-rw-r--r--libutils/RefBase.cpp2
-rw-r--r--lmkd/lmkd.c5
-rw-r--r--rootdir/ueventd.rc2
12 files changed, 136 insertions, 63 deletions
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp
index 56a9f8691..4b709cf55 100644
--- a/healthd/healthd_mode_charger.cpp
+++ b/healthd/healthd_mode_charger.cpp
@@ -74,6 +74,7 @@ char* locale;
#define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC)
#define LAST_KMSG_MAX_SZ (32 * 1024)
+#define BACKLIGHT_TOGGLE_PATH "/sys/class/backlight/panel0-backlight/brightness"
#define LOGE(x...) KLOG_ERROR("charger", x);
#define LOGW(x...) KLOG_WARNING("charger", x);
@@ -186,6 +187,33 @@ static healthd_config* healthd_config;
static android::BatteryProperties* batt_prop;
static std::unique_ptr<HealthdDraw> healthd_draw;
+/* On certain targets the FBIOBLANK ioctl does not turn off the
+ * backlight. In those cases we need to manually toggle it on/off
+ */
+static int set_backlight(int toggle)
+{
+ int fd;
+ char buffer[10];
+
+ fd = open(BACKLIGHT_TOGGLE_PATH, O_RDWR);
+ if (fd < 0) {
+ LOGE("Could not open backlight node : %s", strerror(errno));
+ return 0;
+ }
+ if (toggle) {
+ LOGV("Enabling backlight");
+ snprintf(buffer, sizeof(int), "%d\n", 100);
+ } else {
+ LOGV("Disabling backlight");
+ snprintf(buffer, sizeof(int), "%d\n", 0);
+ }
+ if (write(fd, buffer, strlen(buffer)) < 0) {
+ LOGE("Could not write to backlight node : %s", strerror(errno));
+ }
+ close(fd);
+ return 0;
+}
+
/* current time in milliseconds */
static int64_t curr_time_ms() {
timespec tm;
@@ -292,6 +320,7 @@ static void update_screen_state(charger* charger, int64_t now) {
healthd_draw.reset(new HealthdDraw(batt_anim));
#ifndef CHARGER_DISABLE_INIT_BLANK
+ set_backlight(false);
healthd_draw->blank_screen(true);
#endif
}
@@ -300,6 +329,7 @@ static void update_screen_state(charger* charger, int64_t now) {
if (batt_anim->num_cycles > 0 && batt_anim->cur_cycle == batt_anim->num_cycles) {
reset_animation(batt_anim);
charger->next_screen_transition = -1;
+ set_backlight(false);
healthd_draw->blank_screen(true);
LOGV("[%" PRId64 "] animation done\n", now);
if (charger->charger_connected) request_suspend(true);
@@ -309,8 +339,10 @@ static void update_screen_state(charger* charger, int64_t now) {
disp_time = batt_anim->frames[batt_anim->cur_frame].disp_time;
/* unblank the screen on first cycle and first frame */
- if (batt_anim->cur_cycle == 0 && batt_anim->cur_frame == 0) healthd_draw->blank_screen(false);
-
+ if (batt_anim->cur_cycle == 0 && batt_anim->cur_frame == 0) {
+ healthd_draw->blank_screen(false);
+ set_backlight(true);
+ }
/* animation starting, set up the animation */
if (batt_anim->cur_frame == 0) {
LOGV("[%" PRId64 "] animation starting\n", now);
diff --git a/init/devices.h b/init/devices.h
index f9035da3d..9224fcd82 100644
--- a/init/devices.h
+++ b/init/devices.h
@@ -106,7 +106,6 @@ class DeviceHandler {
DeviceHandler(std::vector<Permissions> dev_permissions,
std::vector<SysfsPermissions> sysfs_permissions, std::vector<Subsystem> subsystems,
std::set<std::string> boot_devices, bool skip_restorecon);
- ~DeviceHandler(){};
void HandleDeviceEvent(const Uevent& uevent);
diff --git a/init/firmware_handler.cpp b/init/firmware_handler.cpp
index 8c8d9f2ab..28bda34a2 100644
--- a/init/firmware_handler.cpp
+++ b/init/firmware_handler.cpp
@@ -21,7 +21,6 @@
#include <sys/wait.h>
#include <unistd.h>
-#include <string>
#include <thread>
#include <android-base/chrono_utils.h>
@@ -36,6 +35,8 @@ using android::base::WriteFully;
namespace android {
namespace init {
+std::vector<std::string> firmware_directories;
+
static void LoadFirmware(const Uevent& uevent, const std::string& root, int fw_fd, size_t fw_size,
int loading_fd, int data_fd) {
// Start transfer.
@@ -78,12 +79,9 @@ static void ProcessFirmwareEvent(const Uevent& uevent) {
return;
}
- static const char* firmware_dirs[] = {"/etc/firmware/", "/odm/firmware/",
- "/vendor/firmware/", "/firmware/image/"};
-
try_loading_again:
- for (size_t i = 0; i < arraysize(firmware_dirs); i++) {
- std::string file = firmware_dirs[i] + uevent.firmware;
+ for (const auto& firmware_directory : firmware_directories) {
+ std::string file = firmware_directory + uevent.firmware;
unique_fd fw_fd(open(file.c_str(), O_RDONLY | O_CLOEXEC));
struct stat sb;
if (fw_fd != -1 && fstat(fw_fd, &sb) != -1) {
diff --git a/init/firmware_handler.h b/init/firmware_handler.h
index e456ac4e4..6081511b5 100644
--- a/init/firmware_handler.h
+++ b/init/firmware_handler.h
@@ -17,11 +17,16 @@
#ifndef _INIT_FIRMWARE_HANDLER_H
#define _INIT_FIRMWARE_HANDLER_H
+#include <string>
+#include <vector>
+
#include "uevent.h"
namespace android {
namespace init {
+extern std::vector<std::string> firmware_directories;
+
void HandleFirmwareEvent(const Uevent& uevent);
} // namespace init
diff --git a/init/init.cpp b/init/init.cpp
index dc5a38da2..ff125df4d 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -685,6 +685,11 @@ int main(int argc, char** argv) {
mkdir("/dev/memcg", 0700);
chown("/dev/memcg",AID_ROOT,AID_SYSTEM);
mount("none", "/dev/memcg", "cgroup", 0, "memory");
+ // app mem cgroups, used by activity manager, lmkd and zygote
+ mkdir("/dev/memcg/apps/",0755);
+ chown("/dev/memcg/apps/",AID_SYSTEM,AID_SYSTEM);
+ mkdir("/dev/memcg/system",0550);
+ chown("/dev/memcg/system",AID_SYSTEM,AID_SYSTEM);
}
// Clean up our environment.
diff --git a/init/ueventd.cpp b/init/ueventd.cpp
index a284203ba..b42a4c62a 100644
--- a/init/ueventd.cpp
+++ b/init/ueventd.cpp
@@ -215,39 +215,6 @@ void ColdBoot::Run() {
LOG(INFO) << "Coldboot took " << cold_boot_timer.duration().count() / 1000.0f << " seconds";
}
-DeviceHandler CreateDeviceHandler() {
- Parser parser;
-
- std::vector<Subsystem> subsystems;
- parser.AddSectionParser("subsystem", std::make_unique<SubsystemParser>(&subsystems));
-
- using namespace std::placeholders;
- std::vector<SysfsPermissions> sysfs_permissions;
- std::vector<Permissions> dev_permissions;
- parser.AddSingleLineParser("/sys/",
- std::bind(ParsePermissionsLine, _1, &sysfs_permissions, nullptr));
- parser.AddSingleLineParser("/dev/",
- std::bind(ParsePermissionsLine, _1, nullptr, &dev_permissions));
-
- parser.ParseConfig("/ueventd.rc");
- parser.ParseConfig("/vendor/ueventd.rc");
- parser.ParseConfig("/odm/ueventd.rc");
-
- /*
- * keep the current product name base configuration so
- * we remain backwards compatible and allow it to override
- * everything
- * TODO: cleanup platform ueventd.rc to remove vendor specific
- * device node entries (b/34968103)
- */
- std::string hardware = android::base::GetProperty("ro.hardware", "");
- parser.ParseConfig("/ueventd." + hardware + ".rc");
-
- auto boot_devices = fs_mgr_get_boot_devices();
- return DeviceHandler(std::move(dev_permissions), std::move(sysfs_permissions),
- std::move(subsystems), std::move(boot_devices), true);
-}
-
int ueventd_main(int argc, char** argv) {
/*
* init sets the umask to 077 for forked processes. We need to
@@ -263,9 +230,27 @@ int ueventd_main(int argc, char** argv) {
SelinuxSetupKernelLogging();
SelabelInitialize();
- DeviceHandler device_handler = CreateDeviceHandler();
+ DeviceHandler device_handler;
UeventListener uevent_listener;
+ {
+ // Keep the current product name base configuration so we remain backwards compatible and
+ // allow it to override everything.
+ // TODO: cleanup platform ueventd.rc to remove vendor specific device node entries (b/34968103)
+ auto hardware = android::base::GetProperty("ro.hardware", "");
+
+ auto ueventd_configuration =
+ ParseConfig({"/ueventd.rc", "/vendor/ueventd.rc", "/odm/ueventd.rc",
+ "/ueventd." + hardware + ".rc"});
+
+ device_handler = DeviceHandler{std::move(ueventd_configuration.dev_permissions),
+ std::move(ueventd_configuration.sysfs_permissions),
+ std::move(ueventd_configuration.subsystems),
+ fs_mgr_get_boot_devices(), true};
+
+ firmware_directories = ueventd_configuration.firmware_directories;
+ }
+
if (access(COLDBOOT_DONE, F_OK) != 0) {
ColdBoot cold_boot(uevent_listener, device_handler);
cold_boot.Run();
diff --git a/init/ueventd_parser.cpp b/init/ueventd_parser.cpp
index f74c87849..c114ec704 100644
--- a/init/ueventd_parser.cpp
+++ b/init/ueventd_parser.cpp
@@ -20,6 +20,7 @@
#include <pwd.h>
#include "keyword_map.h"
+#include "parser.h"
namespace android {
namespace init {
@@ -72,6 +73,33 @@ Result<Success> ParsePermissionsLine(std::vector<std::string>&& args,
return Success();
}
+Result<Success> ParseFirmwareDirectoriesLine(std::vector<std::string>&& args,
+ std::vector<std::string>* firmware_directories) {
+ if (args.size() < 2) {
+ return Error() << "firmware_directories must have at least 1 entry";
+ }
+
+ std::move(std::next(args.begin()), args.end(), std::back_inserter(*firmware_directories));
+
+ return Success();
+}
+
+class SubsystemParser : public SectionParser {
+ public:
+ SubsystemParser(std::vector<Subsystem>* subsystems) : subsystems_(subsystems) {}
+ Result<Success> ParseSection(std::vector<std::string>&& args, const std::string& filename,
+ int line) override;
+ Result<Success> ParseLineSection(std::vector<std::string>&& args, int line) override;
+ Result<Success> EndSection() override;
+
+ private:
+ Result<Success> ParseDevName(std::vector<std::string>&& args);
+ Result<Success> ParseDirName(std::vector<std::string>&& args);
+
+ Subsystem subsystem_;
+ std::vector<Subsystem>* subsystems_;
+};
+
Result<Success> SubsystemParser::ParseSection(std::vector<std::string>&& args,
const std::string& filename, int line) {
if (args.size() != 2) {
@@ -138,5 +166,29 @@ Result<Success> SubsystemParser::EndSection() {
return Success();
}
+UeventdConfiguration ParseConfig(const std::vector<std::string>& configs) {
+ Parser parser;
+ UeventdConfiguration ueventd_configuration;
+
+ parser.AddSectionParser("subsystem",
+ std::make_unique<SubsystemParser>(&ueventd_configuration.subsystems));
+
+ using namespace std::placeholders;
+ parser.AddSingleLineParser(
+ "/sys/",
+ std::bind(ParsePermissionsLine, _1, &ueventd_configuration.sysfs_permissions, nullptr));
+ parser.AddSingleLineParser("/dev/", std::bind(ParsePermissionsLine, _1, nullptr,
+ &ueventd_configuration.dev_permissions));
+ parser.AddSingleLineParser("firmware_directories",
+ std::bind(ParseFirmwareDirectoriesLine, _1,
+ &ueventd_configuration.firmware_directories));
+
+ for (const auto& config : configs) {
+ parser.ParseConfig(config);
+ }
+
+ return ueventd_configuration;
+}
+
} // namespace init
} // namespace android
diff --git a/init/ueventd_parser.h b/init/ueventd_parser.h
index 83684f39e..343d58bfd 100644
--- a/init/ueventd_parser.h
+++ b/init/ueventd_parser.h
@@ -21,30 +21,18 @@
#include <vector>
#include "devices.h"
-#include "parser.h"
namespace android {
namespace init {
-class SubsystemParser : public SectionParser {
- public:
- SubsystemParser(std::vector<Subsystem>* subsystems) : subsystems_(subsystems) {}
- Result<Success> ParseSection(std::vector<std::string>&& args, const std::string& filename,
- int line) override;
- Result<Success> ParseLineSection(std::vector<std::string>&& args, int line) override;
- Result<Success> EndSection() override;
-
- private:
- Result<Success> ParseDevName(std::vector<std::string>&& args);
- Result<Success> ParseDirName(std::vector<std::string>&& args);
-
- Subsystem subsystem_;
- std::vector<Subsystem>* subsystems_;
+struct UeventdConfiguration {
+ std::vector<Subsystem> subsystems;
+ std::vector<SysfsPermissions> sysfs_permissions;
+ std::vector<Permissions> dev_permissions;
+ std::vector<std::string> firmware_directories;
};
-Result<Success> ParsePermissionsLine(std::vector<std::string>&& args,
- std::vector<SysfsPermissions>* out_sysfs_permissions,
- std::vector<Permissions>* out_dev_permissions);
+UeventdConfiguration ParseConfig(const std::vector<std::string>& configs);
} // namespace init
} // namespace android
diff --git a/liblog/tests/libc_test.cpp b/liblog/tests/libc_test.cpp
index 329ba8585..6d78ed6db 100644
--- a/liblog/tests/libc_test.cpp
+++ b/liblog/tests/libc_test.cpp
@@ -21,6 +21,7 @@
TEST(libc, __pstore_append) {
#ifdef __ANDROID__
+#ifndef NO_PSTORE
FILE* fp;
ASSERT_TRUE(NULL != (fp = fopen("/dev/pmsg0", "a")));
static const char message[] = "libc.__pstore_append\n";
@@ -43,6 +44,9 @@ TEST(libc, __pstore_append) {
"Reboot, ensure string libc.__pstore_append is in "
"/sys/fs/pstore/pmsg-ramoops-0\n");
}
+#else /* NO_PSTORE */
+ GTEST_LOG_(INFO) << "This test does nothing because of NO_PSTORE.\n";
+#endif /* NO_PSTORE */
#else
GTEST_LOG_(INFO) << "This test does nothing.\n";
#endif
diff --git a/libutils/RefBase.cpp b/libutils/RefBase.cpp
index 8bccb0f5c..8eecaceeb 100644
--- a/libutils/RefBase.cpp
+++ b/libutils/RefBase.cpp
@@ -500,7 +500,7 @@ void RefBase::weakref_type::decWeak(const void* id)
weakref_impl* const impl = static_cast<weakref_impl*>(this);
impl->removeWeakRef(id);
const int32_t c = impl->mWeak.fetch_sub(1, std::memory_order_release);
- LOG_ALWAYS_FATAL_IF(BAD_WEAK(c), "decWeak called on %p too many times",
+ ALOGW_IF(BAD_WEAK(c), "decWeak called on %p too many times",
this);
if (c != 1) return;
atomic_thread_fence(std::memory_order_acquire);
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c
index d79e2c428..e39176a79 100644
--- a/lmkd/lmkd.c
+++ b/lmkd/lmkd.c
@@ -114,6 +114,7 @@ static unsigned long kill_timeout_ms;
static bool use_minfree_levels;
static bool enhance_batch_kill;
static bool enable_adaptive_lmk;
+static bool enable_userspace_lmk;
/* data required to handle events */
struct event_handler_info {
@@ -1459,7 +1460,7 @@ static int init(void) {
maxevents++;
has_inkernel_module = !access(INKERNEL_MINFREE_PATH, W_OK);
- use_inkernel_interface = has_inkernel_module;
+ use_inkernel_interface = has_inkernel_module && !enable_userspace_lmk;
if (use_inkernel_interface) {
ALOGI("Using in-kernel low memory killer interface");
@@ -1561,6 +1562,8 @@ int main(int argc __unused, char **argv __unused) {
property_get_bool("ro.lmk.enhance_batch_kill", true);
enable_adaptive_lmk =
property_get_bool("ro.lmk.enable_adaptive_lmk", false);
+ enable_userspace_lmk =
+ property_get_bool("ro.lmk.enable_userspace_lmk", false);
#ifdef LMKD_LOG_STATS
statslog_init(&log_ctx, &enable_stats_log);
diff --git a/rootdir/ueventd.rc b/rootdir/ueventd.rc
index b03d83bf1..2f85dec07 100644
--- a/rootdir/ueventd.rc
+++ b/rootdir/ueventd.rc
@@ -1,3 +1,5 @@
+firmware_directories /etc/firmware/ /odm/firmware/ /vendor/firmware/ /firmware/image/
+
subsystem adf
devname uevent_devname