BEIJING — Six years ago, angry demonstrators filled the streets in dozens of Chinese cities to protest Japan’s claim to islands in the East China Sea, surrounding Tokyo’s embassy, overturning Japanese cars and in some cases even attacking sushi restaurants.

Two years later, President Xi Jinping met with Prime Minister Shinzo Abe on the sidelines of a regional conference in Beijing, and the body language said it all: Mr. Xi could barely muster a smile during an awkward handshake for the cameras.

As Mr. Abe begins the first state visit to China by a Japanese leader in eight years on Thursday, no one is expecting the Asian powers to become instant partners, or even to manage a major reconciliation. But in the age of Trump, both are looking for a little more normality.

Battered by plummeting relations with Washington, and particularly by President Trump’s trade war, Mr. Xi is looking to a friendlier Japan as a hedge. And though Mr. Abe has met more often with Mr. Trump than any other foreign leader has, he is well aware of the president’s fickle treatment of American allies and also wants to cover his bets.