Random searches of phones, laptops, and other electronic devices at airports (and other ports of entry) in the United States have increased over the past few years. In fact, the practice is so commonplace that some people choose to wipe their phones before traveling. Thankfully, a district court has decided that random searches of devices at ports of entry is unconstitutional, making the searches illegal.
The lawsuit Alasaad v. McAleenan was filed over two years ago by the EFF (Electronic Frontier Foundation) and ACLU (American Civil Liberties Union), on behalf of 11 plaintiffs who had their smartphones and other devices searched without warrants at the U.S. border. Ten of the plaintiffs are U.S. citizens, and one is a lawful permanent resident. In the lawsuit, the EFF and ACLU argued that warrantless searches of electronic devices violated the First and Fourth Amendments to the U.S. Constitution.
The ruling makes random technology searches by Customs and Border Control (CBP) and Immigration and Customs Enforcement (ICE) illegal, unless officers have reason to suspect the traveler is carrying illegal contraband. As long as you keep the drugs at home, you shouldn't have a problem on your next flight.