Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions base/cvd/cuttlefish/common/libs/utils/device_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ DeviceType ParseDeviceType(std::string_view type_name) {
return DeviceType::Minidroid;
} else if (type_name == "go") {
return DeviceType::Go;
} else if (type_name == "desktop") {
return DeviceType::Desktop;
} else {
return DeviceType::Unknown;
}
Expand All @@ -61,6 +63,8 @@ std::string_view DeviceTypeToStringView(DeviceType device_type) {
return "minidroid";
case DeviceType::Go:
return "go";
case DeviceType::Desktop:
return "desktop";
}
}

Expand Down
1 change: 1 addition & 0 deletions base/cvd/cuttlefish/common/libs/utils/device_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum class DeviceType {
Tv,
Minidroid,
Go,
Desktop,
};

// Parse device type android-info.txt config field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ Result<void> ParseGuestConfigTextProto(const std::string& guest_config_path,
{config::DeviceType::Foldable, DeviceType::Foldable},
{config::DeviceType::Tv, DeviceType::Tv},
{config::DeviceType::Minidroid, DeviceType::Minidroid},
{config::DeviceType::Go, DeviceType::Go}};
{config::DeviceType::Go, DeviceType::Go},
{config::DeviceType::Desktop, DeviceType::Desktop}};

config::GuestConfigFile proto_config;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ enum DeviceType {
Tv = 5;
Minidroid = 6;
Go = 7;
Desktop = 8;
}

// The presence of this field in the proto indicates the lights HAL is enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,31 @@ Result<void> UpdateSensorsHal(const std::string& sensors_data,
return {};
}

SensorsMask HostEnabledSensors(DeviceType device_type) {
switch (device_type) {
case DeviceType::Foldable:
return (1 << kAccelerationId) | (1 << kGyroscopeId) | (1 << kMagneticId) |
(1 << kTemperatureId) | (1 << kProximityId) | (1 << kLightId) |
(1 << kPressureId) | (1 << kHumidityId) | (1 << kHingeAngle0Id);
case DeviceType::Auto:
return (1 << kAccelerationId) | (1 << kGyroscopeId) |
(1 << kUncalibGyroscopeId) | (1 << kUncalibAccelerationId);
case DeviceType::Wear:
return (1 << kAccelerationId) | (1 << kGyroscopeId) | (1 << kMagneticId) |
(1 << kTemperatureId) | (1 << kProximityId) | (1 << kLightId) |
(1 << kPressureId) | (1 << kHumidityId) |
(1 << kSensorHandleLowLatencyOffBodyDetect);
case DeviceType::Desktop:
return (1 << kAccelerationId) | (1 << kGyroscopeId) | (1 << kMagneticId) |
(1 << kTemperatureId) | (1 << kProximityId) | (1 << kLightId) |
(1 << kPressureId) | (1 << kHumidityId) | (1 << kHingeAngle0Id);
default:
return (1 << kAccelerationId) | (1 << kGyroscopeId) | (1 << kMagneticId) |
(1 << kTemperatureId) | (1 << kProximityId) | (1 << kLightId) |
(1 << kPressureId) | (1 << kHumidityId);
}
}

} // namespace

SensorsHalProxy::SensorsHalProxy(SharedFD control_from_guest_fd,
Expand All @@ -135,32 +160,7 @@ SensorsHalProxy::SensorsHalProxy(SharedFD control_from_guest_fd,
data_channel_(std::move(data_from_guest_fd), std::move(data_to_guest_fd)),
kernel_events_fd_(std::move(kernel_events_fd)),
sensors_simulator_(sensors_simulator) {
SensorsMask host_enabled_sensors;
switch (device_type) {
case DeviceType::Foldable:
host_enabled_sensors =
(1 << kAccelerationId) | (1 << kGyroscopeId) | (1 << kMagneticId) |
(1 << kTemperatureId) | (1 << kProximityId) | (1 << kLightId) |
(1 << kPressureId) | (1 << kHumidityId) | (1 << kHingeAngle0Id);
break;
case DeviceType::Auto:
host_enabled_sensors = (1 << kAccelerationId) | (1 << kGyroscopeId) |
(1 << kUncalibGyroscopeId) |
(1 << kUncalibAccelerationId);
break;
case DeviceType::Wear:
host_enabled_sensors = (1 << kAccelerationId) | (1 << kGyroscopeId) |
(1 << kMagneticId) | (1 << kTemperatureId) |
(1 << kProximityId) | (1 << kLightId) |
(1 << kPressureId) | (1 << kHumidityId) |
(1 << kSensorHandleLowLatencyOffBodyDetect);
break;
default:
host_enabled_sensors = (1 << kAccelerationId) | (1 << kGyroscopeId) |
(1 << kMagneticId) | (1 << kTemperatureId) |
(1 << kProximityId) | (1 << kLightId) |
(1 << kPressureId) | (1 << kHumidityId);
}
const SensorsMask host_enabled_sensors = HostEnabledSensors(device_type);

req_responder_thread_ = std::thread([this, host_enabled_sensors] {
while (running_) {
Expand Down
Loading