The US Justice Department and TikTok have agreed on a $400 million settlement to resolve allegations that the social media app violated children’s online ​privacy.