SAN FRANCISCO — A federal judge in Oakland has ruled that government agents didn’t violate the Fourth Amendment when they planted audio recording devices outside courthouses in Alameda and Contra Costa counties without a warrant.

U.S. District Chief Judge Phyllis Hamilton wrote that while it was “unsettling” for the devices to be planted near courthouse entrances in Oakland and Martinez, it wasn’t illegal.