You could try using the OWA_UTIL package, eg OWA_UTIL.get_cgi_env ('HTTP_USER_AGENT');
Thanks Vincent. That looks promising. I'll try it out and mark your answer as correct if it works.
Vincent - the solution you suggested works well. Thanks!
I implemented it with OWA_UTIL.
By the way, I guess internally Apex must have a method of it's own in order to know which theme to use?
To use OWA_UTIL I followed the link you provided and used the package from Christian's blog.
As he explains, no method will be 100% but he's tested it on 11000 common user agent strings (http_user_agent values).
Over time, as devices and browsers change, the http_user_agent will have more possible values but for now it's fine. I didn't need to get much information from http_user_agent, just whether Apex was running on a desktop or not, and it's fine.