Chinese mobile giant Huawei’s smartphone business may be benefiting from a swell of patriotism in its home market, thanks to a U.S. campaign to block sales of its products abroad.

According to market research firm Canalys, Huawei’s Q2 smartphone sales in China rose 31% compared to the same three months last year. The Chinese company shipped 37.3 million units, giving it 38.2% market share in China.

By the same measure, Apple, which is scheduled to report earnings later today, continued to suffer as its Q2 sales in China fell 14% to 5.7 million units, according to Canalys. That continues a tough stretch for Apple in China, a once promising market for the tech giant that has turned disappointing in recent years.

Apple wasn’t alone, as overall smartphone shipments in China fell 6% in the quarter, and other major Chinese vendors — such as Vivo, Oppo, and Xiaomi — all suffered from lower sales.

Earlier this year, the U.S. placed Huawei on a trade blacklist, insisting that its 5G networking equipment posed security risks, due to the company’s ties to China’s central government. More broadly, U.S. officials have been pressuring allies to also block Huawei sales — though with only limited success so far.

Canalys notes that those efforts may have slowed the company’s momentum in other markets, such as Europe. But it appears Chinese consumers are rallying behind the company, motivated by both patriotism and the company’s advanced technology.

“The U.S.-China trade war is also creating new opportunities,” said Canalys analyst Mo Jia in a statement. “Huawei’s retail partners are rolling out advertisements to link Huawei with being the patriotic choice, to appeal to a growing demographic of Chinese consumers willing to take political factors into account when making a purchase decision.”

The Canalys report came out just as Huawei reported that its Q2 revenue rose 23% compared to Q2 2018.

“Revenue grew fast up through May,” said chair Liang Hua in a statement. “Given the foundation we laid in the first half of the year, we continue to see growth even after we were added to the entity list. That’s not to say we don’t have difficulties ahead. We do, and they may affect the pace of our growth in the short term. But we will stay the course.”

For Huawei, growth in China appeared to offset any potential sluggishness resulting from the trade war. Globally, Huawei smartphone sales grew at a slower 24% pace. According to Canalys, 64% of the smartphones Huawei shipped in Q2 were in China, its highest percentage since 2013.

In recent years, Huawei has pushed aggressively to expand outside its home market, most notably in Europe, though that strategy has met with mixed results.

While the latest numbers may offer some relief, Huawei still faces difficulties ahead. Its relationship with Google and its Android operating system remain uncertain. And officials have said the ban could still have big financial implications for the company down the road.