Loading cmds/installd/otapreopt.cpp +29 −17 Original line number Diff line number Diff line Loading @@ -175,8 +175,10 @@ class OTAPreoptService { private: bool ReadSystemProperties() { // TODO This file does not have a stable format. It should be read by // code shared by init and otapreopt. See b/181182967#comment80 static constexpr const char* kPropertyFiles[] = { "/default.prop", "/system/build.prop" "/system/build.prop" }; for (size_t i = 0; i < arraysize(kPropertyFiles); ++i) { Loading @@ -193,8 +195,18 @@ private: // export NAME VALUE // For simplicity, don't respect string quotation. The values we are interested in can be // encoded without them. // init.environ.rc and etc/classpath have the same format for // environment variable exports and can be matched by the same regex. // TODO Just like with the system-properties above we really should have // common code between init and otapreopt to deal with reading these // things. See b/181182967 static constexpr const char* kEnvironmentVariableSources[] = { "/init.environ.rc", "/etc/classpath" }; std::regex export_regex("\\s*export\\s+(\\S+)\\s+(\\S+)"); bool parse_result = ParseFile("/init.environ.rc", [&](const std::string& line) { for (const char* env_vars_file : kEnvironmentVariableSources) { bool parse_result = ParseFile(env_vars_file, [&](const std::string& line) { std::smatch export_match; if (!std::regex_match(line, export_match, export_regex)) { return true; Loading @@ -214,7 +226,7 @@ private: if (!parse_result) { return false; } } if (system_properties_.GetProperty(kAndroidDataPathPropertyName) == nullptr) { return false; } Loading cmds/installd/otapreopt_chroot.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <libdm/dm.h> #include <selinux/android.h> #include <apex_file_repository.h> #include <apexd.h> #include "installd_constants.h" Loading Loading @@ -64,11 +65,14 @@ static std::vector<apex::ApexFile> ActivateApexPackages() { // system/apex/apexd/apexd.cpp. // // Only scan the APEX directory under /system, /system_ext and /vendor (within the chroot dir). std::vector<const char*> apex_dirs{apex::kApexPackageSystemDir, apex::kApexPackageSystemExtDir, std::vector<std::string> apex_dirs{apex::kApexPackageSystemDir, apex::kApexPackageSystemExtDir, apex::kApexPackageVendorDir}; // Initialize ApexFileRepository used internally in ScanPackagesDirAndActivate. // This is a quick fix to fix apex activation in otapreopt_chroot. apex::ApexFileRepository::GetInstance().AddPreInstalledApex(apex_dirs); for (const auto& dir : apex_dirs) { // Cast call to void to suppress warn_unused_result. static_cast<void>(apex::ScanPackagesDirAndActivate(dir)); static_cast<void>(apex::ScanPackagesDirAndActivate(dir.c_str())); } return apex::GetActivePackages(); } Loading include/input/InputTransport.h +15 −8 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include <unordered_map> #include <android-base/chrono_utils.h> #include <android-base/unique_fd.h> #include <binder/IBinder.h> #include <binder/Parcelable.h> Loading @@ -44,7 +45,6 @@ #include <utils/RefBase.h> #include <utils/Timers.h> #include <android-base/unique_fd.h> namespace android { class Parcel; Loading Loading @@ -76,10 +76,15 @@ struct InputMessage { uint32_t seq; } header; // Body *must* be 8 byte aligned. // For keys and motions, rely on the fact that std::array takes up exactly as much space // as the underlying data. This is not guaranteed by C++, but it simplifies the conversions. static_assert(sizeof(std::array<uint8_t, 32>) == 32); // For bool values, rely on the fact that they take up exactly one byte. This is not guaranteed // by C++ and is implementation-dependent, but it simplifies the conversions. static_assert(sizeof(bool) == 1); // Body *must* be 8 byte aligned. union Body { struct Key { int32_t eventId; Loading Loading @@ -154,8 +159,8 @@ struct InputMessage { } motion; struct Finished { uint32_t empty1; uint32_t handled; // actually a bool, but we must maintain 8-byte alignment bool handled; uint8_t empty[7]; nsecs_t consumeTime; // The time when the event was consumed by the receiving end inline size_t size() const { return sizeof(Finished); } Loading @@ -163,16 +168,18 @@ struct InputMessage { struct Focus { int32_t eventId; // The following two fields take up 4 bytes total uint16_t hasFocus; // actually a bool uint16_t inTouchMode; // actually a bool, but we must maintain 8-byte alignment // The following 3 fields take up 4 bytes total bool hasFocus; bool inTouchMode; uint8_t empty[2]; inline size_t size() const { return sizeof(Focus); } } focus; struct Capture { int32_t eventId; uint32_t pointerCaptureEnabled; // actually a bool, but we maintain 8-byte alignment bool pointerCaptureEnabled; uint8_t empty[3]; inline size_t size() const { return sizeof(Capture); } } capture; Loading libs/binder/Android.bp +5 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,11 @@ cc_library { "performance*", "portability*", ], pgo: { sampling: true, profile_file: "libbinder/libbinder.profdata", }, } // AIDL interface between libbinder and framework.jar Loading libs/input/InputTransport.cpp +8 −8 Original line number Diff line number Diff line Loading @@ -577,8 +577,8 @@ status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool h msg.header.type = InputMessage::Type::FOCUS; msg.header.seq = seq; msg.body.focus.eventId = eventId; msg.body.focus.hasFocus = hasFocus ? 1 : 0; msg.body.focus.inTouchMode = inTouchMode ? 1 : 0; msg.body.focus.hasFocus = hasFocus; msg.body.focus.inTouchMode = inTouchMode; return mChannel->sendMessage(&msg); } Loading @@ -595,7 +595,7 @@ status_t InputPublisher::publishCaptureEvent(uint32_t seq, int32_t eventId, msg.header.type = InputMessage::Type::CAPTURE; msg.header.seq = seq; msg.body.capture.eventId = eventId; msg.body.capture.pointerCaptureEnabled = pointerCaptureEnabled ? 1 : 0; msg.body.capture.pointerCaptureEnabled = pointerCaptureEnabled; return mChannel->sendMessage(&msg); } Loading @@ -615,7 +615,7 @@ status_t InputPublisher::receiveFinishedSignal( mChannel->getName().c_str(), NamedEnum::string(msg.header.type).c_str()); return UNKNOWN_ERROR; } callback(msg.header.seq, msg.body.finished.handled == 1, msg.body.finished.consumeTime); callback(msg.header.seq, msg.body.finished.handled, msg.body.finished.consumeTime); return OK; } Loading Loading @@ -1168,7 +1168,7 @@ status_t InputConsumer::sendUnchainedFinishedSignal(uint32_t seq, bool handled) InputMessage msg; msg.header.type = InputMessage::Type::FINISHED; msg.header.seq = seq; msg.body.finished.handled = handled ? 1 : 0; msg.body.finished.handled = handled; msg.body.finished.consumeTime = getConsumeTime(seq); status_t result = mChannel->sendMessage(&msg); if (result == OK) { Loading Loading @@ -1228,12 +1228,12 @@ void InputConsumer::initializeKeyEvent(KeyEvent* event, const InputMessage* msg) } void InputConsumer::initializeFocusEvent(FocusEvent* event, const InputMessage* msg) { event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus == 1, msg->body.focus.inTouchMode == 1); event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus, msg->body.focus.inTouchMode); } void InputConsumer::initializeCaptureEvent(CaptureEvent* event, const InputMessage* msg) { event->initialize(msg->body.capture.eventId, msg->body.capture.pointerCaptureEnabled == 1); event->initialize(msg->body.capture.eventId, msg->body.capture.pointerCaptureEnabled); } void InputConsumer::initializeMotionEvent(MotionEvent* event, const InputMessage* msg) { Loading Loading
cmds/installd/otapreopt.cpp +29 −17 Original line number Diff line number Diff line Loading @@ -175,8 +175,10 @@ class OTAPreoptService { private: bool ReadSystemProperties() { // TODO This file does not have a stable format. It should be read by // code shared by init and otapreopt. See b/181182967#comment80 static constexpr const char* kPropertyFiles[] = { "/default.prop", "/system/build.prop" "/system/build.prop" }; for (size_t i = 0; i < arraysize(kPropertyFiles); ++i) { Loading @@ -193,8 +195,18 @@ private: // export NAME VALUE // For simplicity, don't respect string quotation. The values we are interested in can be // encoded without them. // init.environ.rc and etc/classpath have the same format for // environment variable exports and can be matched by the same regex. // TODO Just like with the system-properties above we really should have // common code between init and otapreopt to deal with reading these // things. See b/181182967 static constexpr const char* kEnvironmentVariableSources[] = { "/init.environ.rc", "/etc/classpath" }; std::regex export_regex("\\s*export\\s+(\\S+)\\s+(\\S+)"); bool parse_result = ParseFile("/init.environ.rc", [&](const std::string& line) { for (const char* env_vars_file : kEnvironmentVariableSources) { bool parse_result = ParseFile(env_vars_file, [&](const std::string& line) { std::smatch export_match; if (!std::regex_match(line, export_match, export_regex)) { return true; Loading @@ -214,7 +226,7 @@ private: if (!parse_result) { return false; } } if (system_properties_.GetProperty(kAndroidDataPathPropertyName) == nullptr) { return false; } Loading
cmds/installd/otapreopt_chroot.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <libdm/dm.h> #include <selinux/android.h> #include <apex_file_repository.h> #include <apexd.h> #include "installd_constants.h" Loading Loading @@ -64,11 +65,14 @@ static std::vector<apex::ApexFile> ActivateApexPackages() { // system/apex/apexd/apexd.cpp. // // Only scan the APEX directory under /system, /system_ext and /vendor (within the chroot dir). std::vector<const char*> apex_dirs{apex::kApexPackageSystemDir, apex::kApexPackageSystemExtDir, std::vector<std::string> apex_dirs{apex::kApexPackageSystemDir, apex::kApexPackageSystemExtDir, apex::kApexPackageVendorDir}; // Initialize ApexFileRepository used internally in ScanPackagesDirAndActivate. // This is a quick fix to fix apex activation in otapreopt_chroot. apex::ApexFileRepository::GetInstance().AddPreInstalledApex(apex_dirs); for (const auto& dir : apex_dirs) { // Cast call to void to suppress warn_unused_result. static_cast<void>(apex::ScanPackagesDirAndActivate(dir)); static_cast<void>(apex::ScanPackagesDirAndActivate(dir.c_str())); } return apex::GetActivePackages(); } Loading
include/input/InputTransport.h +15 −8 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include <unordered_map> #include <android-base/chrono_utils.h> #include <android-base/unique_fd.h> #include <binder/IBinder.h> #include <binder/Parcelable.h> Loading @@ -44,7 +45,6 @@ #include <utils/RefBase.h> #include <utils/Timers.h> #include <android-base/unique_fd.h> namespace android { class Parcel; Loading Loading @@ -76,10 +76,15 @@ struct InputMessage { uint32_t seq; } header; // Body *must* be 8 byte aligned. // For keys and motions, rely on the fact that std::array takes up exactly as much space // as the underlying data. This is not guaranteed by C++, but it simplifies the conversions. static_assert(sizeof(std::array<uint8_t, 32>) == 32); // For bool values, rely on the fact that they take up exactly one byte. This is not guaranteed // by C++ and is implementation-dependent, but it simplifies the conversions. static_assert(sizeof(bool) == 1); // Body *must* be 8 byte aligned. union Body { struct Key { int32_t eventId; Loading Loading @@ -154,8 +159,8 @@ struct InputMessage { } motion; struct Finished { uint32_t empty1; uint32_t handled; // actually a bool, but we must maintain 8-byte alignment bool handled; uint8_t empty[7]; nsecs_t consumeTime; // The time when the event was consumed by the receiving end inline size_t size() const { return sizeof(Finished); } Loading @@ -163,16 +168,18 @@ struct InputMessage { struct Focus { int32_t eventId; // The following two fields take up 4 bytes total uint16_t hasFocus; // actually a bool uint16_t inTouchMode; // actually a bool, but we must maintain 8-byte alignment // The following 3 fields take up 4 bytes total bool hasFocus; bool inTouchMode; uint8_t empty[2]; inline size_t size() const { return sizeof(Focus); } } focus; struct Capture { int32_t eventId; uint32_t pointerCaptureEnabled; // actually a bool, but we maintain 8-byte alignment bool pointerCaptureEnabled; uint8_t empty[3]; inline size_t size() const { return sizeof(Capture); } } capture; Loading
libs/binder/Android.bp +5 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,11 @@ cc_library { "performance*", "portability*", ], pgo: { sampling: true, profile_file: "libbinder/libbinder.profdata", }, } // AIDL interface between libbinder and framework.jar Loading
libs/input/InputTransport.cpp +8 −8 Original line number Diff line number Diff line Loading @@ -577,8 +577,8 @@ status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool h msg.header.type = InputMessage::Type::FOCUS; msg.header.seq = seq; msg.body.focus.eventId = eventId; msg.body.focus.hasFocus = hasFocus ? 1 : 0; msg.body.focus.inTouchMode = inTouchMode ? 1 : 0; msg.body.focus.hasFocus = hasFocus; msg.body.focus.inTouchMode = inTouchMode; return mChannel->sendMessage(&msg); } Loading @@ -595,7 +595,7 @@ status_t InputPublisher::publishCaptureEvent(uint32_t seq, int32_t eventId, msg.header.type = InputMessage::Type::CAPTURE; msg.header.seq = seq; msg.body.capture.eventId = eventId; msg.body.capture.pointerCaptureEnabled = pointerCaptureEnabled ? 1 : 0; msg.body.capture.pointerCaptureEnabled = pointerCaptureEnabled; return mChannel->sendMessage(&msg); } Loading @@ -615,7 +615,7 @@ status_t InputPublisher::receiveFinishedSignal( mChannel->getName().c_str(), NamedEnum::string(msg.header.type).c_str()); return UNKNOWN_ERROR; } callback(msg.header.seq, msg.body.finished.handled == 1, msg.body.finished.consumeTime); callback(msg.header.seq, msg.body.finished.handled, msg.body.finished.consumeTime); return OK; } Loading Loading @@ -1168,7 +1168,7 @@ status_t InputConsumer::sendUnchainedFinishedSignal(uint32_t seq, bool handled) InputMessage msg; msg.header.type = InputMessage::Type::FINISHED; msg.header.seq = seq; msg.body.finished.handled = handled ? 1 : 0; msg.body.finished.handled = handled; msg.body.finished.consumeTime = getConsumeTime(seq); status_t result = mChannel->sendMessage(&msg); if (result == OK) { Loading Loading @@ -1228,12 +1228,12 @@ void InputConsumer::initializeKeyEvent(KeyEvent* event, const InputMessage* msg) } void InputConsumer::initializeFocusEvent(FocusEvent* event, const InputMessage* msg) { event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus == 1, msg->body.focus.inTouchMode == 1); event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus, msg->body.focus.inTouchMode); } void InputConsumer::initializeCaptureEvent(CaptureEvent* event, const InputMessage* msg) { event->initialize(msg->body.capture.eventId, msg->body.capture.pointerCaptureEnabled == 1); event->initialize(msg->body.capture.eventId, msg->body.capture.pointerCaptureEnabled); } void InputConsumer::initializeMotionEvent(MotionEvent* event, const InputMessage* msg) { Loading