media: fix handheld/tablet detection methods

This patch fixes handheld/tablet detection methods. Neither handheld nor
tablet nature is exposed to package manager, so for now, in adddition
to physical screen size, we check also for touchscreen and NOT watch
and NOT tv and NOT pc.

Bug: 238391057
Test: atest android.mediav2.cts

Change-Id: I509748f4ad3fced424fda71a7bd81f99f53f55ab
Signed-off-by: Slawomir Rosek <srosek@google.com>
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/MediaUtils.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/MediaUtils.java
index 488c73f..c4bb536 100644
--- a/common/device-side/util-axt/src/com/android/compatibility/common/util/MediaUtils.java
+++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/MediaUtils.java
@@ -1479,6 +1479,14 @@
         if (screenSize < (FIRST_SDK_IS_AT_LEAST_R ? 3.3 : 2.5)) return false;
         if (screenSize > 8.0) return false;
         if (!hasDeviceGotBattery()) return false;
+        // handheld nature is not exposed to package manager, so for now,
+        // in addition to physical screen size, the following checks are
+        // also required:
+        if (!pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) return false;
+        if (isWatch()) return false;
+        if (isTv()) return false;
+        if (isAutomotive()) return false;
+        if (isPc()) return false;
         return true;
     }
 
@@ -1487,6 +1495,14 @@
         if (screenSize < 7.0) return false;
         if (screenSize > 18.0) return false;
         if (!hasDeviceGotBattery()) return false;
+        // tablet nature is not exposed to package manager, so for now,
+        // in addition to physical screen size, the following checks are
+        // also required:
+        if (!pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) return false;
+        if (isWatch()) return false;
+        if (isTv()) return false;
+        if (isAutomotive()) return false;
+        if (isPc()) return false;
         return true;
     }