Detect Screen Size and/or Tablet vs Phone on Android

Trying to restrict orientation on phones to portrait. Using the screen orientation plugin, I can lock the device-


However, I only want to lock the device when it is a phone or it is smaller than a 7 inch device. Is this possible without writing a plugin for ionic? With iOS there is the ability to detect ionic.Platform.isIPad() ,as well as options in xcode allows you to set orientations for phone and tablet differently.
Please advice what is the best way to do this? I have tried window.screen.width and a few other like window.devicePixelRatio. However, no way to tell if I am dealing with a phone or tablet.
Thanks for your help.

Have you tried to read the viewport size: $window.innerHeight and $window.innerWidth?

Yes, I have. That gives works fine, however, the newer devices can have really high resolutions so it doesn’t really help that much. Especially because keyboards take up similar space.

With the continuing trend toward larger screen sizes and greater resolution, this is going to be an ongoing issue for devs (yesterday’s table innerHeight and innerWidth are today’s phone values). I make screen orientation a user setting I place in local storage.