SAN FRANCISCO — President Biden and Chinese leader Xi Jinping agreed on Wednesday to restore communications between their countries’ militaries after they met face-to-face for the first time in a year, lowering tensions between the two superpowers at a time when the White House is struggling to manage wars in Europe and the Middle East.