crosvm/vm_control
Yuan Yao 66143a5419 bat: Notify guest status change when BatConfig is set by commands
Currently, after bat_config is set by SetFakeBatConfig and
CancelFakeConfig commands. The guest won't be ensured to read all fields
that are possible impacted. That causes battery status change in guest
have some delays to show up.

This CL set the possible impacted flags in `int_status` when
SetFakeConfig and CancelFakeConfig commands are called. That ensures the
guest will immediately reads the battery status again to reflect the
battery config change.

Also, the bat_config field is moved to field of GoldfishBatteryState. A
function `set_bat_config` is created to help set correct `int_status`
when bat_config is changed.

The create_battery_func! macro is created to annotate the value type
explicitly, and set_int_status function is modified to adpat to mask
with multiple flag bits.

BUG=b:382758036
TEST=1. Boot ArcVM and wait for 1 minutes.
     2. Repeat the step 3~6 in DUT for 3 times.
     3. crosvm battery goldfish "set_fake_bat_config" "20"
	${ARCVM_SOCKET_PATH}
     4. adb shell dumpsys battery & verify battery status is changed.
     5. crosvm battery goldfish "cancel_fake_bat_config" ""
	${ARCVM_SOCKET_PATH}
     6. adb shell dumpsys battery & verify battery status is reset.

Change-Id: I3034f6d805e966bfa356595474e67ec2e02e1ece
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6076381
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
2024-12-11 10:38:52 +00:00
..
src bat: Notify guest status change when BatConfig is set by commands 2024-12-11 10:38:52 +00:00
Cargo.toml Cargo.toml: avoid "*" versions for external crates 2024-05-22 01:01:42 +00:00