summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2019-11-20 19:55:52 +0000
committerandroid-build-prod (mdb) <android-build-team-robot@google.com>2019-11-20 19:55:52 +0000
commit73aa67831c1550640e0e93fa8b14a1304ebdc14e (patch)
treeb26ab694c55fe9599817fc130c548410b2eab55f
parent185b9cfcf0e0e320dcba2adf145cf2f8f470bc5e (diff)
parent48ba50d54f0c27927c44c2dcdb424b85cd313496 (diff)
downloadcuttlefish_common-simpleperf-release.tar.gz
Snap for 6021634 from 48ba50d54f0c27927c44c2dcdb424b85cd313496 to simpleperf-releasesimpleperf-release
Change-Id: I7af73b9b67ef5d9f10583003bb31765a224d2a6e
-rw-r--r--Android.mk2
-rw-r--r--common/frontend/socket_vsock_proxy/Android.bp1
-rw-r--r--common/libs/auto_resources/auto_resources.cpp23
-rw-r--r--common/libs/auto_resources/auto_resources.h99
-rw-r--r--common/libs/fs/shared_fd.cpp31
-rw-r--r--common/libs/fs/shared_fd.h7
-rw-r--r--common/libs/net/netlink_request.cpp28
-rw-r--r--common/libs/net/netlink_request.h4
-rw-r--r--common/libs/utils/Android.bp2
-rw-r--r--common/libs/utils/archive.cpp4
-rw-r--r--guest/commands/vsoc_input_service/Android.bp7
-rw-r--r--guest/commands/vsoc_input_service/main.cpp4
-rw-r--r--guest/commands/vsoc_input_service/virtual_device_base.cpp3
-rw-r--r--guest/commands/vsoc_input_service/vsoc_input_service.cpp95
-rw-r--r--guest/hals/camera/EmulatedFakeCamera2.cpp6
-rw-r--r--guest/hals/gralloc/gralloc.cpp4
-rw-r--r--guest/hals/gralloc/legacy/gralloc.cpp4
-rw-r--r--guest/hals/health/android.hardware.health@2.0-service.cuttlefish.rc4
-rw-r--r--guest/hals/ril/cuttlefish_ril.cpp10
-rw-r--r--guest/hals/ril/libril/ril.cpp1
-rw-r--r--guest/hals/ril/libril/ril.h35
-rw-r--r--guest/hals/ril/libril/ril_commands.h1
-rwxr-xr-xguest/hals/ril/libril/ril_service.cpp34
-rw-r--r--guest/hals/ril/libril/ril_service.h4
-rw-r--r--guest/hals/sensors/Android.mk63
-rw-r--r--guest/hals/sensors/sensors.cpp186
-rw-r--r--guest/hals/sensors/sensors.h206
-rw-r--r--guest/hals/sensors/sensors_hal.cpp36
-rw-r--r--guest/hals/sensors/sensors_hal.h31
-rw-r--r--guest/hals/sensors/vsoc_sensors.cpp509
-rw-r--r--guest/hals/sensors/vsoc_sensors.h230
-rw-r--r--guest/hals/sensors/vsoc_sensors_message.cpp20
-rw-r--r--guest/hals/sensors/vsoc_sensors_message.h24
-rw-r--r--guest/monitoring/tombstone_transmit/tombstone_transmit.cpp4
-rw-r--r--host/commands/assemble_cvd/Android.bp6
-rw-r--r--host/commands/assemble_cvd/assemble_cvd.cc4
-rw-r--r--host/commands/assemble_cvd/flags.cc63
-rw-r--r--host/commands/assemble_cvd/super_image_mixer.cc140
-rw-r--r--host/commands/fetcher/Android.bp1
-rw-r--r--host/commands/kernel_log_monitor/Android.bp1
-rw-r--r--host/commands/kernel_log_monitor/main.cc4
-rw-r--r--host/commands/launch/Android.bp1
-rw-r--r--host/commands/launch/filesystem_explorer.cc68
-rw-r--r--host/commands/run_cvd/Android.bp1
-rw-r--r--host/commands/run_cvd/launch.cc73
-rw-r--r--host/commands/run_cvd/main.cc4
-rw-r--r--host/frontend/adb_connector/Android.bp1
-rw-r--r--host/frontend/vnc_server/virtual_inputs.cpp52
-rw-r--r--host/libs/config/cuttlefish_config.cpp20
-rw-r--r--host/libs/config/cuttlefish_config.h6
-rw-r--r--host/libs/config/fetcher_config.cpp16
-rw-r--r--host/libs/config/fetcher_config.h2
-rw-r--r--host/libs/vm_manager/Android.bp5
-rwxr-xr-xhost/libs/vm_manager/cf_qemu.sh7
-rw-r--r--host/libs/vm_manager/qemu_manager.cpp5
-rw-r--r--tests/hidl/hidl_implementation_test.cpp7
-rwxr-xr-xtools/create_base_image_arm.sh88
-rwxr-xr-xtools/make_manifest.sh26
58 files changed, 504 insertions, 1819 deletions
diff --git a/Android.mk b/Android.mk
index 0b78c872..8e69e18b 100644
--- a/Android.mk
+++ b/Android.mk
@@ -11,7 +11,7 @@
# 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.
-ifneq ($(filter vsoc_arm vsoc_arm64 vsoc_x86 vsoc_x86_64 vsoc_x86_noapex, $(TARGET_DEVICE)),)
+ifneq ($(filter vsoc_arm64 vsoc_x86 vsoc_x86_64, $(TARGET_BOARD_PLATFORM)),)
LOCAL_PATH:= $(call my-dir)
include $(call first-makefiles-under,$(LOCAL_PATH))
endif
diff --git a/common/frontend/socket_vsock_proxy/Android.bp b/common/frontend/socket_vsock_proxy/Android.bp
index 0a2f5726..d079e202 100644
--- a/common/frontend/socket_vsock_proxy/Android.bp
+++ b/common/frontend/socket_vsock_proxy/Android.bp
@@ -23,7 +23,6 @@ cc_binary {
"libbase",
"libcuttlefish_fs",
"libcuttlefish_utils",
- "libcuttlefish_strings",
"liblog",
],
static_libs: [
diff --git a/common/libs/auto_resources/auto_resources.cpp b/common/libs/auto_resources/auto_resources.cpp
index 3357b7e4..a57c9689 100644
--- a/common/libs/auto_resources/auto_resources.cpp
+++ b/common/libs/auto_resources/auto_resources.cpp
@@ -19,29 +19,6 @@
#include <stdlib.h>
#include <string.h>
-bool AutoCloseFILE::CopyFrom(const AutoCloseFILE& in) {
- char buffer[8192];
- while (!in.IsEOF()) {
- size_t num_read = fread(buffer, 1, sizeof(buffer), in);
- if (!num_read) {
- if (in.IsEOF()) {
- return true;
- }
- printf("%s: unable to fread %s:%d (%s)\n",
- __FUNCTION__, __FILE__, __LINE__, strerror(errno));
- return false;
- }
- size_t num_written = fwrite(buffer, 1, num_read, *this);
- if (num_written != num_read) {
- printf("%s: unable to fwrite, %zu != %zu %s:%d (%s)\n",
- __FUNCTION__, num_read, num_written, __FILE__, __LINE__,
- strerror(errno));
- return false;
- }
- }
- return true;
-}
-
AutoFreeBuffer::~AutoFreeBuffer() {
if (data_) free(data_);
}
diff --git a/common/libs/auto_resources/auto_resources.h b/common/libs/auto_resources/auto_resources.h
index 43cb6dc4..6dca6a83 100644
--- a/common/libs/auto_resources/auto_resources.h
+++ b/common/libs/auto_resources/auto_resources.h
@@ -32,92 +32,6 @@ char (&ArraySizeHelper(const T (&array)[N]))[N];
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
-// Automatically close a file descriptor
-class AutoCloseFILE {
- public:
- explicit AutoCloseFILE(FILE *f) : f_(f) { }
- virtual ~AutoCloseFILE() {
- if (f_) {
- (void)::fclose(f_);
- f_ = NULL;
- }
- }
-
- operator FILE*() const {
- return f_;
- }
-
- bool CopyFrom(const AutoCloseFILE& in);
-
- bool IsError() const {
- return f_ == NULL;
- }
-
- bool IsEOF() const {
- return IsError() || feof(f_);
- }
-
- bool IsOpen() const {
- return f_ != NULL;
- }
-
- // Close the underlying file descriptor, returning a status to give the caller
- // the chance to act on failure to close.
- // Returns true on success.
- bool close() {
- bool rval = true;
- if (f_) {
- rval = !::fclose(f_);
- f_ = NULL;
- }
- return rval;
- }
-
- private:
- AutoCloseFILE& operator=(const AutoCloseFILE & o);
- explicit AutoCloseFILE(const AutoCloseFILE &);
-
- FILE* f_;
-};
-
-// Automatically close a file descriptor
-class AutoCloseFileDescriptor {
- public:
- explicit AutoCloseFileDescriptor(int fd) : fd_(fd) { }
- virtual ~AutoCloseFileDescriptor() {
- if (fd_ != -1) {
- (void)::close(fd_);
- fd_ = -1;
- }
- }
-
- operator int() const {
- return fd_;
- }
-
- bool IsError() const {
- return fd_ == -1;
- }
-
- // Close the underlying file descriptor, returning a status to give the caller
- // the chance to act on failure to close.
- // Returns true on success.
- bool close() {
- bool rval = true;
- if (fd_ != -1) {
- rval = !::close(fd_);
- fd_ = -1;
- }
- return rval;
- }
-
- private:
- AutoCloseFileDescriptor& operator=(const AutoCloseFileDescriptor & o);
- explicit AutoCloseFileDescriptor(const AutoCloseFileDescriptor &);
-
- int fd_;
-};
-
// In C++11 this is just std::vector<char>, but Android isn't
// there yet.
class AutoFreeBuffer {
@@ -207,17 +121,4 @@ class AutoFreeBuffer {
AutoFreeBuffer& operator=(const AutoFreeBuffer&);
explicit AutoFreeBuffer(const AutoFreeBuffer&);
};
-
-class AutoUMask {
- public:
- explicit AutoUMask(mode_t mask) {
- prev_umask = umask(mask);
- }
-
- ~AutoUMask() {
- umask(prev_umask);
- }
- private:
- mode_t prev_umask;
-};
#endif // CUTTLEFISH_COMMON_COMMON_LIBS_AUTO_RESOURCES_AUTO_RESOURCES_H_
diff --git a/common/libs/fs/shared_fd.cpp b/common/libs/fs/shared_fd.cpp
index dde06046..6db27ee9 100644
--- a/common/libs/fs/shared_fd.cpp
+++ b/common/libs/fs/shared_fd.cpp
@@ -23,6 +23,7 @@
#include <netinet/in.h>
#include <unistd.h>
#include <algorithm>
+#include <vector>
#include "common/libs/auto_resources/auto_resources.h"
#include "common/libs/glog/logging.h"
@@ -57,8 +58,7 @@ void CheckMarked(fd_set* in_out_mask, SharedFDSet* in_out_set) {
namespace cvd {
bool FileInstance::CopyFrom(FileInstance& in) {
- AutoFreeBuffer buffer;
- buffer.Resize(8192);
+ std::vector<char> buffer(8192);
while (true) {
ssize_t num_read = in.Read(buffer.data(), buffer.size());
if (!num_read) {
@@ -78,8 +78,7 @@ bool FileInstance::CopyFrom(FileInstance& in) {
}
bool FileInstance::CopyFrom(FileInstance& in, size_t length) {
- AutoFreeBuffer buffer;
- buffer.Resize(8192);
+ std::vector<char> buffer(8192);
while (length > 0) {
ssize_t num_read = in.Read(buffer.data(), std::min(buffer.size(), length));
length -= num_read;
@@ -95,30 +94,34 @@ bool FileInstance::CopyFrom(FileInstance& in, size_t length) {
}
void FileInstance::Close() {
- AutoFreeBuffer message;
+ std::stringstream message;
if (fd_ == -1) {
errno_ = EBADF;
} else if (close(fd_) == -1) {
errno_ = errno;
if (identity_.size()) {
- message.PrintF("%s: %s failed (%s)", __FUNCTION__, identity_.data(),
- StrError());
- Log(message.data());
+ message << __FUNCTION__ << ": " << identity_ << " failed (" << StrError() << ")";
+ std::string message_str = message.str();
+ Log(message_str.c_str());
}
} else {
if (identity_.size()) {
- message.PrintF("%s: %s succeeded", __FUNCTION__, identity_.data());
- Log(message.data());
+ message << __FUNCTION__ << ": " << identity_ << "succeeded";
+ std::string message_str = message.str();
+ Log(message_str.c_str());
}
}
fd_ = -1;
}
void FileInstance::Identify(const char* identity) {
- identity_.PrintF("fd=%d @%p is %s", fd_, this, identity);
- AutoFreeBuffer message;
- message.PrintF("%s: %s", __FUNCTION__, identity_.data());
- Log(message.data());
+ std::stringstream identity_stream;
+ identity_stream << "fd=" << fd_ << " @" << this << " is " << identity;
+ identity_ = identity_stream.str();
+ std::stringstream message;
+ message << __FUNCTION__ << ": " << identity_;
+ std::string message_str = message.str();
+ Log(message_str.c_str());
}
bool FileInstance::IsSet(fd_set* in) const {
diff --git a/common/libs/fs/shared_fd.h b/common/libs/fs/shared_fd.h
index b811f4a7..b64ad091 100644
--- a/common/libs/fs/shared_fd.h
+++ b/common/libs/fs/shared_fd.h
@@ -33,6 +33,7 @@
#include <sys/un.h>
#include <memory>
+#include <sstream>
#include <errno.h>
#include <fcntl.h>
@@ -515,7 +516,9 @@ class FileInstance {
// Ensure every file descriptor managed by a FileInstance has the CLOEXEC
// flag
TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, FD_CLOEXEC));
- identity_.PrintF("fd=%d @%p", fd, this);
+ std::stringstream identity;
+ identity << "fd=" << fd << " @" << this;
+ identity_ = identity.str();
}
FileInstance* Accept(struct sockaddr* addr, socklen_t* addrlen) const {
@@ -529,7 +532,7 @@ class FileInstance {
int fd_;
int errno_;
- AutoFreeBuffer identity_;
+ std::string identity_;
char strerror_buf_[160];
};
diff --git a/common/libs/net/netlink_request.cpp b/common/libs/net/netlink_request.cpp
index 28690a41..501b2c35 100644
--- a/common/libs/net/netlink_request.cpp
+++ b/common/libs/net/netlink_request.cpp
@@ -20,6 +20,7 @@
#include <net/if.h>
#include <string.h>
+#include <algorithm>
#include <string>
#include <vector>
@@ -35,21 +36,16 @@ uint32_t NetlinkRequest::SeqNo() const {
}
void* NetlinkRequest::AppendRaw(const void* data, size_t length) {
- void* out = request_.end();
-
- request_.Append(data, length);
- int pad = RTA_ALIGN(length) - length;
- if (pad > 0) {
- request_.Resize(request_.size() + pad);
- }
-
- return out;
+ auto* output = static_cast<char*>(ReserveRaw(length));
+ const auto* input = static_cast<const char*>(data);
+ std::copy(input, input + length, output);
+ return output;
}
void* NetlinkRequest::ReserveRaw(size_t length) {
- void* out = request_.end();
- request_.Resize(request_.size() + RTA_ALIGN(length));
- return out;
+ size_t original_size = request_.size();
+ request_.resize(original_size + RTA_ALIGN(length), '\0');
+ return reinterpret_cast<void*>(request_.data() + original_size);
}
nlattr* NetlinkRequest::AppendTag(
@@ -61,9 +57,9 @@ nlattr* NetlinkRequest::AppendTag(
return attr;
}
-NetlinkRequest::NetlinkRequest(int32_t command, int32_t flags)
- : request_(512),
- header_(Reserve<nlmsghdr>()) {
+NetlinkRequest::NetlinkRequest(int32_t command, int32_t flags) {
+ request_.reserve(512);
+ header_ = Reserve<nlmsghdr>();
flags |= NLM_F_ACK | NLM_F_REQUEST;
header_->nlmsg_flags = flags;
header_->nlmsg_type = command;
@@ -75,7 +71,7 @@ NetlinkRequest::NetlinkRequest(NetlinkRequest&& other) {
using std::swap;
swap(lists_, other.lists_);
swap(header_, other.header_);
- request_.Swap(other.request_);
+ swap(request_, other.request_);
}
void NetlinkRequest::AddString(uint16_t type, const std::string& value) {
diff --git a/common/libs/net/netlink_request.h b/common/libs/net/netlink_request.h
index e0f8753a..5e5b3557 100644
--- a/common/libs/net/netlink_request.h
+++ b/common/libs/net/netlink_request.h
@@ -23,8 +23,6 @@
#include <string>
#include <vector>
-#include "common/libs/auto_resources/auto_resources.h"
-
namespace cvd {
// Abstraction of Network link request.
// Used to supply kernel with information about which interface needs to be
@@ -100,7 +98,7 @@ class NetlinkRequest {
nlattr* AppendTag(uint16_t type, const void* data, uint16_t length);
std::vector<std::pair<nlattr*, int32_t>> lists_;
- AutoFreeBuffer request_;
+ std::vector<char> request_;
nlmsghdr* header_;
NetlinkRequest(const NetlinkRequest&) = delete;
diff --git a/common/libs/utils/Android.bp b/common/libs/utils/Android.bp
index 1bd252d9..f2a5aff7 100644
--- a/common/libs/utils/Android.bp
+++ b/common/libs/utils/Android.bp
@@ -31,7 +31,6 @@ cc_library {
shared_libs: [
"libbase",
"libcuttlefish_fs",
- "libcuttlefish_strings",
"cuttlefish_auto_resources",
],
},
@@ -39,7 +38,6 @@ cc_library {
static_libs: [
"libbase",
"libcuttlefish_fs",
- "libcuttlefish_strings",
"cuttlefish_auto_resources",
],
},
diff --git a/common/libs/utils/archive.cpp b/common/libs/utils/archive.cpp
index a22db4fd..c1c496d0 100644
--- a/common/libs/utils/archive.cpp
+++ b/common/libs/utils/archive.cpp
@@ -19,9 +19,9 @@
#include <string>
#include <vector>
+#include <android-base/strings.h>
#include <glog/logging.h>
-#include "common/libs/strings/str_split.h"
#include "common/libs/utils/subprocess.h"
namespace cvd {
@@ -43,7 +43,7 @@ std::vector<std::string> Archive::Contents() {
LOG(ERROR) << "`bsdtar -tf \"" << file << "\"` returned " << bsdtar_ret;
}
return bsdtar_ret == 0
- ? cvd::StrSplit(bsdtar_output, '\n')
+ ? android::base::Split(bsdtar_output, "\n")
: std::vector<std::string>();
}
diff --git a/guest/commands/vsoc_input_service/Android.bp b/guest/commands/vsoc_input_service/Android.bp
index 76aae19f..73ca0671 100644
--- a/guest/commands/vsoc_input_service/Android.bp
+++ b/guest/commands/vsoc_input_service/Android.bp
@@ -24,12 +24,19 @@ cc_binary {
"virtual_touchscreen.cpp",
"vsoc_input_service.cpp",
],
+ static_libs: [
+ "libgflags",
+ ],
shared_libs: [
"cuttlefish_auto_resources",
+ "libcuttlefish_device_config",
"libcuttlefish_fs",
"libbase",
"liblog",
"vsoc_lib",
],
+ header_libs: [
+ "cuttlefish_glog",
+ ],
defaults: ["cuttlefish_guest_only"]
}
diff --git a/guest/commands/vsoc_input_service/main.cpp b/guest/commands/vsoc_input_service/main.cpp
index 47b02a5f..c9e93ede 100644
--- a/guest/commands/vsoc_input_service/main.cpp
+++ b/guest/commands/vsoc_input_service/main.cpp
@@ -15,10 +15,12 @@
*/
#include "log/log.h"
+#include <gflags/gflags.h>
#include "vsoc_input_service.h"
-int main(int /* arg */, char* /* argv */[]) {
+int main(int argc, char* argv[]) {
+ gflags::ParseCommandLineFlags(&argc, &argv, true);
vsoc_input_service::VSoCInputService service;
if (!service.SetUpDevices()) {
return -1;
diff --git a/guest/commands/vsoc_input_service/virtual_device_base.cpp b/guest/commands/vsoc_input_service/virtual_device_base.cpp
index d0c16bda..0abb0cd9 100644
--- a/guest/commands/vsoc_input_service/virtual_device_base.cpp
+++ b/guest/commands/vsoc_input_service/virtual_device_base.cpp
@@ -16,6 +16,7 @@
#include "virtual_device_base.h"
+#include <glog/logging.h>
#include <errno.h>
#include <inttypes.h>
#include <string.h>
@@ -103,6 +104,8 @@ bool VirtualDeviceBase::SetUp() {
return false;
}
+ LOG(INFO) << "set up virtual device";
+
return true;
}
diff --git a/guest/commands/vsoc_input_service/vsoc_input_service.cpp b/guest/commands/vsoc_input_service/vsoc_input_service.cpp
index d100a527..8753735c 100644
--- a/guest/commands/vsoc_input_service/vsoc_input_service.cpp
+++ b/guest/commands/vsoc_input_service/vsoc_input_service.cpp
@@ -18,37 +18,35 @@
#include <linux/input.h>
#include <linux/uinput.h>
+#include <linux/virtio_input.h>
#include <thread>
+#include <gflags/gflags.h>
#include "log/log.h"
+#include <glog/logging.h>
-#include "common/vsoc/lib/screen_region_view.h"
+#include "common/libs/fs/shared_fd.h"
+#include "common/libs/device_config/device_config.h"
#include "common/vsoc/lib/input_events_region_view.h"
-using vsoc::screen::ScreenRegionView;
using vsoc::input_events::InputEvent;
-using vsoc::input_events::InputEventsRegionView;
using vsoc_input_service::VirtualDeviceBase;
using vsoc_input_service::VirtualKeyboard;
using vsoc_input_service::VirtualPowerButton;
using vsoc_input_service::VirtualTouchScreen;
using vsoc_input_service::VSoCInputService;
+DEFINE_uint32(keyboard_port, 0, "keyboard vsock port");
+DEFINE_uint32(touch_port, 0, "keyboard vsock port");
+
namespace {
void EventLoop(std::shared_ptr<VirtualDeviceBase> device,
- std::function<int(InputEvent*, int)> next_events) {
+ std::function<InputEvent()> next_event) {
while (1) {
- InputEvent events[InputEventsRegionView::kMaxEventsPerPacket];
- int count = next_events(events, InputEventsRegionView::kMaxEventsPerPacket);
- if (count <= 0) {
- SLOGE("Error getting events from the queue: Maybe check packet size");
- continue;
- }
- for (int i = 0; i < count; ++i) {
- device->EmitEvent(events[i].type, events[i].code, events[i].value);
- }
+ InputEvent event = next_event();
+ device->EmitEvent(event.type, event.code, event.value);
}
}
@@ -64,14 +62,14 @@ bool VSoCInputService::SetUpDevices() {
return false;
}
- auto screen_view = ScreenRegionView::GetInstance();
- if (!screen_view) {
- SLOGE("Failed to open framebuffer broadcast region");
+ auto config = cvd::DeviceConfig::Get();
+ if (!config) {
+ LOG(ERROR) << "Failed to open device config";
return false;
}
virtual_touchscreen_.reset(
- new VirtualTouchScreen(screen_view->x_res(), screen_view->y_res()));
+ new VirtualTouchScreen(config->screen_x_res(), config->screen_y_res()));
if (!virtual_touchscreen_->SetUp()) {
return false;
}
@@ -80,35 +78,56 @@ bool VSoCInputService::SetUpDevices() {
}
bool VSoCInputService::ProcessEvents() {
- auto input_events_rv = InputEventsRegionView::GetInstance();
- // TODO(jemoreira): Post available devices to region
- auto worker = input_events_rv->StartWorker();
+ cvd::SharedFD keyboard_fd;
+ cvd::SharedFD touch_fd;
+
+ LOG(INFO) << "Connecting to the keyboard at " << FLAGS_keyboard_port;
+ if (FLAGS_keyboard_port) {
+ keyboard_fd = cvd::SharedFD::VsockClient(2, FLAGS_keyboard_port, SOCK_STREAM);
+ if (!keyboard_fd->IsOpen()) {
+ LOG(ERROR) << "Could not connect to the keyboard at vsock:2:" << FLAGS_keyboard_port;
+ }
+ LOG(INFO) << "Connected to keyboard";
+ }
+ LOG(INFO) << "Connecting to the touchscreen at " << FLAGS_keyboard_port;
+ if (FLAGS_touch_port) {
+ touch_fd = cvd::SharedFD::VsockClient(2, FLAGS_touch_port, SOCK_STREAM);
+ if (!touch_fd->IsOpen()) {
+ LOG(ERROR) << "Could not connect to the touch at vsock:2:" << FLAGS_touch_port;
+ }
+ LOG(INFO) << "Connected to touch";
+ }
// Start device threads
- std::thread screen_thread([this]() {
- EventLoop(
- virtual_touchscreen_, [](InputEvent* event_buffer, int max_events) {
- return InputEventsRegionView::GetInstance()->GetScreenEventsOrWait(
- event_buffer, max_events);
- });
- });
- std::thread keyboard_thread([this]() {
- EventLoop(virtual_keyboard_, [](InputEvent* event_buffer, int max_events) {
- return InputEventsRegionView::GetInstance()->GetKeyboardEventsOrWait(
- event_buffer, max_events);
+ std::thread screen_thread([this, touch_fd]() {
+ EventLoop(virtual_touchscreen_, [touch_fd]() {
+ struct virtio_input_event event;
+ if (touch_fd->Read(&event, sizeof(event)) != sizeof(event)) {
+ LOG(FATAL) << "Could not read touch event: " << touch_fd->StrError();
+ }
+ return InputEvent {
+ .type = event.type,
+ .code = event.code,
+ .value = event.value,
+ };
});
});
- std::thread button_thread([this]() {
- EventLoop(virtual_power_button_,
- [](InputEvent* event_buffer, int max_events) {
- return InputEventsRegionView::GetInstance()
- ->GetPowerButtonEventsOrWait(event_buffer, max_events);
- });
+ std::thread keyboard_thread([this, keyboard_fd]() {
+ EventLoop(virtual_keyboard_, [keyboard_fd]() {
+ struct virtio_input_event event;
+ if (keyboard_fd->Read(&event, sizeof(event)) != sizeof(event)) {
+ LOG(FATAL) << "Could not read keyboard event: " << keyboard_fd->StrError();
+ }
+ return InputEvent {
+ .type = event.type,
+ .code = event.code,
+ .value = event.value,
+ };
+ });
});
screen_thread.join();
keyboard_thread.join();
- button_thread.join();
// Should never return
return false;
diff --git a/guest/hals/camera/EmulatedFakeCamera2.cpp b/guest/hals/camera/EmulatedFakeCamera2.cpp
index 63a5c1a9..e2923619 100644
--- a/guest/hals/camera/EmulatedFakeCamera2.cpp
+++ b/guest/hals/camera/EmulatedFakeCamera2.cpp
@@ -1441,12 +1441,12 @@ status_t EmulatedFakeCamera2::ReadoutThread::collectStatisticsMetadata(
// To simulate some kind of real detection going on, we jitter the rectangles
// on each frame by a few pixels in each dimension.
for (size_t i = 0; i < numFaces * 4; i++) {
- rects[i] += (int32_t)(((float)rand() / RAND_MAX) * 6 - 3);
+ rects[i] += (int32_t)(((float)rand() / (float)RAND_MAX) * 6 - 3);
}
// The confidence scores (0-100) are similarly jittered.
uint8_t scores[numFaces] = {85, 95};
for (size_t i = 0; i < numFaces; i++) {
- scores[i] += (int32_t)(((float)rand() / RAND_MAX) * 10 - 5);
+ scores[i] += (int32_t)(((float)rand() / (float)RAND_MAX) * 10 - 5);
}
res = add_camera_metadata_entry(frame, ANDROID_STATISTICS_FACE_RECTANGLES,
@@ -1485,7 +1485,7 @@ status_t EmulatedFakeCamera2::ReadoutThread::collectStatisticsMetadata(
};
// Jitter these a bit less than the rects
for (size_t i = 0; i < numFaces * 6; i++) {
- features[i] += (int32_t)(((float)rand() / RAND_MAX) * 4 - 2);
+ features[i] += (int32_t)(((float)rand() / (float)RAND_MAX) * 4 - 2);
}
// These are unique IDs that are used to identify each face while it's
// visible to the detector (if a face went away and came back, it'd get a
diff --git a/guest/hals/gralloc/gralloc.cpp b/guest/hals/gralloc/gralloc.cpp
index bf672eea..d21d918d 100644
--- a/guest/hals/gralloc/gralloc.cpp
+++ b/guest/hals/gralloc/gralloc.cpp
@@ -312,9 +312,9 @@ struct vsoc_gralloc_module_t HAL_MODULE_INFO_SYM = {
.unregisterBuffer = unregister_buffer,
.lock = lock,
.unlock = unlock,
- .lock_ycbcr = lock_ycbcr,
.perform = NULL,
- .validateBufferSize = NULL,
+ .lock_ycbcr = lock_ycbcr,
.getTransportSize = NULL,
+ .validateBufferSize = NULL,
},
};
diff --git a/guest/hals/gralloc/legacy/gralloc.cpp b/guest/hals/gralloc/legacy/gralloc.cpp
index a100a764..8a0cbd2e 100644
--- a/guest/hals/gralloc/legacy/gralloc.cpp
+++ b/guest/hals/gralloc/legacy/gralloc.cpp
@@ -194,11 +194,11 @@ struct private_module_t HAL_MODULE_INFO_SYM = {
.unregisterBuffer = gralloc_unregister_buffer,
.lock = gralloc_lock,
.unlock = gralloc_unlock,
- .validateBufferSize = gralloc_validate_buffer_size,
- .getTransportSize = gralloc_get_transport_size,
#ifdef GRALLOC_MODULE_API_VERSION_0_2
.perform = NULL,
.lock_ycbcr = gralloc_lock_ycbcr,
#endif
+ .getTransportSize = gralloc_get_transport_size,
+ .validateBufferSize = gralloc_validate_buffer_size,
},
};
diff --git a/guest/hals/health/android.hardware.health@2.0-service.cuttlefish.rc b/guest/hals/health/android.hardware.health@2.0-service.cuttlefish.rc
deleted file mode 100644
index c225ee8d..00000000
--- a/guest/hals/health/android.hardware.health@2.0-service.cuttlefish.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.cuttlefish
- class hal
- user system
- group system
diff --git a/guest/hals/ril/cuttlefish_ril.cpp b/guest/hals/ril/cuttlefish_ril.cpp
index 20534297..cf791b9f 100644
--- a/guest/hals/ril/cuttlefish_ril.cpp
+++ b/guest/hals/ril/cuttlefish_ril.cpp
@@ -2229,6 +2229,13 @@ static void request_get_modem_stack_status(int /*request*/, RIL_Token t) {
return;
}
+static void request_set_signal_strength_reporting_criteria_1_5(int /*request*/, void* /*data*/,
+ size_t /*datalen*/, RIL_Token t) {
+ ALOGV("request_set_signal_strength_reporting_criteria_1_5 - void");
+ gce_ril_env->OnRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
+ return;
+}
+
static void request_enable_modem(int /*request*/, RIL_Token t) {
ALOGV("Enabling modem - void");
gce_ril_env->OnRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
@@ -2473,6 +2480,9 @@ static void gce_ril_on_request(int request, void* data, size_t datalen,
case RIL_REQUEST_START_NETWORK_SCAN4:
request_start_network_scan4(t);
break;
+ case RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA_1_5:
+ request_set_signal_strength_reporting_criteria_1_5(request, data, datalen, t);
+ break;
case RIL_REQUEST_GET_MODEM_STACK_STATUS:
request_get_modem_stack_status(request, t);
break;
diff --git a/guest/hals/ril/libril/ril.cpp b/guest/hals/ril/libril/ril.cpp
index 3637ac4c..ef77ed29 100644
--- a/guest/hals/ril/libril/ril.cpp
+++ b/guest/hals/ril/libril/ril.cpp
@@ -1169,6 +1169,7 @@ requestToString(int request) {
case RIL_REQUEST_GET_CARRIER_RESTRICTIONS: return "GET_CARRIER_RESTRICTIONS";
case RIL_REQUEST_GET_CARRIER_RESTRICTIONS_1_4: return "GET_CARRIER_RESTRICTIONS_1_4";
case RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION: return "SET_CARRIER_INFO_IMSI_ENCRYPTION";
+ case RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA_1_5: return "SET_SIGNAL_STRENGTH_REPORTING_CRITERIA_1_5";
case RIL_RESPONSE_ACKNOWLEDGEMENT: return "RESPONSE_ACKNOWLEDGEMENT";
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
diff --git a/guest/hals/ril/libril/ril.h b/guest/hals/ril/libril/ril.h
index 9b1b0ff9..caf6939a 100644
--- a/guest/hals/ril/libril/ril.h
+++ b/guest/hals/ril/libril/ril.h
@@ -6561,6 +6561,41 @@ typedef struct {
*/
#define RIL_REQUEST_GET_CARRIER_RESTRICTIONS_1_4 154
+/**
+ * Sets the signal strength reporting criteria.
+ *
+ * The resulting reporting rules are the AND of all the supplied criteria. For each RAN
+ * The hysteresisDb apply to only the following measured quantities:
+ * -GERAN - RSSI
+ * -CDMA2000 - RSSI
+ * -UTRAN - RSCP
+ * -EUTRAN - RSRP/RSRQ/RSSNR
+ *
+ * The thresholds apply to only the following measured quantities:
+ * -GERAN - RSSI
+ * -CDMA2000 - RSSI
+ * -UTRAN - RSCP
+ * -EUTRAN - RSRP/RSRQ/RSSNR
+ * -NGRAN - SSRSRP/SSRSRQ/SSSINR
+ *
+ * Note: Reporting criteria must be individually set for each RAN. For any unset reporting
+ * criteria, the value is implementation-defined.
+ *
+ * Note: @1.5::SignalThresholdInfo includes fields 'hysteresisDb', 'hysteresisMs',
+ * and 'thresholds'. As this mechanism generally only constrains reports based on one
+ * measured quantity per RAN, if multiple measured quantities must be used to trigger a report
+ * for a given RAN, the only valid field may be hysteresisMs: hysteresisDb and thresholds must
+ * be set to zero and length zero respectively. If either hysteresisDb or thresholds is set,
+ * then reports shall only be triggered by the respective measured quantity, subject to the
+ * applied constraints.
+ *
+ * Valid errors returned:
+ * RadioError:NONE
+ * RadioError:INVALID_ARGUMENTS
+ * RadioError:RADIO_NOT_AVAILABLE
+ */
+#define RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA_1_5 155
+
/***********************************************************************/
/**
diff --git a/guest/hals/ril/libril/ril_commands.h b/guest/hals/ril/libril/ril_commands.h
index 93559900..3f451519 100644
--- a/guest/hals/ril/libril/ril_commands.h
+++ b/guest/hals/ril/libril/ril_commands.h
@@ -169,3 +169,4 @@
{RIL_REQUEST_ENABLE_MODEM, radio_1_5::enableModemResponse},
{RIL_REQUEST_SET_CARRIER_RESTRICTIONS_1_4, radio_1_5::setAllowedCarriersResponse4},
{RIL_REQUEST_GET_CARRIER_RESTRICTIONS_1_4, radio_1_5::getAllowedCarriersResponse4},
+ {RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA_1_5, radio_1_5::setSignalStrengthReportingCriteriaResponse_1_5},
diff --git a/guest/hals/ril/libril/ril_service.cpp b/guest/hals/ril/libril/ril_service.cpp
index 6101a2e6..9e009a59 100755
--- a/guest/hals/ril/libril/ril_service.cpp
+++ b/guest/hals/ril/libril/ril_service.cpp
@@ -531,6 +531,11 @@ struct RadioImpl_1_5 : public V1_5::IRadio {
::android::hardware::radio::V1_4::SimLockMultiSimPolicy multiSimPolicy);
Return<void> getAllowedCarriers_1_4(int32_t serial);
Return<void> getSignalStrength_1_4(int32_t serial);
+
+ // Methods from ::android::hardware::radio::V1_5::IRadio follow.
+ Return<void> setSignalStrengthReportingCriteria_1_5(int32_t serial,
+ const ::android::hardware::radio::V1_5::SignalThresholdInfo& signalThresholdInfo,
+ const ::android::hardware::radio::V1_5::AccessNetwork accessNetwork);
};
struct OemHookImpl : public IOemHook {
@@ -3207,6 +3212,16 @@ Return<void> RadioImpl_1_5::setSignalStrengthReportingCriteria(int32_t /* serial
return Void();
}
+Return<void> RadioImpl_1_5::setSignalStrengthReportingCriteria_1_5(int32_t /* serial */,
+ const ::android::hardware::radio::V1_5::SignalThresholdInfo& /* signalThresholdInfo */,
+ const ::android::hardware::radio::V1_5::AccessNetwork /* accessNetwork */) {
+ // TODO implement
+#if VDBG
+ RLOGE("[%04d]< %s", serial, "Method is not implemented");
+#endif
+ return Void();
+}
+
Return<void> RadioImpl_1_5::setLinkCapacityReportingCriteria(int32_t /* serial */,
int32_t /* hysteresisMs */, int32_t /* hysteresisDlKbps */, int32_t /* hysteresisUlKbps */,
const hidl_vec<int32_t>& /* thresholdsDownlinkKbps */,
@@ -7659,6 +7674,25 @@ int radio_1_5::setSystemSelectionChannelsResponse(int slotId, int responseType,
return 0;
}
+int radio_1_5::setSignalStrengthReportingCriteriaResponse_1_5(int slotId, int responseType,
+ int serial, RIL_Errno e, void* /* response */,
+ size_t responseLen) {
+#if VDBG
+ RLOGD("%s(): %d", __FUNCTION__, serial);
+#endif
+ RadioResponseInfo responseInfo = {};
+ populateResponseInfo(responseInfo, serial, responseType, e);
+
+ if (radioService[slotId]->mRadioResponseV1_5 == NULL) {
+ RLOGE("%s: radioService[%d]->mRadioResponseV1_5 == NULL", __FUNCTION__, slotId);
+ Return<void> retStatus =
+ radioService[slotId]->mRadioResponseV1_5->setSignalStrengthReportingCriteriaResponse_1_5(
+ responseInfo);
+ radioService[slotId]->checkReturnStatus(retStatus);
+ }
+ return 0;
+}
+
/***************************************************************************************************
* INDICATION FUNCTIONS
* The below function handle unsolicited messages coming from the Radio
diff --git a/guest/hals/ril/libril/ril_service.h b/guest/hals/ril/libril/ril_service.h
index be01d6dd..b6ba3e41 100644
--- a/guest/hals/ril/libril/ril_service.h
+++ b/guest/hals/ril/libril/ril_service.h
@@ -778,6 +778,10 @@ int getAllowedCarriersResponse4(int slotId,
void *response,
size_t responselen);
+int setSignalStrengthReportingCriteriaResponse_1_5(int slotId,
+ int responseType, int serial, RIL_Errno e,
+ void *response, size_t responselen);
+
pthread_rwlock_t * getRadioServiceRwlock(int slotId);
void setNitzTimeReceived(int slotId, long timeReceived);
diff --git a/guest/hals/sensors/Android.mk b/guest/hals/sensors/Android.mk
deleted file mode 100644
index e9a1a1af..00000000
--- a/guest/hals/sensors/Android.mk
+++ /dev/null
@@ -1,63 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-# HAL module implemenation stored in
-# hw/<SENSORS_HARDWARE_MODULE_ID>.<ro.hardware>.so
-include $(CLEAR_VARS)
-
-ifeq (0, $(shell test $(PLATFORM_SDK_VERSION) -ge 21; echo $$?))
-LOCAL_MODULE_RELATIVE_PATH := hw
-else
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
-endif
-LOCAL_MULTILIB := first
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SHARED_LIBRARIES := \
- $(VSOC_STLPORT_LIBS) \
- libcuttlefish_fs \
- cuttlefish_auto_resources \
- liblog \
- libcutils
-
-LOCAL_HEADER_LIBRARIES := \
- libhardware_headers
-
-LOCAL_SRC_FILES := \
- sensors.cpp \
- sensors_hal.cpp \
- vsoc_sensors.cpp \
- vsoc_sensors_message.cpp
-
-LOCAL_CFLAGS := -DLOG_TAG=\"VSoC-Sensors\" \
- $(VSOC_VERSION_CFLAGS) \
- -std=c++17 \
- -Werror -Wall -Wno-missing-field-initializers -Wno-unused-parameter
-
-LOCAL_C_INCLUDES := \
- $(VSOC_STLPORT_INCLUDES) \
- device/google/cuttlefish_common \
- system/extras
-
-LOCAL_STATIC_LIBRARIES := \
- libcutils \
- libcuttlefish_remoter_framework \
- $(VSOC_STLPORT_STATIC_LIBS)
-
-LOCAL_MODULE := sensors.cutf
-LOCAL_VENDOR_MODULE := true
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/guest/hals/sensors/sensors.cpp b/guest/hals/sensors/sensors.cpp
deleted file mode 100644
index 951461db..00000000
--- a/guest/hals/sensors/sensors.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * 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 "guest/hals/sensors/vsoc_sensors.h"
-
-#include <limits>
-
-#include "guest/hals/sensors/sensors.h"
-
-namespace cvd {
-namespace {
-const cvd::time::Milliseconds kDefaultSamplingRate(200);
-
-timespec infinity() {
- timespec ts;
- ts.tv_sec = std::numeric_limits<time_t>::max();
- ts.tv_nsec = 0;
- return ts;
-}
-} // namespace
-
-const cvd::time::MonotonicTimePoint SensorState::kInfinity =
- cvd::time::MonotonicTimePoint(infinity());
-
-SensorState::SensorState(SensorInfo info)
- : enabled_(false),
- event_(),
- deadline_(kInfinity),
- sampling_period_(kDefaultSamplingRate) {
- event_.sensor = info.handle;
- event_.type = info.type;
-}
-
-SensorInfo::SensorInfo(const char* name, const char* vendor, int version,
- int handle, int type, float max_range, float resolution,
- float power, int32_t min_delay,
- uint32_t fifo_reserved_event_count,
- uint32_t fifo_max_event_count, const char* string_type,
- const char* required_permission, int32_t max_delay,
- uint32_t reporting_mode) {
- this->name = name;
- this->vendor = vendor;
- this->version = version;
- this->handle = handle;
- this->type = type;
- this->maxRange = max_range;
- this->resolution = resolution;
- this->power = power;
- this->minDelay = min_delay;
- this->fifoReservedEventCount = fifo_reserved_event_count;
- this->fifoMaxEventCount = fifo_max_event_count;
- this->stringType = string_type;
- this->requiredPermission = required_permission;
- this->maxDelay = max_delay;
- this->flags = reporting_mode;
-}
-
-namespace sc = sensors_constants;
-
-SensorInfo AccelerometerSensor() {
- uint32_t flags = sc::kAccelerometerReportingMode |
- (sc::kAccelerometerIsWakeup ? SENSOR_FLAG_WAKE_UP : 0);
-
- return SensorInfo(sc::kAccelerometerName, sc::kVendor, sc::kVersion,
- sc::kAccelerometerHandle, SENSOR_TYPE_ACCELEROMETER,
- sc::kAccelerometerMaxRange, sc::kAccelerometerResolution,
- sc::kAccelerometerPower, sc::kAccelerometerMinDelay,
- sc::kFifoReservedEventCount, sc::kFifoMaxEventCount,
- sc::kAccelerometerStringType, sc::kRequiredPermission,
- sc::kMaxDelay, flags);
-}
-
-SensorInfo GyroscopeSensor() {
- uint32_t flags = sc::kGyroscopeReportingMode |
- (sc::kGyroscopeIsWakeup ? SENSOR_FLAG_WAKE_UP : 0);
-
- return SensorInfo(
- sc::kGyroscopeName, sc::kVendor, sc::kVersion, sc::kGyroscopeHandle,
- SENSOR_TYPE_GYROSCOPE, sc::kGyroscopeMaxRange, sc::kGyroscopeResolution,
- sc::kGyroscopePower, sc::kGyroscopeMinDelay, sc::kFifoReservedEventCount,
- sc::kFifoMaxEventCount, sc::kGyroscopeStringType, sc::kRequiredPermission,
- sc::kMaxDelay, flags);
-}
-
-SensorInfo LightSensor() {
- uint32_t flags = sc::kLightReportingMode |
- (sc::kLightIsWakeup ? SENSOR_FLAG_WAKE_UP : 0);
-
- return SensorInfo(sc::kLightName, sc::kVendor, sc::kVersion, sc::kLightHandle,
- SENSOR_TYPE_LIGHT, sc::kLightMaxRange, sc::kLightResolution,
- sc::kLightPower, sc::kLightMinDelay,
- sc::kFifoReservedEventCount, sc::kFifoMaxEventCount,
- sc::kLightStringType, sc::kRequiredPermission,
- sc::kMaxDelay, flags);
-}
-
-SensorInfo MagneticFieldSensor() {
- uint32_t flags = sc::kMagneticFieldReportingMode |
- (sc::kMagneticFieldIsWakeup ? SENSOR_FLAG_WAKE_UP : 0);
-
- return SensorInfo(sc::kMagneticFieldName, sc::kVendor, sc::kVersion,
- sc::kMagneticFieldHandle, SENSOR_TYPE_MAGNETIC_FIELD,
- sc::kMagneticFieldMaxRange, sc::kMagneticFieldResolution,
- sc::kMagneticFieldPower, sc::kMagneticFieldMinDelay,
- sc::kFifoReservedEventCount, sc::kFifoMaxEventCount,
- sc::kMagneticFieldStringType, sc::kRequiredPermission,
- sc::kMaxDelay, flags);
-}
-
-SensorInfo PressureSensor() {
- uint32_t flags = sc::kPressureReportingMode |
- (sc::kPressureIsWakeup ? SENSOR_FLAG_WAKE_UP : 0);
-
- return SensorInfo(
- sc::kPressureName, sc::kVendor, sc::kVersion, sc::kPressureHandle,
- SENSOR_TYPE_PRESSURE, sc::kPressureMaxRange, sc::kPressureResolution,
- sc::kPressurePower, sc::kPressureMinDelay, sc::kFifoReservedEventCount,
- sc::kFifoMaxEventCount, sc::kPressureStringType, sc::kRequiredPermission,
- sc::kMaxDelay, flags);
-}
-
-SensorInfo ProximitySensor() {
- uint32_t flags = sc::kProximityReportingMode |
- (sc::kProximityIsWakeup ? SENSOR_FLAG_WAKE_UP : 0);
-
- return SensorInfo(
- sc::kProximityName, sc::kVendor, sc::kVersion, sc::kProximityHandle,
- SENSOR_TYPE_PROXIMITY, sc::kProximityMaxRange, sc::kProximityResolution,
- sc::kProximityPower, sc::kProximityMinDelay, sc::kFifoReservedEventCount,
- sc::kFifoMaxEventCount, sc::kProximityStringType, sc::kRequiredPermission,
- sc::kMaxDelay, flags);
-}
-
-SensorInfo AmbientTempSensor() {
- uint32_t flags = sc::kAmbientTempReportingMode |
- (sc::kAmbientTempIsWakeup ? SENSOR_FLAG_WAKE_UP : 0);
-
- return SensorInfo(sc::kAmbientTempName, sc::kVendor, sc::kVersion,
- sc::kAmbientTempHandle, SENSOR_TYPE_AMBIENT_TEMPERATURE,
- sc::kAmbientTempMaxRange, sc::kAmbientTempResolution,
- sc::kAmbientTempPower, sc::kAmbientTempMinDelay,
- sc::kFifoReservedEventCount, sc::kFifoMaxEventCount,
- sc::kAmbientTempStringType, sc::kRequiredPermission,
- sc::kMaxDelay, flags);
-}
-
-SensorInfo DeviceTempSensor() {
- uint32_t flags = sc::kDeviceTempReportingMode |
- (sc::kDeviceTempIsWakeup ? SENSOR_FLAG_WAKE_UP : 0);
-
- return SensorInfo(sc::kDeviceTempName, sc::kVendor, sc::kVersion,
- sc::kDeviceTempHandle, SENSOR_TYPE_TEMPERATURE,
- sc::kDeviceTempMaxRange, sc::kDeviceTempResolution,
- sc::kDeviceTempPower, sc::kDeviceTempMinDelay,
- sc::kFifoReservedEventCount, sc::kFifoMaxEventCount,
- sc::kDeviceTempStringType, sc::kRequiredPermission,
- sc::kMaxDelay, flags);
-}
-
-SensorInfo RelativeHumiditySensor() {
- uint32_t flags = sc::kRelativeHumidityReportingMode |
- (sc::kRelativeHumidityIsWakeup ? SENSOR_FLAG_WAKE_UP : 0);
-
- return SensorInfo(sc::kRelativeHumidityName, sc::kVendor, sc::kVersion,
- sc::kRelativeHumidityHandle, SENSOR_TYPE_RELATIVE_HUMIDITY,
- sc::kRelativeHumidityMaxRange,
- sc::kRelativeHumidityResolution, sc::kRelativeHumidityPower,
- sc::kRelativeHumidityMinDelay, sc::kFifoReservedEventCount,
- sc::kFifoMaxEventCount, sc::kRelativeHumidityStringType,
- sc::kRequiredPermission, sc::kMaxDelay,
- flags);
-}
-
-} // namespace cvd
diff --git a/guest/hals/sensors/sensors.h b/guest/hals/sensors/sensors.h
deleted file mode 100644
index 9543e4e1..00000000
--- a/guest/hals/sensors/sensors.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * 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.
- */
-#pragma once
-
-#include "common/libs/time/monotonic_time.h"
-#include "guest/hals/sensors/sensors_hal.h"
-
-namespace cvd {
-
-// Stores static information about a sensor.
-// Must be completely compatible with sensor_t (i.e. no additional
-// information or virtual functions)
-// so we can cast a list of SensorInfo to a list of sensor_t.
-class SensorInfo : public sensor_t {
- public:
- // Dummy, empty set of sensor information (value-initialized).
- SensorInfo() : sensor_t() {}
-
- private:
- SensorInfo(const char* name, const char* vendor, int version, int handle,
- int type, float max_range, float resolution, float power,
- int32_t min_delay, uint32_t fifo_reserved_event_count,
- uint32_t fifo_max_event_count, const char* string_type,
- const char* required_permission, int32_t max_delay,
- uint32_t reporting_mode);
-
- friend SensorInfo AccelerometerSensor();
- friend SensorInfo GyroscopeSensor();
- friend SensorInfo LightSensor();
- friend SensorInfo MagneticFieldSensor();
- friend SensorInfo PressureSensor();
- friend SensorInfo ProximitySensor();
- friend SensorInfo AmbientTempSensor();
- friend SensorInfo DeviceTempSensor();
- friend SensorInfo RelativeHumiditySensor();
-};
-
-SensorInfo AccelerometerSensor();
-SensorInfo GyroscopeSensor();
-SensorInfo LightSensor();
-SensorInfo MagneticFieldSensor();
-SensorInfo PressureSensor();
-SensorInfo ProximitySensor();
-SensorInfo AmbientTempSensor();
-SensorInfo DeviceTempSensor();
-SensorInfo RelativeHumiditySensor();
-
-// Stores the current state of a sensor.
-class SensorState {
- public:
- SensorState(SensorInfo info);
- virtual ~SensorState() {}
-
- // What this sensor is activated or not.
- bool enabled_;
- // Buffer of incoming events.
- sensors_event_t event_;
- // The deadline at which we should report the next sensor event
- // to the framework in order to meet our frequency constraints.
- // For disabled sensors, should be 'infinity'.
- cvd::time::MonotonicTimePoint deadline_;
- // Delay time between consecutive sensor samples, in ns.
- cvd::time::Nanoseconds sampling_period_;
-
- // Time 'infinity'.
- static const cvd::time::MonotonicTimePoint kInfinity;
-};
-
-namespace sensors_constants {
-// TODO: Verify these numbers.
-// Vendor of the hardware part.
-const char kVendor[] = "Google";
-// Version of the hardware part + driver. The value of this field
-// must increase when the driver is updated in a way that
-// changes the output of the sensor.
-const int kVersion = VSOC_SENSOR_DEVICE_VERSION;
-// Number of events reserved for this sensor in batch mode FIFO.
-// If it has its own FIFO, the size of that FIFO.
-const uint32_t kFifoReservedEventCount = 15;
-// Maximum events that can be batched. In a shared FIFO,
-// the size of that FIFO.
-const uint32_t kFifoMaxEventCount = 15;
-// Permission required to use this sensor, or empty string
-// if none required.
-const char kRequiredPermission[] = "";
-// Defined only for continuous mode and on-change sensors.
-// Delay corresponding with lowest frequency supported.
-const int32_t kMaxDelay = 5000000;
-
-// Name of this sensor. Must be unique.
-const char kAccelerometerName[] = "acceleration";
-const char kGyroscopeName[] = "gyroscope";
-const char kLightName[] = "light";
-const char kMagneticFieldName[] = "magnetic_field";
-const char kPressureName[] = "pressure";
-const char kProximityName[] = "proximity";
-const char kAmbientTempName[] = "ambient_temp";
-const char kDeviceTempName[] = "device_temp";
-const char kRelativeHumidityName[] = "relative_humidity";
-
-// Handle that identifies the sensor. This is used as an array index,
-// so must be unique in the range [0, # sensors)
-
-const int kAccelerometerHandle = 0;
-const int kGyroscopeHandle = 1;
-const int kLightHandle = 2;
-const int kMagneticFieldHandle = 3;
-const int kPressureHandle = 4;
-const int kProximityHandle = 5;
-const int kAmbientTempHandle = 6;
-const int kDeviceTempHandle = 7;
-const int kRelativeHumidityHandle = 8;
-
-// For continuous sensors, minimum sample period (in microseconds).
-// On-Change (0), One-shot (-1), and special (0).
-const int32_t kAccelerometerMinDelay = 4444;
-const int32_t kGyroscopeMinDelay = 4444;
-const int32_t kLightMinDelay = 0;
-const int32_t kMagneticFieldMinDelay = 14285;
-const int32_t kPressureMinDelay = 28571;
-const int32_t kProximityMinDelay = 0;
-const int32_t kAmbientTempMinDelay = 4444;
-const int32_t kDeviceTempMinDelay = 4444;
-const int32_t kRelativeHumidityMinDelay = 4444;
-
-// Maximum range of this sensor's value in SI units.
-const float kAccelerometerMaxRange = 39.226593f;
-const float kGyroscopeMaxRange = 8.726639f;
-const float kLightMaxRange = 10000.0f;
-const float kMagneticFieldMaxRange = 4911.9995f;
-const float kPressureMaxRange = 1100.0f;
-const float kProximityMaxRange = 5.0f;
-const float kAmbientTempMaxRange = 80.0f;
-const float kDeviceTempMaxRange = 80.0f;
-const float kRelativeHumidityMaxRange = 100;
-
-// Smallest difference between two values reported by this sensor.
-const float kAccelerometerResolution = 0.45f;
-const float kGyroscopeResolution = 10.0f;
-const float kLightResolution = 10.0f;
-const float kMagneticFieldResolution = 1.0f;
-const float kPressureResolution = 1.0f;
-const float kProximityResolution = 1.0f;
-const float kAmbientTempResolution = 1.0f;
-const float kDeviceTempResolution = 1.0f;
-const float kRelativeHumidityResolution = 1.0f;
-
-// Rough estimate of this sensor's power consumption in mA.
-const float kAccelerometerPower = 0.45f;
-const float kGyroscopePower = 3.6f;
-const float kLightPower = 0.175f;
-const float kMagneticFieldPower = 5.0f;
-const float kPressurePower = 0.004f;
-const float kProximityPower = 12.675f;
-const float kAmbientTempPower = 1.0f;
-const float kDeviceTempPower = 1.0f;
-const float kRelativeHumidityPower = 1.0f;
-
-// Type of this sensor, represented as a string.
-
-const char kAccelerometerStringType[] = SENSOR_STRING_TYPE_ACCELEROMETER;
-const char kGyroscopeStringType[] = SENSOR_STRING_TYPE_GYROSCOPE;
-const char kLightStringType[] = SENSOR_STRING_TYPE_LIGHT;
-const char kMagneticFieldStringType[] = SENSOR_STRING_TYPE_MAGNETIC_FIELD;
-const char kPressureStringType[] = SENSOR_STRING_TYPE_PRESSURE;
-const char kProximityStringType[] = SENSOR_STRING_TYPE_PROXIMITY;
-const char kAmbientTempStringType[] = SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE;
-const char kDeviceTempStringType[] = SENSOR_STRING_TYPE_TEMPERATURE;
-const char kRelativeHumidityStringType[] = SENSOR_STRING_TYPE_RELATIVE_HUMIDITY;
-
-const uint32_t kAccelerometerReportingMode = SENSOR_FLAG_CONTINUOUS_MODE;
-const uint32_t kGyroscopeReportingMode = SENSOR_FLAG_CONTINUOUS_MODE;
-const uint32_t kLightReportingMode = SENSOR_FLAG_ON_CHANGE_MODE;
-const uint32_t kMagneticFieldReportingMode = SENSOR_FLAG_CONTINUOUS_MODE;
-const uint32_t kPressureReportingMode = SENSOR_FLAG_CONTINUOUS_MODE;
-const uint32_t kProximityReportingMode = SENSOR_FLAG_ON_CHANGE_MODE;
-const uint32_t kAmbientTempReportingMode = SENSOR_FLAG_ON_CHANGE_MODE;
-const uint32_t kDeviceTempReportingMode = SENSOR_FLAG_ON_CHANGE_MODE;
-const uint32_t kRelativeHumidityReportingMode = SENSOR_FLAG_ON_CHANGE_MODE;
-
-const bool kAccelerometerIsWakeup = false;
-const bool kGyroscopeIsWakeup = false;
-const bool kLightIsWakeup = false;
-const bool kMagneticFieldIsWakeup = false;
-const bool kPressureIsWakeup = false;
-const bool kProximityIsWakeup = true;
-const bool kAmbientTempIsWakeup = false;
-const bool kDeviceTempIsWakeup = false;
-const bool kRelativeHumidityIsWakeup = false;
-
-} // namespace sensors_constants
-} // namespace cvd
-
diff --git a/guest/hals/sensors/sensors_hal.cpp b/guest/hals/sensors/sensors_hal.cpp
deleted file mode 100644
index c1e2284c..00000000
--- a/guest/hals/sensors/sensors_hal.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 "guest/hals/sensors/sensors_hal.h"
-
-#include "guest/hals/sensors/vsoc_sensors.h"
-
-static hw_module_methods_t hal_module_methods = {
- .open = cvd::GceSensors::Open,
-};
-
-sensors_module_t HAL_MODULE_INFO_SYM = {
- .common = {
- .tag = HARDWARE_MODULE_TAG,
- .module_api_version = 1,
- .hal_api_version = 0,
- .id = SENSORS_HARDWARE_MODULE_ID,
- .name = "Android-GCE SENSORS Module",
- .author = "Google",
- .methods = & hal_module_methods,
- },
- .get_sensors_list = cvd::GceSensors::GetSensorsList,
- .set_operation_mode = cvd::GceSensors::SetOperationMode,
-};
diff --git a/guest/hals/sensors/sensors_hal.h b/guest/hals/sensors/sensors_hal.h
deleted file mode 100644
index 263bf09f..00000000
--- a/guest/hals/sensors/sensors_hal.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-#pragma once
-
-#include <log/log.h>
-#include <hardware/hardware.h>
-#include <hardware/sensors.h>
-
-#define VSOC_SENSOR_DEVICE_VERSION SENSORS_DEVICE_API_VERSION_1_4
-
-#define SENSORS_DEBUG 0
-
-#if SENSORS_DEBUG
-# define D(...) ALOGD(__VA_ARGS__)
-#else
-# define D(...) ((void)0)
-#endif
-
diff --git a/guest/hals/sensors/vsoc_sensors.cpp b/guest/hals/sensors/vsoc_sensors.cpp
deleted file mode 100644
index c9388b00..00000000
--- a/guest/hals/sensors/vsoc_sensors.cpp
+++ /dev/null
@@ -1,509 +0,0 @@
-/*
- * 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 <cstdint>
-
-#include <cutils/properties.h>
-#include <cutils/sockets.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/system_properties.h>
-#include <unistd.h>
-
-#include <algorithm>
-
-#include "common/libs/fs/shared_select.h"
-#include "common/libs/threads/thunkers.h"
-#include "guest/hals/sensors/sensors_hal.h"
-#include "guest/hals/sensors/vsoc_sensors.h"
-#include "guest/hals/sensors/vsoc_sensors_message.h"
-#include "guest/libs/remoter/remoter_framework_pkt.h"
-
-using cvd::LockGuard;
-using cvd::Mutex;
-using cvd::time::Milliseconds;
-using cvd::time::MonotonicTimePoint;
-using cvd::time::Nanoseconds;
-
-namespace cvd {
-
-int GceSensors::total_sensor_count_ = -1;
-SensorInfo* GceSensors::sensor_infos_ = NULL;
-const int GceSensors::kInjectedEventWaitPeriods = 3;
-const Nanoseconds GceSensors::kInjectedEventWaitTime =
- Nanoseconds(Milliseconds(20));
-
-GceSensors::GceSensors()
- : sensors_poll_device_1(), deadline_change_(&sensor_state_lock_) {
- if (total_sensor_count_ == -1) {
- RegisterSensors();
- }
-
- // Create a pair of FDs that would be used to control the
- // receiver thread.
- if (control_sender_socket_->IsOpen() || control_receiver_socket_->IsOpen()) {
- ALOGE("%s: Receiver control FDs are opened", __FUNCTION__);
- }
- if (!cvd::SharedFD::Pipe(&control_receiver_socket_,
- &control_sender_socket_)) {
- ALOGE("%s: Unable to create thread control FDs: %d -> %s", __FUNCTION__,
- errno, strerror(errno));
- }
-
- // Create the correct number of holding buffers for this client.
- sensor_states_.resize(total_sensor_count_);
- int i;
- for (i = 0; i < total_sensor_count_; i++) {
- sensor_states_[i] = new SensorState(sensor_infos_[i]);
- }
-}
-
-GceSensors::~GceSensors() {
- int i;
- for (i = 0; i < total_sensor_count_; i++) {
- delete sensor_states_[i];
- }
-}
-
-int GceSensors::GetSensorsList(struct sensors_module_t* /*module*/,
- struct sensor_t const** list) {
- *list = sensor_infos_;
- return total_sensor_count_;
-}
-
-int GceSensors::SetOperationMode(unsigned int /* is_loopback_mode */) {
- return -EINVAL;
-}
-
-int GceSensors::Open(const struct hw_module_t* module, const char* name,
- struct hw_device_t** device) {
- int status = -EINVAL;
-
- if (!strcmp(name, SENSORS_HARDWARE_POLL)) {
- // Create a new GceSensors object and set all the fields/functions
- // to their default values.
- GceSensors* rval = new GceSensors;
-
- rval->common.tag = HARDWARE_DEVICE_TAG;
- rval->common.version = VSOC_SENSOR_DEVICE_VERSION;
- rval->common.module = (struct hw_module_t*)module;
- rval->common.close = cvd::thunk<hw_device_t, &GceSensors::Close>;
-
- rval->poll = cvd::thunk<sensors_poll_device_t, &GceSensors::Poll>;
- rval->activate = cvd::thunk<sensors_poll_device_t, &GceSensors::Activate>;
- rval->setDelay = cvd::thunk<sensors_poll_device_t, &GceSensors::SetDelay>;
-
- rval->batch = cvd::thunk<sensors_poll_device_1, &GceSensors::Batch>;
- rval->flush = cvd::thunk<sensors_poll_device_1, &GceSensors::Flush>;
- rval->inject_sensor_data =
- cvd::thunk<sensors_poll_device_1, &GceSensors::InjectSensorData>;
-
- // Spawn a thread to listen for incoming data from the remoter.
- int err = pthread_create(
- &rval->receiver_thread_, NULL,
- cvd::thunk<void, &GceSensors::Receiver>,
- rval);
- if (err) {
- ALOGE("GceSensors::%s: Unable to start receiver thread (%s)",
- __FUNCTION__, strerror(err));
- }
-
- *device = &rval->common;
- status = 0;
- }
- return status;
-}
-
-int GceSensors::Close() {
- // Make certain the receiver thread wakes up.
- SensorControlMessage msg;
- msg.message_type = THREAD_STOP;
- SendControlMessage(msg);
- pthread_join(receiver_thread_, NULL);
- delete this;
- return 0;
-}
-
-int GceSensors::Activate(int handle, int enabled) {
- if (handle < 0 || handle >= total_sensor_count_) {
- ALOGE("GceSensors::%s: Bad handle %d", __FUNCTION__, handle);
- return -1;
- }
-
- {
- LockGuard<Mutex> guard(sensor_state_lock_);
- // Update the report deadline, if changed.
- if (enabled && !sensor_states_[handle]->enabled_) {
- sensor_states_[handle]->deadline_ =
- MonotonicTimePoint::Now() + sensor_states_[handle]->sampling_period_;
- } else if (!enabled && sensor_states_[handle]->enabled_) {
- sensor_states_[handle]->deadline_ = SensorState::kInfinity;
- }
- sensor_states_[handle]->enabled_ = enabled;
- UpdateDeadline();
- }
-
- D("sensor_activate(): handle %d, enabled %d", handle, enabled);
- if (!UpdateRemoterState(handle)) {
- ALOGE("Failed to notify remoter about new sensor enable/disable.");
- }
- return 0;
-}
-
-int GceSensors::SetDelay(int handle, int64_t sampling_period_ns) {
- if (handle < 0 || handle >= total_sensor_count_) {
- ALOGE("GceSensors::%s: Bad handle %d", __FUNCTION__, handle);
- return -1;
- }
- int64_t min_delay_ns = sensor_infos_[handle].minDelay * 1000;
- if (sampling_period_ns < min_delay_ns) {
- sampling_period_ns = min_delay_ns;
- }
-
- {
- LockGuard<Mutex> guard(sensor_state_lock_);
- sensor_states_[handle]->deadline_ -=
- sensor_states_[handle]->sampling_period_;
- sensor_states_[handle]->sampling_period_ = Nanoseconds(sampling_period_ns);
- sensor_states_[handle]->deadline_ +=
- sensor_states_[handle]->sampling_period_;
- // If our sampling period has decreased, our deadline
- // could have already passed. If so, report immediately, but not in the
- // past.
- MonotonicTimePoint now = MonotonicTimePoint::Now();
- if (sensor_states_[handle]->deadline_ < now) {
- sensor_states_[handle]->deadline_ = now;
- }
- UpdateDeadline();
- }
-
- D("sensor_set_delay(): handle %d, delay (ms) %" PRId64, handle,
- Milliseconds(Nanoseconds(sampling_period_ns)).count());
- if (!UpdateRemoterState(handle)) {
- ALOGE("Failed to notify remoter about new sensor delay.");
- }
- return 0;
-}
-
-int GceSensors::Poll(sensors_event_t* data, int count_unsafe) {
- if (count_unsafe <= 0) {
- ALOGE("Framework polled with bad count (%d)", count_unsafe);
- return -1;
- }
- size_t count = size_t(count_unsafe);
-
- // Poll will block until 1 of 2 things happens:
- // 1. The next deadline for some active sensor
- // occurs.
- // 2. The next deadline changes (either because
- // a sensor was activated/deactivated or its
- // delay changed).
- // In both cases, any sensors whose report deadlines
- // have passed will report their data (or mock data),
- // and poll will either return (if at least one deadline
- // has passed), or repeat by blocking until the next deadline.
- LockGuard<Mutex> guard(sensor_state_lock_);
- current_deadline_ = UpdateDeadline();
- // Sleep until we have something to report
- while (!fifo_.size()) {
- deadline_change_.WaitUntil(current_deadline_);
- current_deadline_ = UpdateDeadline();
- }
- // Copy the events from the buffer
- int num_copied = std::min(fifo_.size(), count);
- FifoType::iterator first_uncopied = fifo_.begin() + num_copied;
- std::copy(fifo_.begin(), first_uncopied, data);
- fifo_.erase(fifo_.begin(), first_uncopied);
- D("Reported %d sensor events. First: %d %f %f %f", num_copied, data->sensor,
- data->data[0], data->data[1], data->data[2]);
- return num_copied;
-}
-
-
-void *GceSensors::Receiver() {
- // Initialize the server.
- sensor_listener_socket_ = cvd::SharedFD::SocketSeqPacketServer(
- gce_sensors_message::kSensorsHALSocketName, 0777);
- if (!sensor_listener_socket_->IsOpen()) {
- ALOGE("GceSensors::%s: Could not listen for sensor connections. (%s).",
- __FUNCTION__, sensor_listener_socket_->StrError());
- return NULL;
- }
- D("GceSensors::%s: Listening for sensor connections at %s", __FUNCTION__,
- gce_sensors_message::kSensorsHALSocketName);
- // Announce that we are ready for the remoter to connect.
- if (!NotifyRemoter()) {
- ALOGI("Failed to notify remoter that HAL is ready.");
- } else {
- ALOGI("Notified remoter that HAL is ready.");
- }
-
- typedef std::vector<cvd::SharedFD> FDVec;
- FDVec connected;
- // Listen for incoming sensor data and control messages
- // from the HAL.
- while (true) {
- cvd::SharedFDSet fds;
- for (FDVec::iterator it = connected.begin(); it != connected.end(); ++it) {
- fds.Set(*it);
- }
- fds.Set(control_receiver_socket_);
- // fds.Set(sensor_listener_socket_);
- int res = cvd::Select(&fds, NULL, NULL, NULL);
- if (res == -1) {
- ALOGE("%s: select returned %d and failed %d -> %s", __FUNCTION__, res,
- errno, strerror(errno));
- break;
- } else if (res == 0) {
- ALOGE("%s: select timed out", __FUNCTION__);
- break;
- } else if (fds.IsSet(sensor_listener_socket_)) {
- connected.push_back(cvd::SharedFD::Accept(*sensor_listener_socket_));
- ALOGI("GceSensors::%s: new client connected", __FUNCTION__);
- } else if (fds.IsSet(control_receiver_socket_)) {
- // We received a control message.
- SensorControlMessage msg;
- int res =
- control_receiver_socket_->Read(&msg, sizeof(SensorControlMessage));
- if (res == -1) {
- ALOGE("GceSensors::%s: Failed to receive control message.",
- __FUNCTION__);
- } else if (res == 0) {
- ALOGE("GceSensors::%s: Control connection closed.", __FUNCTION__);
- }
- if (msg.message_type == SENSOR_STATE_UPDATE) {
- // Forward the update to the remoter.
- remoter_request_packet packet;
- remoter_request_packet_init(&packet, kRemoterSensorState, 0);
- {
- LockGuard<Mutex> guard(sensor_state_lock_);
- packet.params.sensor_state_params.type =
- sensor_infos_[msg.sensor_handle].type;
- packet.params.sensor_state_params.enabled =
- sensor_states_[msg.sensor_handle]->enabled_;
- packet.params.sensor_state_params.delay_ns =
- sensor_states_[msg.sensor_handle]->sampling_period_.count();
- packet.params.sensor_state_params.handle = msg.sensor_handle;
- }
- struct msghdr msg;
- iovec msg_iov[1];
- msg_iov[0].iov_base = &packet;
- msg_iov[0].iov_len = sizeof(remoter_request_packet);
- msg.msg_name = NULL;
- msg.msg_namelen = 0;
- msg.msg_iov = msg_iov;
- msg.msg_iovlen = arraysize(msg_iov);
- msg.msg_control = NULL;
- msg.msg_controllen = 0;
- msg.msg_flags = 0;
-
- for (FDVec::iterator it = connected.begin(); it != connected.end();
- ++it) {
- cvd::SharedFD &fd = *it;
- if (fd->SendMsg(&msg, 0) == -1) {
- ALOGE("GceSensors::%s. Could not send sensor state (%s).",
- __FUNCTION__, fd->StrError());
- }
- }
- }
- if (msg.message_type == THREAD_STOP) {
- D("Received terminate control message.");
- return NULL;
- }
- } else {
- for (FDVec::iterator it = connected.begin(); it != connected.end();
- ++it) {
- cvd::SharedFD &fd = *it;
- if (fds.IsSet(fd)) {
- // We received a sensor update from remoter.
- sensors_event_t event;
- struct msghdr msg;
- iovec msg_iov[1];
- msg_iov[0].iov_base = &event;
- msg_iov[0].iov_len = sizeof(event);
- msg.msg_name = NULL;
- msg.msg_namelen = 0;
- msg.msg_iov = msg_iov;
- msg.msg_iovlen = arraysize(msg_iov);
- msg.msg_control = NULL;
- msg.msg_controllen = 0;
- msg.msg_flags = 0;
- int res = fd->RecvMsg(&msg, 0);
- if (res <= 0) {
- if (res == 0) {
- ALOGE("GceSensors::%s: Sensors HAL connection closed.",
- __FUNCTION__);
- } else {
- ALOGE("GceSensors::%s: Failed to receive sensor message",
- __FUNCTION__);
- }
- connected.erase(std::find(connected.begin(), connected.end(), fd));
- break;
- }
-
- // We received an event from the remoter.
- if (event.sensor < 0 || event.sensor >= total_sensor_count_) {
- ALOGE("Remoter sent us an invalid sensor event! (handle %d)",
- event.sensor);
- connected.erase(std::find(connected.begin(), connected.end(), fd));
- break;
- }
-
- D("Received sensor event: %d %f %f %f", event.sensor, event.data[0],
- event.data[1], event.data[2]);
-
- {
- LockGuard<Mutex> guard(sensor_state_lock_);
- // Increase the delay so that the HAL knows
- // it shouldn't report on its own for a while.
- SensorState *holding_buffer = sensor_states_[event.sensor];
- int wait_periods =
- std::max(kInjectedEventWaitPeriods,
- (int)(kInjectedEventWaitTime.count() /
- holding_buffer->sampling_period_.count()));
- holding_buffer->deadline_ =
- MonotonicTimePoint::Now() +
- holding_buffer->sampling_period_ * wait_periods;
- holding_buffer->event_.data[0] = event.data[0];
- holding_buffer->event_.data[1] = event.data[1];
- holding_buffer->event_.data[2] = event.data[2];
- // Signal the HAL to report the newly arrived event.
- fifo_.push_back(event);
- deadline_change_.NotifyOne();
- }
- }
- }
- }
- }
- return NULL;
-}
-
-bool GceSensors::NotifyRemoter() {
- remoter_request_packet packet;
- remoter_request_packet_init(&packet, kRemoterHALReady, 0);
- packet.send_response = 0;
- strncpy(packet.params.hal_ready_params.unix_socket,
- gce_sensors_message::kSensorsHALSocketName,
- sizeof(packet.params.hal_ready_params.unix_socket));
- AutoCloseFileDescriptor remoter_socket(remoter_connect());
- if (remoter_socket.IsError()) {
- D("GceSensors::%s: Could not connect to remoter to notify ready (%s).",
- __FUNCTION__, strerror(errno));
- return false;
- }
- int err =
- remoter_do_single_request_with_socket(remoter_socket, &packet, NULL);
- if (err == -1) {
- D("GceSensors::%s: Notify remoter ready: Failed after connect (%s).",
- __FUNCTION__, strerror(errno));
- return false;
- }
- D("GceSensors::%s: Notify remoter ready Succeeded.", __FUNCTION__);
- return true;
-}
-
-static bool CompareTimestamps(const sensors_event_t& a,
- const sensors_event_t& b) {
- return a.timestamp < b.timestamp;
-}
-
-MonotonicTimePoint GceSensors::UpdateDeadline() {
- // Get the minimum of all the current deadlines.
- MonotonicTimePoint now = MonotonicTimePoint::Now();
- MonotonicTimePoint min = SensorState::kInfinity;
- int i = 0;
- bool sort_fifo = false;
-
- for (i = 0; i < total_sensor_count_; i++) {
- SensorState* holding_buffer = sensor_states_[i];
- // Ignore disabled sensors.
- if (!holding_buffer->enabled_) {
- continue;
- }
- while (holding_buffer->deadline_ < now) {
- sensors_event_t data = holding_buffer->event_;
- data.timestamp = holding_buffer->deadline_.SinceEpoch().count();
- fifo_.push_back(data);
- holding_buffer->deadline_ += holding_buffer->sampling_period_;
- sort_fifo = true;
- }
- // Now check if we should update the wake time based on the next event
- // from this sensor.
- if (sensor_states_[i]->deadline_ < min) {
- min = sensor_states_[i]->deadline_;
- }
- }
- // We added one or more sensor readings, so do a sort.
- // This is likely to be cheaper than a traditional priority queue because
- // a priority queue would try to keep its state correct for each addition.
- if (sort_fifo) {
- std::sort(fifo_.begin(), fifo_.end(), CompareTimestamps);
- }
- // If we added events or the deadline is lower notify the thread in Poll().
- // If the deadline went up, don't do anything.
- if (fifo_.size() || (min < current_deadline_)) {
- deadline_change_.NotifyOne();
- }
- return min;
-}
-
-bool GceSensors::UpdateRemoterState(int handle) {
- SensorControlMessage msg;
- msg.message_type = SENSOR_STATE_UPDATE;
- msg.sensor_handle = handle;
- return SendControlMessage(msg);
-}
-
-bool GceSensors::SendControlMessage(SensorControlMessage msg) {
- if (!control_sender_socket_->IsOpen()) {
- ALOGE("%s: Can't send control message %d, control socket not open.",
- __FUNCTION__, msg.message_type);
- return false;
- }
- if (control_sender_socket_->Write(&msg, sizeof(SensorControlMessage)) == -1) {
- ALOGE("GceSensors::%s. Could not send control message %d (%s).",
- __FUNCTION__, msg.message_type, control_sender_socket_->StrError());
- return false;
- }
- return true;
-}
-
-int GceSensors::RegisterSensors() {
- if (total_sensor_count_ != -1) {
- return -1;
- }
- total_sensor_count_ = 9;
- sensor_infos_ = new SensorInfo[total_sensor_count_];
- sensor_infos_[sensors_constants::kAccelerometerHandle] =
- AccelerometerSensor();
- sensor_infos_[sensors_constants::kGyroscopeHandle] = GyroscopeSensor();
- sensor_infos_[sensors_constants::kLightHandle] = LightSensor();
- sensor_infos_[sensors_constants::kMagneticFieldHandle] =
- MagneticFieldSensor();
- sensor_infos_[sensors_constants::kPressureHandle] = PressureSensor();
- sensor_infos_[sensors_constants::kProximityHandle] = ProximitySensor();
- sensor_infos_[sensors_constants::kAmbientTempHandle] = AmbientTempSensor();
- sensor_infos_[sensors_constants::kDeviceTempHandle] = DeviceTempSensor();
- sensor_infos_[sensors_constants::kRelativeHumidityHandle] =
- RelativeHumiditySensor();
- int i;
- for (i = 0; i < total_sensor_count_; i++) {
- D("Found sensor %s with handle %d", sensor_infos_[i].name,
- sensor_infos_[i].handle);
- }
- return total_sensor_count_;
-}
-
-} // namespace cvd
diff --git a/guest/hals/sensors/vsoc_sensors.h b/guest/hals/sensors/vsoc_sensors.h
deleted file mode 100644
index c4e97183..00000000
--- a/guest/hals/sensors/vsoc_sensors.h
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * 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.
- */
-#pragma once
-
-#include <vector>
-
-#include "common/libs/threads/cuttlefish_thread.h"
-#include "common/libs/fs/shared_fd.h"
-#include "guest/hals/sensors/sensors.h"
-#include "guest/hals/sensors/sensors_hal.h"
-
-namespace cvd {
-
-// Used for sending control messages to the receiver thread.
-// The sensor_handle field may be left unused if it is not needed.
-enum ControlMessageType {
- THREAD_STOP,
- SENSOR_STATE_UPDATE
-};
-typedef struct {
- ControlMessageType message_type;
- uint8_t sensor_handle;
-} SensorControlMessage;
-
-// Last updated to HAL 1.4
-// Version history:
-// Before jb, jb-mr1 SENSORS_DEVICE_API_VERSION_0_1 (no version in sensors.h)
-// jb-mr2: SENSORS_DEVICE_API_VERSION_1_0
-// k: SENSORS_DEVICE_API_VERSION_1_1
-// l, l-mr1: SENSORS_DEVICE_API_VERSION_1_3
-// m, n, n-mr1: SENSORS_DEVICE_API_VERSION_1_4
-
-class GceSensors : public sensors_poll_device_1 {
- public:
- GceSensors();
- ~GceSensors();
-
- /**
- ** SENSOR HAL API FUNCTIONS FOR MODULE
- **/
-
- // Gets a list of all supported sensors and stores in list.
- // Returns the number of supported sensors.
- static int GetSensorsList(struct sensors_module_t* module,
- struct sensor_t const** list);
-
- // Place the module in a specific mode. The following modes are defined
- //
- // 0 - Normal operation. Default state of the module.
- // 1 - Loopback mode. Data is injected for the supported
- // sensors by the sensor service in this mode.
- // @return 0 on success
- // -EINVAL if requested mode is not supported
- // -EPERM if operation is not allowed
- static int SetOperationMode(unsigned int mode);
-
-
- /**
- ** SENSOR HAL API FUNCTIONS FOR DEVICE
- **/
- // Opens the device.
- static int Open(const struct hw_module_t* module, const char* name,
- struct hw_device_t** device);
-
- // Closes the device, closing all sensors.
- int Close();
-
- // Activate (or deactivate) the sensor with the given handle.
- //
- // One-shot sensors deactivate themselves automatically upon receiving an
- // event, and they must still accept to be deactivated through a call to
- // activate(..., enabled=0).
- // Non-wake-up sensors never prevent the SoC from going into suspend mode;
- // that is, the HAL shall not hold a partial wake-lock on behalf of
- // applications.
- //
- // If enabled is 1 and the sensor is already activated, this function is a
- // no-op and succeeds.
- //
- // If enabled is 0 and the sensor is already deactivated, this function is a
- // no-op and succeeds.
- //
- // This function returns 0 on success and a negative error number otherwise.
- int Activate(int handle, int enabled);
-
- // Sets the delay (in ns) for the sensor with the given handle.
- // Deprecated as of HAL 1.1
- // Called after activate()
- int SetDelay(int handle, int64_t sampling_period_ns);
-
- // Returns an array of sensor data by filling the data argument.
- // This function must block until events are available. It will return
- // the number of events read on success, or a negative number in case of
- // an error.
- int Poll(sensors_event_t* data, int count);
-
- // Sets a sensor’s parameters, including sampling frequency and maximum
- // report latency. This function can be called while the sensor is
- // activated, in which case it must not cause any sensor measurements to
- // be lost: transitioning from one sampling rate to the other cannot cause
- // lost events, nor can transitioning from a high maximum report latency to
- // a low maximum report latency.
- //
- // Before SENSORS_DEVICE_API_VERSION_1_3, flags included:
- // SENSORS_BATCH_DRY_RUN
- // SENSORS_BATCH_WAKE_UPON_FIFO_FULL
- //
- // After SENSORS_DEVICE_API_VERSION_1_3 see WAKE_UPON_FIFO_FULL
- // in sensor_t.flags
- int Batch(int sensor_handle, int flags, int64_t sampling_period_ns,
- int64_t max_report_latency_ns) {
- // TODO: Add support for maximum report latency with max_report_latency_ns.
- return SetDelay(sensor_handle, sampling_period_ns);
- }
-
- // Adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t)
- // to the end of the "batch mode" FIFO for the specified sensor and flushes
- // the FIFO.
- //
- // If the FIFO is empty or if the sensor doesn't support batching (FIFO
- // size zero), it should return SUCCESS along with a trivial
- // META_DATA_FLUSH_COMPLETE event added to the event stream. This applies to
- // all sensors other than one-shot sensors.
- //
- // If the sensor is a one-shot sensor, flush must return -EINVAL and not
- // generate any flush complete metadata.
- //
- // If the sensor is not active at the time flush() is called, flush() should
- // return -EINVAL.
- int Flush(int sensor_handle) {
- return -EINVAL;
- }
-
- // Inject a single sensor sample to be to this device.
- // data points to the sensor event to be injected
- // @return 0 on success
- // -EPERM if operation is not allowed
- // -EINVAL if sensor event cannot be injected
- int InjectSensorData(const sensors_event_t *data) {
- return -EINVAL;
- }
-
- private:
- typedef std::vector<SensorState*> SensorStateVector;
- typedef std::vector<sensors_event_t> FifoType;
- // Total number of sensors supported by this HAL.
- static int total_sensor_count_;
- // Vector of static sensor information for sensors supported by this HAL.
- // Indexed by the handle. Length must always be equal to total_sensor_count_.
- static SensorInfo* sensor_infos_;
- // Vector of sensor state information, indexed by the handle.
- // Assumption here is that the sensor handles will start at 0 and be
- // contiguous up to the number of supported sensors.
- SensorStateVector sensor_states_;
- // Keep track of the time when the thread in Poll() is scheduled to wake.
- cvd::time::MonotonicTimePoint current_deadline_;
-
- // Ordered set of sensor values.
- // TODO(ghartman): Simulate FIFO overflow.
- FifoType fifo_;
- // Thread to handle new connections.
- pthread_t receiver_thread_;
- // Socket to receive sensor events on.
- cvd::SharedFD sensor_listener_socket_;
- // Socket for listener thread to receive control messages.
- cvd::SharedFD control_receiver_socket_;
- // Socket to send control messages to listener thread.
- cvd::SharedFD control_sender_socket_;
-
- // Lock to protect shared state, including
- // sensor_states_ and next_deadline_.
- // Associated with deadline_change_ condition variable.
- cvd::Mutex sensor_state_lock_;
- // Condition variable to signal changes in the deadline.
- cvd::ConditionVariable deadline_change_;
-
- // When events are arriving from a client, we report only
- // when they arrive, rather than at a fixed cycle. After not
- // receiving a real event for both a given number of periods
- // and a given time period, we will give up and resume
- // sending mock events.
- const static int kInjectedEventWaitPeriods;
- const static cvd::time::Nanoseconds kInjectedEventWaitTime;
-
- /**
- ** UTILITY FUNCTIONS
- **/
-
- // Receive data from remoter.
- void* Receiver();
-
- // Notifies the remoter that the HAL is awake and ready.
- inline bool NotifyRemoter();
-
- // Looks through all active sensor deadlines, and finds the one that
- // is coming up next. If this is not next_deadline_, then the deadline
- // has changed. Update it and signal the Poll thread.
- // This should be called anytime the next deadline may have changed.
- // Can only be called while holding sensor_state_lock_.
- // Returns true if the deadline has changed.
- cvd::time::MonotonicTimePoint UpdateDeadline();
-
- // Sends an update for the sensor with the given handle to the remoter.
- // Update will be enqueued for receiver, not send immediately.
- inline bool UpdateRemoterState(int handle);
-
- // Sends a control event to the listener.
- inline bool SendControlMessage(SensorControlMessage msg);
-
- // Populates the list of static sensor info. Returns the number
- // of sensors supported. Should only be called once.
- static inline int RegisterSensors();
-
-};
-
-} //namespace cvd
-
diff --git a/guest/hals/sensors/vsoc_sensors_message.cpp b/guest/hals/sensors/vsoc_sensors_message.cpp
deleted file mode 100644
index 19987621..00000000
--- a/guest/hals/sensors/vsoc_sensors_message.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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 <stdlib.h>
-#include "guest/hals/sensors/vsoc_sensors_message.h"
-
-const char* gce_sensors_message::kSensorsHALSocketName =
- "/var/run/system/sensors_hal_socket";
diff --git a/guest/hals/sensors/vsoc_sensors_message.h b/guest/hals/sensors/vsoc_sensors_message.h
deleted file mode 100644
index 3a577002..00000000
--- a/guest/hals/sensors/vsoc_sensors_message.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.
- */
-#pragma once
-
-#include <hardware/hardware.h>
-#include <hardware/sensors.h>
-
-struct gce_sensors_message : sensors_event_t {
- static const char* kSensorsHALSocketName;
-};
-
diff --git a/guest/monitoring/tombstone_transmit/tombstone_transmit.cpp b/guest/monitoring/tombstone_transmit/tombstone_transmit.cpp
index 3633612c..8fc3586c 100644
--- a/guest/monitoring/tombstone_transmit/tombstone_transmit.cpp
+++ b/guest/monitoring/tombstone_transmit/tombstone_transmit.cpp
@@ -86,7 +86,6 @@ DEFINE_uint32(port, property_get_int32("ro.boot.vsock_tombstone_port", 0),
"VSOCK port to send tombstones to");
DEFINE_uint32(cid, 2, "VSOCK CID to send logcat output to");
#define TOMBSTONE_BUFFER_SIZE (1024)
-#define MAX_TOMBSTONE_SIZE (50 * TOMBSTONE_BUFFER_SIZE)
int main(int argc, char** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
@@ -114,8 +113,7 @@ int main(int argc, char** argv) {
char buffer[TOMBSTONE_BUFFER_SIZE];
uint num_transfers = 0;
int num_bytes_read = 0;
- while (log_fd->IsOpen() && ifs.is_open() && !ifs.eof() &&
- num_bytes_read < MAX_TOMBSTONE_SIZE) {
+ while (log_fd->IsOpen() && ifs.is_open() && !ifs.eof()) {
ifs.read(buffer, sizeof(buffer));
num_bytes_read += ifs.gcount();
log_fd->Write(buffer, ifs.gcount());
diff --git a/host/commands/assemble_cvd/Android.bp b/host/commands/assemble_cvd/Android.bp
index b03d8bfb..c5ac4c92 100644
--- a/host/commands/assemble_cvd/Android.bp
+++ b/host/commands/assemble_cvd/Android.bp
@@ -46,7 +46,6 @@ cc_binary_host {
"cdisk_spec",
"vsoc_lib",
"libcuttlefish_fs",
- "libcuttlefish_strings",
"libcuttlefish_utils",
"cuttlefish_auto_resources",
"libbase",
@@ -66,8 +65,7 @@ cc_binary_host {
defaults: ["cuttlefish_host_only", "cuttlefish_libicuuc"],
}
-cc_prebuilt_binary {
+sh_binary_host {
name: "cf_bpttool",
- srcs: ["cf_bpttool"],
- defaults: ["cuttlefish_host_only"],
+ src: "cf_bpttool",
}
diff --git a/host/commands/assemble_cvd/assemble_cvd.cc b/host/commands/assemble_cvd/assemble_cvd.cc
index 6eab814b..c8293956 100644
--- a/host/commands/assemble_cvd/assemble_cvd.cc
+++ b/host/commands/assemble_cvd/assemble_cvd.cc
@@ -15,11 +15,11 @@
#include <iostream>
+#include <android-base/strings.h>
#include <glog/logging.h>
#include "common/libs/fs/shared_buf.h"
#include "common/libs/fs/shared_fd.h"
-#include "common/libs/strings/str_split.h"
#include "host/commands/assemble_cvd/assembler_defs.h"
#include "host/commands/assemble_cvd/flags.h"
#include "host/libs/config/fetcher_config.h"
@@ -68,7 +68,7 @@ int main(int argc, char** argv) {
LOG(FATAL) << "Failed to read input files. Error was \"" << input_fd->StrError() << "\"";
}
}
- std::vector<std::string> input_files = cvd::StrSplit(input_files_str, '\n');
+ std::vector<std::string> input_files = android::base::Split(input_files_str, "\n");
auto config = InitFilesystemAndCreateConfig(&argc, &argv, FindFetcherConfig(input_files));
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index 54eefcc0..5ae5a916 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -3,10 +3,10 @@
#include <iostream>
#include <fstream>
+#include <android-base/strings.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
-#include "common/libs/strings/str_split.h"
#include "common/libs/utils/environment.h"
#include "common/libs/utils/files.h"
#include "common/vsoc/lib/vsoc_memory.h"
@@ -180,7 +180,6 @@ DEFINE_string(console_forwarder_binary,
vsoc::DefaultHostArtifactsPath("bin/console_forwarder"),
"The Console Forwarder binary to use");
DEFINE_bool(restart_subprocesses, true, "Restart any crashed host process");
-DEFINE_bool(run_e2e_test, true, "Run e2e test after device launches");
DEFINE_string(e2e_test_binary,
vsoc::DefaultHostArtifactsPath("bin/host_region_e2e_test"),
"Location of the region end to end test binary");
@@ -205,6 +204,10 @@ DEFINE_string(tombstone_receiver_binary,
"Binary for the tombstone server");
DEFINE_int32(tombstone_receiver_port, vsoc::GetPerInstanceDefault(5630),
"The vsock port for tombstones");
+DEFINE_int32(keyboard_server_port, GetPerInstanceDefault(5540),
+ "The port on which the vsock keyboard server should listen");
+DEFINE_int32(touch_server_port, GetPerInstanceDefault(5640),
+ "The port on which the vsock touch server should listen");
DEFINE_bool(use_bootloader, false, "Boots the device using a bootloader");
DEFINE_string(bootloader, "", "Bootloader binary path");
DEFINE_string(boot_slot, "", "Force booting into the given slot. If empty, "
@@ -214,7 +217,9 @@ DEFINE_string(boot_slot, "", "Force booting into the given slot. If empty, "
namespace {
-std::string kRamdiskConcatExt = ".concat";
+const std::string kKernelDefaultPath = "kernel";
+const std::string kInitramfsImg = "initramfs.img";
+const std::string kRamdiskConcatExt = ".concat";
template<typename S, typename T>
static std::string concat(const S& s, const T& t) {
@@ -273,7 +278,8 @@ int GetHostPort() {
// Initializes the config object and saves it to file. It doesn't return it, all
// further uses of the config should happen through the singleton
bool InitializeCuttlefishConfiguration(
- const cvd::BootImageUnpacker& boot_image_unpacker) {
+ const cvd::BootImageUnpacker& boot_image_unpacker,
+ const cvd::FetcherConfig& fetcher_config) {
vsoc::CuttlefishConfig tmp_config_obj;
auto& memory_layout = *vsoc::VSoCMemoryLayout::Get();
// Set this first so that calls to PerInstancePath below are correct
@@ -310,18 +316,20 @@ bool InitializeCuttlefishConfiguration(
tmp_config_obj.set_num_screen_buffers(FLAGS_num_screen_buffers);
tmp_config_obj.set_refresh_rate_hz(FLAGS_refresh_rate_hz);
tmp_config_obj.set_gdb_flag(FLAGS_qemu_gdb);
- std::vector<std::string> adb = cvd::StrSplit(FLAGS_adb_mode, ',');
+ std::vector<std::string> adb = android::base::Split(FLAGS_adb_mode, ",");
tmp_config_obj.set_adb_mode(std::set<std::string>(adb.begin(), adb.end()));
tmp_config_obj.set_host_port(GetHostPort());
tmp_config_obj.set_adb_ip_and_port("127.0.0.1:" + std::to_string(GetHostPort()));
tmp_config_obj.set_device_title(FLAGS_device_title);
- if (FLAGS_kernel_path.size()) {
- tmp_config_obj.set_kernel_image_path(FLAGS_kernel_path);
+ std::string discovered_kernel = fetcher_config.FindCvdFileWithSuffix(kKernelDefaultPath);
+ std::string foreign_kernel = FLAGS_kernel_path.size() ? FLAGS_kernel_path : discovered_kernel;
+ if (foreign_kernel.size()) {
+ tmp_config_obj.set_kernel_image_path(foreign_kernel);
tmp_config_obj.set_use_unpacked_kernel(false);
} else {
tmp_config_obj.set_kernel_image_path(
- tmp_config_obj.PerInstancePath("kernel"));
+ tmp_config_obj.PerInstancePath(kKernelDefaultPath.c_str()));
tmp_config_obj.set_use_unpacked_kernel(true);
}
tmp_config_obj.set_decompress_kernel(FLAGS_decompress_kernel);
@@ -394,9 +402,6 @@ bool InitializeCuttlefishConfiguration(
tmp_config_obj.add_kernel_cmdline("audit=0");
}
}
- if (FLAGS_run_e2e_test) {
- tmp_config_obj.add_kernel_cmdline("androidboot.vsoc_e2e_test=1");
- }
if (FLAGS_extra_kernel_cmdline.size()) {
tmp_config_obj.add_kernel_cmdline(FLAGS_extra_kernel_cmdline);
}
@@ -418,7 +423,9 @@ bool InitializeCuttlefishConfiguration(
// Boot as recovery is set so normal boot needs to be forced every boot
tmp_config_obj.add_kernel_cmdline("androidboot.force_normal_boot=1");
- if (FLAGS_kernel_path.size() && !FLAGS_initramfs_path.size()) {
+ std::string discovered_ramdisk = fetcher_config.FindCvdFileWithSuffix(kInitramfsImg);
+ std::string foreign_ramdisk = FLAGS_initramfs_path.size () ? FLAGS_initramfs_path : discovered_ramdisk;
+ if (foreign_kernel.size() && !foreign_ramdisk.size()) {
// If there's a kernel that's passed in without an initramfs, that implies
// user error or a kernel built with no modules. In either case, let's
// choose to avoid loading the modules from the vendor ramdisk which are
@@ -427,8 +434,8 @@ bool InitializeCuttlefishConfiguration(
tmp_config_obj.set_final_ramdisk_path(ramdisk_path);
} else {
tmp_config_obj.set_final_ramdisk_path(ramdisk_path + kRamdiskConcatExt);
- if(FLAGS_initramfs_path.size()) {
- tmp_config_obj.set_initramfs_path(FLAGS_initramfs_path);
+ if(foreign_ramdisk.size()) {
+ tmp_config_obj.set_initramfs_path(foreign_ramdisk);
}
}
@@ -493,7 +500,7 @@ bool InitializeCuttlefishConfiguration(
FLAGS_socket_forward_proxy_binary);
tmp_config_obj.set_socket_vsock_proxy_binary(FLAGS_socket_vsock_proxy_binary);
tmp_config_obj.set_run_as_daemon(FLAGS_daemon);
- tmp_config_obj.set_run_e2e_test(FLAGS_run_e2e_test);
+ tmp_config_obj.set_run_e2e_test(false);
tmp_config_obj.set_e2e_test_binary(FLAGS_e2e_test_binary);
tmp_config_obj.set_data_policy(FLAGS_data_policy);
@@ -526,6 +533,15 @@ bool InitializeCuttlefishConfiguration(
tmp_config_obj.add_kernel_cmdline("androidboot.tombstone_transmit=0");
}
+ tmp_config_obj.set_touch_socket_port(FLAGS_touch_server_port);
+ tmp_config_obj.set_keyboard_socket_port(FLAGS_keyboard_server_port);
+ if (FLAGS_vm_manager == vm_manager::QemuManager::name()) {
+ tmp_config_obj.add_kernel_cmdline(concat("androidboot.vsock_touch_port=",
+ FLAGS_touch_server_port));
+ tmp_config_obj.add_kernel_cmdline(concat("androidboot.vsock_keyboard_port=",
+ FLAGS_keyboard_server_port));
+ }
+
tmp_config_obj.set_use_bootloader(FLAGS_use_bootloader);
tmp_config_obj.set_bootloader(FLAGS_bootloader);
@@ -568,9 +584,11 @@ void SetDefaultFlagsForQemu() {
SetCommandLineOptionWithMode("instance_dir",
default_instance_dir.c_str(),
google::FlagSettingMode::SET_FLAGS_DEFAULT);
- SetCommandLineOptionWithMode("hardware_name", "cutf_ivsh",
+ // TODO(b/144111429): Consolidate to one hardware name
+ SetCommandLineOptionWithMode("hardware_name", "cutf_cvm",
google::FlagSettingMode::SET_FLAGS_DEFAULT);
- SetCommandLineOptionWithMode("logcat_mode", cvd::kLogcatSerialMode,
+ // TODO(b/144119457) Use the serial port.
+ SetCommandLineOptionWithMode("logcat_mode", cvd::kLogcatVsockMode,
google::FlagSettingMode::SET_FLAGS_DEFAULT);
}
@@ -586,10 +604,9 @@ void SetDefaultFlagsForCrosvm() {
SetCommandLineOptionWithMode("x_display",
getenv("DISPLAY"),
google::FlagSettingMode::SET_FLAGS_DEFAULT);
+ // TODO(b/144111429): Consolidate to one hardware name
SetCommandLineOptionWithMode("hardware_name", "cutf_cvm",
google::FlagSettingMode::SET_FLAGS_DEFAULT);
- SetCommandLineOptionWithMode("run_e2e_test", "false",
- google::FlagSettingMode::SET_FLAGS_DEFAULT);
SetCommandLineOptionWithMode("logcat_mode", cvd::kLogcatVsockMode,
google::FlagSettingMode::SET_FLAGS_DEFAULT);
}
@@ -796,7 +813,7 @@ const vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(
cvd::BootImageUnpacker::FromImages(FLAGS_boot_image,
FLAGS_vendor_boot_image);
- if (!InitializeCuttlefishConfiguration(*boot_img_unpacker)) {
+ if (!InitializeCuttlefishConfiguration(*boot_img_unpacker, fetcher_config)) {
LOG(ERROR) << "Failed to initialize configuration";
exit(AssemblerExitCodes::kCuttlefishConfigurationInitError);
}
@@ -829,7 +846,11 @@ const vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(
// boot ramdisk. If a kernel IS provided with no initramfs, it is safe to
// safe to assume that the kernel was built with no modules and expects no
// modules for cf to run properly.
- if(!FLAGS_kernel_path.size() || FLAGS_initramfs_path.size()) {
+ std::string discovered_kernel = fetcher_config.FindCvdFileWithSuffix(kKernelDefaultPath);
+ std::string foreign_kernel = FLAGS_kernel_path.size() ? FLAGS_kernel_path : discovered_kernel;
+ std::string discovered_ramdisk = fetcher_config.FindCvdFileWithSuffix(kInitramfsImg);
+ std::string foreign_ramdisk = FLAGS_initramfs_path.size () ? FLAGS_initramfs_path : discovered_ramdisk;
+ if(!foreign_kernel.size() || foreign_ramdisk.size()) {
const std::string& vendor_ramdisk_path =
config->initramfs_path().size() ? config->initramfs_path()
: config->vendor_ramdisk_image_path();
diff --git a/host/commands/assemble_cvd/super_image_mixer.cc b/host/commands/assemble_cvd/super_image_mixer.cc
index 6cfa2690..2081af43 100644
--- a/host/commands/assemble_cvd/super_image_mixer.cc
+++ b/host/commands/assemble_cvd/super_image_mixer.cc
@@ -15,15 +15,17 @@
#include "super_image_mixer.h"
+#include <sys/stat.h>
+
+#include <algorithm>
#include <cstdio>
#include <functional>
#include <memory>
+#include <android-base/strings.h>
#include <glog/logging.h>
-#include "ziparchive/zip_archive.h"
-#include "ziparchive/zip_writer.h"
-
+#include "common/libs/utils/archive.h"
#include "common/libs/utils/files.h"
#include "common/libs/utils/subprocess.h"
#include "host/libs/config/cuttlefish_config.h"
@@ -49,45 +51,6 @@ std::string TargetFilesZip(const cvd::FetcherConfig& fetcher_config,
return "";
}
-class ZipArchiveDeleter {
-public:
- void operator()(ZipArchive* archive) {
- CloseArchive(archive);
- }
-};
-
-using ManagedZipArchive = std::unique_ptr<ZipArchive, ZipArchiveDeleter>;
-
-class CFileCloser {
-public:
- void operator()(FILE* file) {
- fclose(file);
- }
-};
-
-using ManagedCFile = std::unique_ptr<FILE, CFileCloser>;
-
-ManagedZipArchive OpenZipArchive(const std::string& path) {
- ZipArchive* ptr;
- int status = OpenArchive(path.c_str(), &ptr);
- if (status != 0) {
- LOG(ERROR) << "Could not open archive \"" << path << "\": " << status;
- return {};
- }
- return ManagedZipArchive(ptr);
-}
-
-ManagedCFile OpenFile(const std::string& path, const std::string& mode) {
- FILE* ptr = fopen(path.c_str(), mode.c_str());
- if (ptr == nullptr) {
- int error_num = errno;
- LOG(ERROR) << "Could not open \"" << path << "\". Error was "
- << strerror(error_num);
- return {};
- }
- return ManagedCFile(ptr);
-}
-
const std::string kMiscInfoPath = "META/misc_info.txt";
const std::set<std::string> kDefaultTargetImages = {
"IMAGES/boot.img",
@@ -97,84 +60,65 @@ const std::set<std::string> kDefaultTargetImages = {
"IMAGES/vendor.img",
};
-bool CopyZipFileContents(const uint8_t* buf, size_t buf_size, void* cookie) {
- ZipWriter* out_writer = (ZipWriter*) cookie;
- int32_t status = out_writer->WriteBytes(buf, buf_size);
- if (status != 0) {
- LOG(ERROR) << "Could not write zip file contents, error code " << status;
- return false;
- }
- return true;
-}
-
bool CombineTargetZipFiles(const std::string& default_target_zip,
const std::string& system_target_zip,
const std::string& output_path) {
- auto default_target = OpenZipArchive(default_target_zip);
- if (!default_target) {
+ cvd::Archive default_target_archive(default_target_zip);
+ cvd::Archive system_target_archive(system_target_zip);
+
+ auto default_target_contents = default_target_archive.Contents();
+ if (default_target_contents.size() == 0) {
LOG(ERROR) << "Could not open " << default_target_zip;
return false;
}
- auto system_target = OpenZipArchive(system_target_zip);
- if (!system_target) {
+ auto system_target_contents = system_target_archive.Contents();
+ if (system_target_contents.size() == 0) {
LOG(ERROR) << "Could not open " << system_target_zip;
return false;
}
- auto out_file = OpenFile(output_path, "wb");
- if (!out_file) {
- LOG(ERROR) << "Could not open " << output_path;
+ if (mkdir(output_path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
+ LOG(ERROR) << "Could not create directory " << output_path;
return false;
}
- ZipWriter out_writer{out_file.get()};
-
- ZipEntry entry;
- if (FindEntry(default_target.get(), kMiscInfoPath, &entry) != 0) {
+ if (std::find(default_target_contents.begin(), default_target_contents.end(), kMiscInfoPath)
+ == default_target_contents.end()) {
LOG(ERROR) << "Default target files zip does not have " << kMiscInfoPath;
return false;
}
- out_writer.StartEntry(kMiscInfoPath, 0);
- ProcessZipEntryContents(
- default_target.get(), &entry, CopyZipFileContents, (void*) &out_writer);
- out_writer.FinishEntry();
-
- void* iteration_cookie;
- std::string name;
+ if (!default_target_archive.ExtractFiles({kMiscInfoPath}, output_path)) {
+ LOG(ERROR) << "Failed to write misc info to output directory";
+ return false;
+ }
- StartIteration(default_target.get(), &iteration_cookie, "IMAGES/", ".img");
- for (int status = 0; status != -1; status = Next(iteration_cookie, &entry, &name)) {
- if (name == "") {
+ for (const auto& name : default_target_contents) {
+ if (!android::base::StartsWith(name, "IMAGES/")) {
continue;
- }
- LOG(INFO) << "Name is \"" << name << "\"";
- if (kDefaultTargetImages.count(name) == 0) {
+ } else if (!android::base::EndsWith(name, ".img")) {
+ continue;
+ } else if (kDefaultTargetImages.count(name) == 0) {
continue;
}
LOG(INFO) << "Writing " << name;
- out_writer.StartEntry(name, 0);
- ProcessZipEntryContents(
- default_target.get(), &entry, CopyZipFileContents, (void*) &out_writer);
- out_writer.FinishEntry();
+ if (!default_target_archive.ExtractFiles({name}, output_path)) {
+ LOG(ERROR) << "Failed to extract " << name << " from the default target zip";
+ return false;
+ }
}
- EndIteration(iteration_cookie);
- StartIteration(system_target.get(), &iteration_cookie, "IMAGES/", ".img");
- for (int status = 0; status != -1; status = Next(iteration_cookie, &entry, &name)) {
- if (kDefaultTargetImages.count(name) > 0) {
+ for (const auto& name : system_target_contents) {
+ if (!android::base::StartsWith(name, "IMAGES/")) {
+ continue;
+ } else if (!android::base::EndsWith(name, ".img")) {
+ continue;
+ } else if (kDefaultTargetImages.count(name) > 0) {
continue;
}
LOG(INFO) << "Writing " << name;
- out_writer.StartEntry(name, 0);
- ProcessZipEntryContents(
- system_target.get(), &entry, CopyZipFileContents, (void*) &out_writer);
- out_writer.FinishEntry();
- }
- EndIteration(iteration_cookie);
-
- int success = out_writer.Finish();
- if (success != 0) {
- LOG(ERROR) << "Unable to write combined image zip archive: " << success;
- return false;
+ if (!system_target_archive.ExtractFiles({name}, output_path)) {
+ LOG(ERROR) << "Failed to extract " << name << " from the system target zip";
+ return false;
+ }
}
return true;
@@ -235,14 +179,14 @@ bool RebuildSuperImage(const cvd::FetcherConfig& fetcher_config,
LOG(ERROR) << "Unable to find system target zip file.";
return false;
}
- std::string combined_target_zip = config.PerInstancePath("target_combined.zip");
+ std::string combined_target_path = config.PerInstanceInternalPath("target_combined");
// TODO(schuffelen): Use otatools/bin/merge_target_files
if (!CombineTargetZipFiles(default_target_zip, system_target_zip,
- combined_target_zip)) {
+ combined_target_path)) {
LOG(ERROR) << "Could not combine target zip files.";
return false;
}
- bool success = BuildSuperImage(combined_target_zip, output_path);
+ bool success = BuildSuperImage(combined_target_path, output_path);
if (!success) {
LOG(ERROR) << "Could not write the final output super image.";
}
diff --git a/host/commands/fetcher/Android.bp b/host/commands/fetcher/Android.bp
index 786455f1..6af562c9 100644
--- a/host/commands/fetcher/Android.bp
+++ b/host/commands/fetcher/Android.bp
@@ -31,7 +31,6 @@ cc_binary_host {
"libbase",
"libcuttlefish_host_config",
"libcuttlefish_fs",
- "libcuttlefish_strings",
"libcuttlefish_utils",
"libcurl",
"libcrypto",
diff --git a/host/commands/kernel_log_monitor/Android.bp b/host/commands/kernel_log_monitor/Android.bp
index 7bc29e07..a7197e52 100644
--- a/host/commands/kernel_log_monitor/Android.bp
+++ b/host/commands/kernel_log_monitor/Android.bp
@@ -24,7 +24,6 @@ cc_binary_host {
],
shared_libs: [
"libcuttlefish_fs",
- "libcuttlefish_strings",
"libcuttlefish_utils",
"cuttlefish_auto_resources",
"libbase",
diff --git a/host/commands/kernel_log_monitor/main.cc b/host/commands/kernel_log_monitor/main.cc
index 1f0ead3d..6956e68c 100644
--- a/host/commands/kernel_log_monitor/main.cc
+++ b/host/commands/kernel_log_monitor/main.cc
@@ -20,12 +20,12 @@
#include <string>
#include <vector>
+#include <android-base/strings.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <common/libs/fs/shared_fd.h>
#include <common/libs/fs/shared_select.h>
-#include <common/libs/strings/str_split.h>
#include <host/libs/config/cuttlefish_config.h>
#include "host/commands/kernel_log_monitor/kernel_log_server.h"
@@ -47,7 +47,7 @@ std::vector<cvd::SharedFD> SubscribersFromCmdline() {
}
}
- auto fds = cvd::StrSplit(FLAGS_subscriber_fds, ',');
+ auto fds = android::base::Split(FLAGS_subscriber_fds, ",");
std::vector<cvd::SharedFD> shared_fds;
for (auto& fd_str: fds) {
auto fd = std::stoi(fd_str);
diff --git a/host/commands/launch/Android.bp b/host/commands/launch/Android.bp
index a40a07d5..e2db6153 100644
--- a/host/commands/launch/Android.bp
+++ b/host/commands/launch/Android.bp
@@ -26,7 +26,6 @@ cc_binary_host {
shared_libs: [
"vsoc_lib",
"libcuttlefish_fs",
- "libcuttlefish_strings",
"libcuttlefish_utils",
"cuttlefish_auto_resources",
"libbase",
diff --git a/host/commands/launch/filesystem_explorer.cc b/host/commands/launch/filesystem_explorer.cc
index 5be4ef05..4d43dcfa 100644
--- a/host/commands/launch/filesystem_explorer.cc
+++ b/host/commands/launch/filesystem_explorer.cc
@@ -28,56 +28,6 @@
#include "common/libs/utils/environment.h"
#include "host/libs/config/fetcher_config.h"
-namespace {
-
-/*
- * Returns the paths of all files in `directory_path`.
- *
- * This is a shallow exploration that ignores directories, i.e. it only prints
- * any regular files.
- */
-std::set<std::string> ReportFiles(const std::string& directory_path) {
- // TODO(schuffelen): Put this in a common library.
- DIR* directory = opendir(directory_path.c_str());
- if (!directory) {
- int error_num = errno;
- LOG(ERROR) << "ReportFiles could not open " << directory_path << " ("
- << strerror(error_num) << ")";
- return {};
- }
- struct dirent* entry;
- std::set<std::string> found_files;
- while ((entry = readdir(directory)) != NULL) {
- if (entry->d_type == DT_DIR) {
- continue;
- }
- found_files.insert(directory_path + "/" + std::string(entry->d_name));
- }
- closedir(directory);
- return found_files;
-}
-
-/**
- * Report files that are present based on some heuristics for relevance.
- *
- * This is used in cases where it's not clear in advance whether there are
- * Cuttlefish files in the given directory.
- */
-std::set<std::string> HeuristicFileReport(const std::string& directory_path) {
- std::set<std::string> files;
- if (cvd::FileExists(directory_path + "/bin/launch_cvd")) {
- files.merge(ReportFiles(directory_path + "/bin"));
- }
- bool has_super_img = cvd::FileExists(directory_path + "/super.img");
- bool has_android_info = cvd::FileExists(directory_path + "/android-info.txt");
- if (has_super_img || has_android_info) {
- files.merge(ReportFiles(directory_path));
- }
- return files;
-}
-
-} // namespace
-
cvd::FetcherConfig AvailableFilesReport() {
std::string current_directory = cvd::AbsolutePath(cvd::CurrentDirectory());
if (cvd::FileExists(current_directory + "/fetcher_config.json")) {
@@ -87,28 +37,12 @@ cvd::FetcherConfig AvailableFilesReport() {
}
std::set<std::string> files;
- std::string host_out = cvd::StringFromEnv("ANDROID_HOST_OUT", "");
- if (host_out != "") {
- files.merge(ReportFiles(cvd::AbsolutePath(host_out + "/bin")));
- }
-
- std::string product_out = cvd::StringFromEnv("ANDROID_PRODUCT_OUT", "");
- if (product_out != "") {
- files.merge(ReportFiles(cvd::AbsolutePath(product_out)));
- }
-
- files.merge(HeuristicFileReport(current_directory));
-
- std::string home = cvd::StringFromEnv("HOME", "");
- if (home != "" && cvd::AbsolutePath(home) != current_directory) {
- files.merge(HeuristicFileReport(home));
- }
std::string psuedo_fetcher_dir =
cvd::StringFromEnv("ANDROID_HOST_OUT",
cvd::StringFromEnv("HOME", current_directory));
std::string psuedo_fetcher_config =
- psuedo_fetcher_dir + "/launcher_psuedo_fetcher_config.json";
+ psuedo_fetcher_dir + "/launcher_pseudo_fetcher_config.json";
files.insert(psuedo_fetcher_config);
cvd::FetcherConfig config;
diff --git a/host/commands/run_cvd/Android.bp b/host/commands/run_cvd/Android.bp
index 5629d6a2..29238c9f 100644
--- a/host/commands/run_cvd/Android.bp
+++ b/host/commands/run_cvd/Android.bp
@@ -28,7 +28,6 @@ cc_binary_host {
shared_libs: [
"vsoc_lib",
"libcuttlefish_fs",
- "libcuttlefish_strings",
"libcuttlefish_utils",
"cuttlefish_auto_resources",
"libbase",
diff --git a/host/commands/run_cvd/launch.cc b/host/commands/run_cvd/launch.cc
index 47cf2e26..5c42e593 100644
--- a/host/commands/run_cvd/launch.cc
+++ b/host/commands/run_cvd/launch.cc
@@ -12,6 +12,8 @@
#include "host/commands/run_cvd/runner_defs.h"
#include "host/commands/run_cvd/pre_launch_initializers.h"
#include "host/commands/run_cvd/vsoc_shared_memory.h"
+#include "host/libs/vm_manager/crosvm_manager.h"
+#include "host/libs/vm_manager/qemu_manager.h"
using cvd::RunnerExitCodes;
using cvd::MonitorEntry;
@@ -246,10 +248,20 @@ void LaunchUsbServerIfEnabled(const vsoc::CuttlefishConfig& config,
GetOnSubprocessExitCallback(config));
}
-cvd::SharedFD CreateVncInputServer(const std::string& path) {
+cvd::SharedFD CreateUnixVncInputServer(const std::string& path) {
auto server = cvd::SharedFD::SocketLocalServer(path.c_str(), false, SOCK_STREAM, 0666);
if (!server->IsOpen()) {
- LOG(ERROR) << "Unable to create mouse server: "
+ LOG(ERROR) << "Unable to create unix input server: "
+ << server->StrError();
+ return cvd::SharedFD();
+ }
+ return server;
+}
+
+cvd::SharedFD CreateVsockVncInputServer(int port) {
+ auto server = cvd::SharedFD::VsockServer(port, SOCK_STREAM);
+ if (!server->IsOpen()) {
+ LOG(ERROR) << "Unable to create vsock input server: "
<< server->StrError();
return cvd::SharedFD();
}
@@ -264,33 +276,38 @@ bool LaunchVNCServerIfEnabled(const vsoc::CuttlefishConfig& config,
auto port_options = "-port=" + std::to_string(config.vnc_server_port());
cvd::Command vnc_server(config.vnc_server_binary());
vnc_server.AddParameter(port_options);
- if (!config.enable_ivserver()) {
- // When the ivserver is not enabled, the vnc touch_server needs to serve
- // on unix sockets and send input events to whoever connects to it (namely
- // crosvm)
- auto touch_server = CreateVncInputServer(config.touch_socket_path());
- if (!touch_server->IsOpen()) {
- return false;
- }
- vnc_server.AddParameter("-touch_fd=", touch_server);
-
- auto keyboard_server =
- CreateVncInputServer(config.keyboard_socket_path());
- if (!keyboard_server->IsOpen()) {
- return false;
- }
- vnc_server.AddParameter("-keyboard_fd=", keyboard_server);
- // TODO(b/128852363): This should be handled through the wayland mock
- // instead.
- // Additionally it receives the frame updates from a virtual socket
- // instead
- auto frames_server =
- cvd::SharedFD::VsockServer(config.frames_vsock_port(), SOCK_STREAM);
- if (!frames_server->IsOpen()) {
- return false;
- }
- vnc_server.AddParameter("-frame_server_fd=", frames_server);
+ if (config.vm_manager() == vm_manager::QemuManager::name()) {
+ vnc_server.AddParameter("-write_virtio_input");
+ }
+ // When the ivserver is not enabled, the vnc touch_server needs to serve
+ // on sockets and send input events to whoever connects to it (the VMM).
+ auto touch_server =
+ config.vm_manager() == vm_manager::CrosvmManager::name()
+ ? CreateUnixVncInputServer(config.touch_socket_path())
+ : CreateVsockVncInputServer(config.touch_socket_port());
+ if (!touch_server->IsOpen()) {
+ return false;
+ }
+ vnc_server.AddParameter("-touch_fd=", touch_server);
+
+ auto keyboard_server =
+ config.vm_manager() == vm_manager::CrosvmManager::name()
+ ? CreateUnixVncInputServer(config.keyboard_socket_path())
+ : CreateVsockVncInputServer(config.keyboard_socket_port());
+ if (!keyboard_server->IsOpen()) {
+ return false;
+ }
+ vnc_server.AddParameter("-keyboard_fd=", keyboard_server);
+ // TODO(b/128852363): This should be handled through the wayland mock
+ // instead.
+ // Additionally it receives the frame updates from a virtual socket
+ // instead
+ auto frames_server =
+ cvd::SharedFD::VsockServer(config.frames_vsock_port(), SOCK_STREAM);
+ if (!frames_server->IsOpen()) {
+ return false;
}
+ vnc_server.AddParameter("-frame_server_fd=", frames_server);
process_monitor->StartSubprocess(std::move(vnc_server), callback);
return true;
}
diff --git a/host/commands/run_cvd/main.cc b/host/commands/run_cvd/main.cc
index 663b7f07..dd5ed4d1 100644
--- a/host/commands/run_cvd/main.cc
+++ b/host/commands/run_cvd/main.cc
@@ -35,13 +35,13 @@
#include <thread>
#include <vector>
+#include <android-base/strings.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include "common/libs/fs/shared_buf.h"
#include "common/libs/fs/shared_fd.h"
#include "common/libs/fs/shared_select.h"
-#include "common/libs/strings/str_split.h"
#include "common/libs/utils/environment.h"
#include "common/libs/utils/files.h"
#include "common/libs/utils/subprocess.h"
@@ -351,7 +351,7 @@ int main(int argc, char** argv) {
LOG(FATAL) << "Failed to read input files. Error was \"" << input_fd->StrError() << "\"";
}
}
- std::vector<std::string> input_files = cvd::StrSplit(input_files_str, '\n');
+ std::vector<std::string> input_files = android::base::Split(input_files_str, "\n");
bool found_config = false;
for (const auto& file : input_files) {
if (file.find("cuttlefish_config.json") != std::string::npos) {
diff --git a/host/frontend/adb_connector/Android.bp b/host/frontend/adb_connector/Android.bp
index 3af5ef13..41fa1f65 100644
--- a/host/frontend/adb_connector/Android.bp
+++ b/host/frontend/adb_connector/Android.bp
@@ -28,7 +28,6 @@ cc_binary_host {
shared_libs: [
"libbase",
"libcuttlefish_fs",
- "libcuttlefish_strings",
"liblog",
],
defaults: ["cuttlefish_host_only"],
diff --git a/host/frontend/vnc_server/virtual_inputs.cpp b/host/frontend/vnc_server/virtual_inputs.cpp
index e7e37577..31c03282 100644
--- a/host/frontend/vnc_server/virtual_inputs.cpp
+++ b/host/frontend/vnc_server/virtual_inputs.cpp
@@ -19,6 +19,7 @@
#include <linux/input.h>
#include <linux/uinput.h>
+#include <cstdint>
#include <mutex>
#include "keysyms.h"
@@ -34,7 +35,18 @@ DEFINE_int32(touch_fd, -1,
DEFINE_int32(keyboard_fd, -1,
"A fd for a socket where to accept keyboard connections");
+DEFINE_bool(write_virtio_input, false,
+ "Whether to write the virtio_input struct over the socket");
+
namespace {
+// Necessary to define here as the virtio_input.h header is not available
+// in the host glibc.
+struct virtio_input_event {
+ std::uint16_t type;
+ std::uint16_t code;
+ std::int32_t value;
+};
+
void AddKeyMappings(std::map<uint32_t, uint16_t>* key_mapping) {
(*key_mapping)[cvd::xk::AltLeft] = KEY_LEFTALT;
(*key_mapping)[cvd::xk::ControlLeft] = KEY_LEFTCTRL;
@@ -274,7 +286,7 @@ class SocketVirtualInputs : public VirtualInputs {
InitInputEvent(&events[0], EV_KEY, keymapping_[key_code], down);
InitInputEvent(&events[1], EV_SYN, 0, 0);
- SendEvents(keyboard_socket_, events, sizeof(events));
+ SendEvents(keyboard_socket_, events);
}
void PressPowerButton(bool down) override {
@@ -282,7 +294,7 @@ class SocketVirtualInputs : public VirtualInputs {
InitInputEvent(&events[0], EV_KEY, KEY_POWER, down);
InitInputEvent(&events[1], EV_SYN, 0, 0);
- SendEvents(keyboard_socket_, events, sizeof(events));
+ SendEvents(keyboard_socket_, events);
}
void HandlePointerEvent(bool touch_down, int x, int y) override {
@@ -293,11 +305,12 @@ class SocketVirtualInputs : public VirtualInputs {
InitInputEvent(&events[2], EV_KEY, BTN_TOUCH, touch_down);
InitInputEvent(&events[3], EV_SYN, 0, 0);
- SendEvents(touch_socket_, events, sizeof(events));
+ SendEvents(touch_socket_, events);
}
private:
- void SendEvents(cvd::SharedFD socket, void* event_buffer, int byte_count) {
+ template<size_t num_events>
+ void SendEvents(cvd::SharedFD socket, struct input_event (&event_buffer)[num_events]) {
std::lock_guard<std::mutex> lock(socket_mutex_);
if (!socket->IsOpen()) {
// This is unlikely as it would only happen between the start of the vnc
@@ -306,9 +319,25 @@ class SocketVirtualInputs : public VirtualInputs {
// handle it.
return;
}
- auto ret = socket->Write(event_buffer, byte_count);
- if (ret < 0) {
- LOG(ERROR) << "Error sending input event: " << socket->StrError();
+
+ if (FLAGS_write_virtio_input) {
+ struct virtio_input_event virtio_events[num_events];
+ for (size_t i = 0; i < num_events; i++) {
+ virtio_events[i] = (struct virtio_input_event) {
+ .type = event_buffer[i].type,
+ .code = event_buffer[i].code,
+ .value = event_buffer[i].value,
+ };
+ }
+ auto ret = socket->Write(virtio_events, sizeof(virtio_events));
+ if (ret < 0) {
+ LOG(ERROR) << "Error sending input events: " << socket->StrError();
+ }
+ } else {
+ auto ret = socket->Write(event_buffer, sizeof(event_buffer));
+ if (ret < 0) {
+ LOG(ERROR) << "Error sending input events: " << socket->StrError();
+ }
}
}
@@ -320,6 +349,7 @@ class SocketVirtualInputs : public VirtualInputs {
auto keyboard_server = cvd::SharedFD::Dup(FLAGS_keyboard_fd);
close(FLAGS_keyboard_fd);
FLAGS_keyboard_fd = -1;
+ LOG(INFO) << "Input socket host accepting connections...";
while (1) {
cvd::SharedFDSet read_set;
@@ -330,9 +360,11 @@ class SocketVirtualInputs : public VirtualInputs {
std::lock_guard<std::mutex> lock(socket_mutex_);
if (read_set.IsSet(touch_server)) {
touch_socket_ = cvd::SharedFD::Accept(*touch_server);
+ LOG(INFO) << "connected to touch";
}
if (read_set.IsSet(keyboard_server)) {
keyboard_socket_ = cvd::SharedFD::Accept(*keyboard_server);
+ LOG(INFO) << "connected to keyboard";
}
}
}
@@ -346,9 +378,5 @@ class SocketVirtualInputs : public VirtualInputs {
VirtualInputs::VirtualInputs() { AddKeyMappings(&keymapping_); }
VirtualInputs* VirtualInputs::Get() {
- if (vsoc::CuttlefishConfig::Get()->enable_ivserver()) {
- return new VSoCVirtualInputs();
- } else {
- return new SocketVirtualInputs();
- }
+ return new SocketVirtualInputs();
}
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index 882a951e..17dcb6e5 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -168,6 +168,10 @@ const char* kBootloader = "bootloader";
const char* kUseBootloader = "use_bootloader";
const char* kBootSlot = "boot_slot";
+
+const char* kTouchSocketPort = "touch_socket_port";
+const char* kKeyboardSocketPort = "keyboard_socket_port";
+
} // namespace
namespace vsoc {
@@ -938,6 +942,22 @@ std::string CuttlefishConfig::keyboard_socket_path() const {
return PerInstanceInternalPath("keyboard.sock");
}
+void CuttlefishConfig::set_touch_socket_port(int port) {
+ (*dictionary_)[kTouchSocketPort] = port;
+}
+
+int CuttlefishConfig::touch_socket_port() const {
+ return (*dictionary_)[kTouchSocketPort].asInt();
+}
+
+void CuttlefishConfig::set_keyboard_socket_port(int port) {
+ (*dictionary_)[kKeyboardSocketPort] = port;
+}
+
+int CuttlefishConfig::keyboard_socket_port() const {
+ return (*dictionary_)[kKeyboardSocketPort].asInt();
+}
+
// Creates the (initially empty) config object and populates it with values from
// the config file if the CUTTLEFISH_CONFIG_FILE env variable is present.
// Returns nullptr if there was an error loading from file
diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h
index 0fca9f0d..fc479ec7 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -356,6 +356,12 @@ class CuttlefishConfig {
std::string touch_socket_path() const;
std::string keyboard_socket_path() const;
+ void set_touch_socket_port(int touch_socket_port);
+ int touch_socket_port() const;
+
+ void set_keyboard_socket_port(int keyboard_socket_port);
+ int keyboard_socket_port() const;
+
private:
std::unique_ptr<Json::Value> dictionary_;
diff --git a/host/libs/config/fetcher_config.cpp b/host/libs/config/fetcher_config.cpp
index d2183514..86e16dcf 100644
--- a/host/libs/config/fetcher_config.cpp
+++ b/host/libs/config/fetcher_config.cpp
@@ -197,4 +197,20 @@ std::map<std::string, CvdFile> FetcherConfig::get_cvd_files() const {
return files;
}
+std::string FetcherConfig::FindCvdFileWithSuffix(const std::string& suffix) const {
+ if (!dictionary_->isMember(kCvdFiles)) {
+ return {};
+ }
+ const auto& json_files = (*dictionary_)[kCvdFiles];
+ for (auto it = json_files.begin(); it != json_files.end(); it++) {
+ auto file = it.key().asString();
+ auto expected_pos = file.size() - suffix.size();
+ if (file.rfind(suffix) == expected_pos) {
+ return file;
+ }
+ }
+ LOG(ERROR) << "Could not find file ending in " << suffix;
+ return "";
+}
+
} // namespace cvd
diff --git a/host/libs/config/fetcher_config.h b/host/libs/config/fetcher_config.h
index 41fd396b..825fbc60 100644
--- a/host/libs/config/fetcher_config.h
+++ b/host/libs/config/fetcher_config.h
@@ -78,6 +78,8 @@ public:
bool add_cvd_file(const CvdFile& file, bool override_entry = false);
std::map<std::string, CvdFile> get_cvd_files() const;
+
+ std::string FindCvdFileWithSuffix(const std::string& suffix) const;
};
} // namespace cvd
diff --git a/host/libs/vm_manager/Android.bp b/host/libs/vm_manager/Android.bp
index 6c638ea1..eadcb123 100644
--- a/host/libs/vm_manager/Android.bp
+++ b/host/libs/vm_manager/Android.bp
@@ -38,8 +38,7 @@ cc_library_host_static {
defaults: ["cuttlefish_host_only"],
}
-cc_prebuilt_binary {
+sh_binary_host {
name: "cf_qemu.sh",
- srcs: ["cf_qemu.sh"],
- defaults: ["cuttlefish_host_only"],
+ src: "cf_qemu.sh",
}
diff --git a/host/libs/vm_manager/cf_qemu.sh b/host/libs/vm_manager/cf_qemu.sh
index 75707eda..969332d6 100755
--- a/host/libs/vm_manager/cf_qemu.sh
+++ b/host/libs/vm_manager/cf_qemu.sh
@@ -61,11 +61,6 @@ default_wifi_tap_name="cvd-wtap-${CUTTLEFISH_INSTANCE}"
qemu_binary=${qemu_binary=/usr/bin/qemu-system-x86_64}
dtc_binary=${dtc_binary:-dtc}
-if [[ -z "${ivshmem_vector_count}" ]]; then
- echo "The required ivshmem_vector_count environment variable is not set" >&2
- exit 1
-fi
-
if [[ "${qemu_binary##*/}" = "qemu-system-aarch64" ]]; then
# On ARM, the early console can be PCI, and ISA is not supported
kernel_console_serial="pci-serial"
@@ -147,8 +142,6 @@ args+=(
-device "${kernel_console_serial},chardev=charserial0,id=serial0"
-chardev "socket,id=charserial1,path=${console_path:-${default_dir}/console},server,nowait"
-device "${kernel_console_serial},chardev=charserial1,id=serial1"
- -chardev "socket,path=${ivshmem_qemu_socket_path:-${default_internal_dir}/ivshmem_socket_qemu},id=ivsocket"
- -device "ivshmem-doorbell,chardev=ivsocket,vectors=${ivshmem_vector_count}"
)
if [[ "${logcat_mode}" == "serial" ]]; then
diff --git a/host/libs/vm_manager/qemu_manager.cpp b/host/libs/vm_manager/qemu_manager.cpp
index 5130afe6..138aac4c 100644
--- a/host/libs/vm_manager/qemu_manager.cpp
+++ b/host/libs/vm_manager/qemu_manager.cpp
@@ -110,9 +110,8 @@ bool QemuManager::ConfigureGpu(vsoc::CuttlefishConfig *config) {
// HALs.
config->add_kernel_cmdline("androidboot.hardware.gralloc=cutf_ashmem");
config->add_kernel_cmdline(
- "androidboot.hardware.hwcomposer=cutf_ivsh_ashmem");
- config->add_kernel_cmdline(
- "androidboot.hardware.egl=swiftshader");
+ "androidboot.hardware.hwcomposer=cutf_cvm_ashmem");
+ config->add_kernel_cmdline("androidboot.hardware.egl=swiftshader");
return true;
}
diff --git a/tests/hidl/hidl_implementation_test.cpp b/tests/hidl/hidl_implementation_test.cpp
index a4782f2b..562950b2 100644
--- a/tests/hidl/hidl_implementation_test.cpp
+++ b/tests/hidl/hidl_implementation_test.cpp
@@ -42,9 +42,8 @@ static std::set<std::string> kKnownMissing = {
"android.hardware.bluetooth.a2dp@1.0",
"android.hardware.broadcastradio@1.1",
"android.hardware.broadcastradio@2.0",
- "android.hardware.camera.device@1.0",
- "android.hardware.camera.device@3.5",
"android.hardware.camera.provider@2.5",
+ "android.hardware.cas@1.2",
"android.hardware.cas.native@1.0",
"android.hardware.confirmationui@1.0",
"android.hardware.contexthub@1.0",
@@ -83,7 +82,7 @@ static std::set<std::string> kKnownMissing = {
"android.hardware.tv.tuner@1.0",
"android.hardware.usb@1.2",
"android.hardware.usb.gadget@1.0",
- "android.hardware.vibrator@1.4",
+ "android.hardware.vibrator@1.3",
"android.hardware.vr@1.0",
"android.hardware.weaver@1.0",
"android.hardware.wifi@1.3",
@@ -99,6 +98,8 @@ static bool isPackageWhitelist(const FQName& name) {
static std::vector<std::string> gAospExclude = {
// packages not implemented now that we never expect to be implemented
"android.hardware.tests",
+ // packages not registered with hwservicemanager, usually sub-interfaces
+ "android.hardware.camera.device",
};
for (const std::string& package : gAospExclude) {
if (name.inPackage(package)) {
diff --git a/tools/create_base_image_arm.sh b/tools/create_base_image_arm.sh
index 4cd673b4..87756df3 100755
--- a/tools/create_base_image_arm.sh
+++ b/tools/create_base_image_arm.sh
@@ -203,55 +203,85 @@ if dhcp ${scriptaddr} manifest.txt; then
setenv OldSha ${Sha}
setenv Sha
env import -t ${scriptaddr} 0x8000 ManifestVersion
+ echo "Manifest version $ManifestVersion";
if test "$ManifestVersion" = "1"; then
run manifest1
+ elif test "$ManifestVersion" = "2"; then
+ run manifest2
else
run manifestX
fi
fi'
setenv manifestX 'echo "***** ERROR: Unknown manifest version! *****";'
setenv manifest1 '
-echo "Manifest version 1";
env import -t ${scriptaddr} 0x8000
if test "$Sha" != "$OldSha"; then
setenv serverip ${TftpServer}
setenv loadaddr 0x00200000
mmc dev 0 0;
- file=$TplSplImg; offset=0x40; size=0x1f80; run tftpget1; setenv TplSplImg
- file=$UbootItb; offset=0x4000; size=0x2000; run tftpget1; setenv UbootItb
- file=$TrustImg; offset=0x6000; size=0x2000; run tftpget1; setenv TrustImg
- file=$RootfsImg; offset=0x8000; size=0; run tftpget1; setenv RootfsImg
- file=$UbootEnv; offset=0x1fc0; size=0x40; run tftpget1; setenv UbootEnv
+ setenv file $TplSplImg; offset=0x40; size=0x1f80; run tftpget1; setenv TplSplImg
+ setenv file $UbootItb; offset=0x4000; size=0x2000; run tftpget1; setenv UbootItb
+ setenv file $TrustImg; offset=0x6000; size=0x2000; run tftpget1; setenv TrustImg
+ setenv file $RootfsImg; offset=0x8000; size=0; run tftpget1; setenv RootfsImg
+ setenv file $UbootEnv; offset=0x1fc0; size=0x40; run tftpget1; setenv UbootEnv
mw.b ${scriptaddr} 0 0x8000
env export -b ${scriptaddr} 0x8000
mmc write ${scriptaddr} 0x1fc0 0x40
else
echo "Already have ${Sha}. Booting..."
fi'
-setenv tftpget1 "
-mw.b ${loadaddr} 0 0x400000
-&& tftp ${file}
-&& isGz=0 && setexpr isGz sub .*\\.gz\$ 1 ${file}
-&& if test $isGz = 1; then
- setexpr boffset ${offset} * 0x200
- && gzwrite mmc 0 ${loadaddr} 0x${filesize} 100000 ${boffset}
- && echo Updated: ${bootfile}
-elif test ${file} = boot.env; then
- env import -b ${loadaddr}
- && echo Updated: boot.env
+setenv manifest2 '
+env import -t ${scriptaddr} 0x8000
+if test "$DFUethaddr" = "$ethaddr" || test "$DFUethaddr" = ""; then
+ if test "$Sha" != "$OldSha"; then
+ setenv serverip ${TftpServer}
+ setenv loadaddr 0x00200000
+ mmc dev 0 0;
+ setenv file $TplSplImg; offset=0x40; size=0x1f80; run tftpget1; setenv TplSplImg
+ setenv file $UbootItb; offset=0x4000; size=0x2000; run tftpget1; setenv UbootItb
+ setenv file $TrustImg; offset=0x6000; size=0x2000; run tftpget1; setenv TrustImg
+ setenv file $RootfsImg; offset=0x8000; size=0; run tftpget1; setenv RootfsImg
+ setenv file $UbootEnv; offset=0x1fc0; size=0x40; run tftpget1; setenv UbootEnv
+ mw.b ${scriptaddr} 0 0x8000
+ env export -b ${scriptaddr} 0x8000
+ mmc write ${scriptaddr} 0x1fc0 0x40
+ else
+ echo "Already have ${Sha}. Booting..."
+ fi
else
- && if test $size = 0; then
- setexpr x $filesize - 1
- && setexpr x $x / 0x1000
- && setexpr x $x + 1
- && setexpr x $x * 0x1000
- && setexpr x $x / 0x200
- && size=0x${x}
+ echo "Update ${Sha} is not for me. Booting..."
+fi'
+setenv tftpget1 '
+if test "$file" != ""; then
+ mw.b ${loadaddr} 0 0x400000
+ tftp ${file}
+ if test $? = 0; then
+ setenv isGz 0 && setexpr isGz sub .*\\.gz\$ 1 ${file}
+ if test $isGz = 1; then
+ if test ${file} = ${UbootEnv}; then
+ echo "** gzipped env unsupported **"
+ else
+ setexpr boffset ${offset} * 0x200
+ gzwrite mmc 0 ${loadaddr} 0x${filesize} 100000 ${boffset} && echo Updated: ${file}
+ fi
+ elif test ${file} = ${UbootEnv}; then
+ env import -b ${loadaddr} && echo Updated: ${file}
+ else
+ if test $size = 0; then
+ setexpr x $filesize - 1
+ setexpr x $x / 0x1000
+ setexpr x $x + 1
+ setexpr x $x * 0x1000
+ setexpr x $x / 0x200
+ size=0x${x}
+ fi
+ mmc write ${loadaddr} ${offset} ${size} && echo Updated: ${file}
+ fi
fi
- && mmc write ${loadaddr} ${offset} ${size}
- && echo Updated: ${bootfile}
-fi
-|| echo ** UPDATE FAILED: ${bootfile} **"
+ if test $? != 0; then
+ echo ** UPDATE FAILED: ${file} **
+ fi
+fi'
if mmc dev 1 0; then; else
run bootcmd_dhcp;
fi
@@ -458,7 +488,7 @@ EOF
#!/bin/bash
echo "Installing cuttlefish-common package..."
echo "nameserver 8.8.8.8" > /etc/resolv.conf
-MAC=`ip link | grep eth0 -A1 | grep ether | sed 's/.*\(..:..:..:..:..:..\) .*/\1/'`
+MAC=`ip link | grep eth0 -A1 | grep ether | sed 's/.*\(..:..:..:..:..:..\) .*/\1/' | tr -d :`
sed -i " 1 s/.*/& rockpi-${MAC}/" /etc/hosts
sudo hostnamectl set-hostname "rockpi-${MAC}"
diff --git a/tools/make_manifest.sh b/tools/make_manifest.sh
index f3a18387..5b07d5d6 100755
--- a/tools/make_manifest.sh
+++ b/tools/make_manifest.sh
@@ -30,6 +30,10 @@ DEFINE_string tftp \
"192.168.0.1" "TFTP server address" "f"
DEFINE_string tftpdir \
"/tftpboot" "TFTP server directory" "d"
+DEFINE_string version \
+ "2" "Specify which manifest version to use (default: latest)" "v"
+DEFINE_string ethaddr \
+ "" "MAC address of device to DFU (default: all)" "m"
FLAGS_HELP="USAGE: $0 [flags]"
@@ -54,11 +58,7 @@ confirm() {
}
createManifest() {
-if [ ! -e manifest.txt ]; then
- cat > manifest.txt << EOF
-ManifestVersion=1
-EOF
-fi
+ >>manifest.txt
}
addKVToManifest() {
@@ -69,19 +69,19 @@ addKVToManifest() {
echo "${key}=${value}" >> manifest.txt
}
-addSHAToManifest() {
- key="SHA"
+addShaToManifest() {
+ key="Sha"
cd "${ANDROID_BUILD_TOP}/device/google/cuttlefish_common"
- SHA=`git rev-parse HEAD`
+ Sha=`git rev-parse HEAD`
cd -
cd "${ANDROID_BUILD_TOP}/external/u-boot"
- SHA="$SHA,`git rev-parse HEAD`"
+ Sha="$Sha,`git rev-parse HEAD`"
cd -
cd "${ANDROID_BUILD_TOP}/external/arm-trusted-firmware"
- SHA="$SHA,`git rev-parse HEAD`"
+ Sha="$Sha,`git rev-parse HEAD`"
cd -
- addKVToManifest "${key}" "${SHA}"
+ addKVToManifest "${key}" "${Sha}"
}
addPathToManifest() {
@@ -109,9 +109,11 @@ addPathToManifest() {
}
createManifest
+addKVToManifest ManifestVersion ${FLAGS_version}
addKVToManifest TftpServer ${FLAGS_tftp}
+addKVToManifest DFUethaddr ${FLAGS_ethaddr}
addPathToManifest RootfsImg ${FLAGS_rootfs}
addPathToManifest UbootEnv ${FLAGS_env}
addPathToManifest TplSplImg ${FLAGS_loader1}
addPathToManifest UbootItb ${FLAGS_loader2}
-addSHAToManifest
+addShaToManifest