Define "safe".
If you are not a US Citizen or, maybe, a legal permanent resident then you must provide unlocked access to your electronic devices at the border upon request or be denied entry to the US.
A US Citizen can refuse but the government will then seize your device and you won't be getting it back short of (maybe) a very expensive lawsuit.
The odds that the US will attempt to search your electronics "randomly" are incredibly low but, again, refusal to cooperate is likely to get you permanently flagged for enhanced scrutiny on any attempt to enter the US, your device permanently seized, and you denied entry on that visit.
If you already might be a person of interest to US authorities then the odds of an attempted search skyrocket.
Use a clean, disposable, phone when crossing the border. Upon entry to the US buy a Pixel, put GOS on it, and then use encrypted cloud backups to reestablish whatever data you need while in the US. That is about the only way to guarantee (in so far as one practically can) safety.