Huawei Technologies Co. posted a first-half profit, getting back into the black after the emergence of DeepSeek ignited a wave of AI development across China.