Aircraft carriers now have Wifi available for sailors for morale reasons, so cell phones are used all the time while underway for text and email.
However, if an incident happens (such as a crash) or, you know, going to war or etc - the ship will undergo "River City" conditions and I guarantee you everyone on board knows the drill and you'll be in deep shit if you violate River City. River City conditions will also be implemented in the case of a fatality, accident or death onboard the ship so the identity of the victims is preserved so the Navy can make next of kin notifications without family being alerted early to the issue.
Presumably it's also OK if a warship that shows up at a military dock frotzes mobile phones -- maybe even if mobile phones were disabled on bases in general? I've never been in a military and haven't the faintest idea how much is confidential. And it's not like the military doesn't have other telecom gear.
If a warship ties up at a civilian dock it's a little more tricky, but in general I'd think this principle would also apply.