Merge "Refactor DeviceStateManager service and tests." into main