A few months ago a Palestinian guy was seized his phone and then denied entry to the US because an agent saw anti-US propaganda posts shared by his friends on FB, so from this stance one should log out from any account he rebukes or makes fun of the US with, since US officials may take a joke or a critique about their country very seriously. But I wonder whether US officials can simply check manually a traveler's phone or also go further and used advanced IT techniques? Is it something that may likely happen or is it a privacy violation?
The likelihood is extremely low unless you have have special circumstances that trigger advanced interest.
In 2018 there were about 33000 phone and laptop searches and there are about 80 million visitors. The statistical likelihood would be around 0.0004 .
**UPDATE based on comments **
Sources: Number of US visitors: https://uk.usembassy.gov/international-visitors-to-u-s-on-the-rise-infographic/
Number of searches: I can't find the original source quickly but here is a Washington Post article that quotes the 2017 numbers at 30,000 https://www.washingtonpost.com/world/national-security/us-customs-agents-are-searching-more-cellphones--including-those-belonging-to-americans/2018/01/05/0a236202-f247-11e7-b3bf-ab90a706e175_story.html
Yes, they can and will ask you to log into your phone, and search your phone for "obvious stuff" - emails, texts, chats, Facebook, etc. Generally, what they're looking for is evidence of one of the big four:
- planning to overstay your visa
- planning to seek employment without a visa for that
- planning to fall back onto social services (the dole)
- planning to commit crime or terror
But if they find something else ... well, gotcha.
They may also plug your phone into an automated process that scans your files for keywords or illegal/obscene files (typically by image or hash comparisons).
Keep in mind that obscenity-wise, something legal in both nations may be illegal to take across the border! (this, page 7, prohibiting perfectly normal mainstream stuff like vanilla hetsex, Fifty Shades of Grey, and contortionists of all things).