Funny coincidence, I came across another use of ultrasonics today. Sony is redistributing an open-source tool to detect if your Android phone is underwater. To do so, the library emits 22 kHz tone from the phone speaker and listens for it with the phone’s microphone. They have created a pre-trained neural network to distinguish air from water sound transmission.
I like this part: “The user must not use headphones or turn on silent mode. This will violate the assumed Android audio policy.” 🙂
To work on a non-Xperia device (phone, watch, etc), you’d probably have to do a bunch of training work. But it likely could work in theory. But if your phone is not waterproof, not a good idea. 🙂
What I think could be interesting is what you do differently if you detect that the device is underwater. Maybe you apply different equalizer settings to make audio alerts more clear?