Smartphones are so ubiquitous that we take them for granted. The wealth of information they offer to users is matched by the immense trove of information they compile about users — where they went, whom they called or texted, what websites they perused, even how many steps they took.

The accumulation of such information presents a threat to privacy — from companies that aggregate data, but also from the government. If law enforcement officers can examine the contents of your phone, they can peek mercilessly into every corner of your life.

That’s the bad news.

The good news is that the Fourth Amendment forbids “unreasonable searches and seizures” by government agents. And federal courts have shown they understand that the advance of technology requires the updating of the law to shield citizens from unwarranted snooping.

In 2014, the U.S. Supreme Court took a firm stand, ruling unanimously that police must obtain a warrant to search the phones of people they arrest. “A cellphone search would typically expose to the government far more than the most exhaustive search of a house,” noted Chief Justice John Roberts. “The fact that technology now allows an individual to carry such information in his hand does not make the information any less worthy of the protection for which the Founders fought.”

That decision protected people going about their normal business. But it didn’t affect them when crossing an international border.

The issue arose in a case involving Hamza Kolsuz, a Turkish national convicted of trying to smuggle guns out of the country. The Fourth U.S. Circuit Court of Appeals ruled that privacy requires limits on such searches even at border checkpoints and other ports of entry. Routine searches of pockets and suitcases, it noted, require no legal justification. But strip searches, X-rays and other invasive procedures are allowed only when agents act on the basis of “reasonable suspicion.”

Unpacking the contents of a smartphone, the court said, is anything but routine and therefore should be subject to the same restriction. The logic of the 2014 Supreme Court decision was fully applicable here, it said.

Kolsuz was stopped on his way to board a plane for Istanbul at Washington Dulles International Airport after firearms components were found in his luggage. He had his phone taken and subjected to a thorough forensic examination that yielded an 896-page report. His lawyers argued that the search was illegal because the government didn’t have “probable cause.” But the court said the lower standard of “reasonable suspicion” was all the agents needed to meet to examine his phone. So his conviction stood.

Call it a happy ending — an arms trafficker goes to prison, but he also does the rest of us a favor by inducing a federal appeals court to issue a decision to keep a basic right from being fatally eroded. We hope the Supreme Court will find the opportunity to do likewise.