Skip test if device owner cant be set

Bug: 287246591
Test: atest CtsSuspendAppsTestCases:SuspendPackagesTest
Change-Id: I9836a7a257cecf1b92e8d35241794718c3538158
diff --git a/tests/suspendapps/tests/src/android/suspendapps/cts/SuspendPackagesTest.java b/tests/suspendapps/tests/src/android/suspendapps/cts/SuspendPackagesTest.java
index bec0a80..6efa5b9 100644
--- a/tests/suspendapps/tests/src/android/suspendapps/cts/SuspendPackagesTest.java
+++ b/tests/suspendapps/tests/src/android/suspendapps/cts/SuspendPackagesTest.java
@@ -86,9 +86,15 @@
     @Rule
     public static final DeviceState sDeviceState = new DeviceState();
 
-    private void addAndAssertDeviceOwner() {
-        TestApis.devicePolicy().setDeviceOwner(new ComponentName(DEVICE_ADMIN_PACKAGE,
-                TestDeviceAdmin.class.getName()));
+    private boolean addDeviceOwner() {
+        try {
+            TestApis.devicePolicy().setDeviceOwner(new ComponentName(DEVICE_ADMIN_PACKAGE,
+                    TestDeviceAdmin.class.getName()));
+            return true;
+        } catch (Exception e) {
+            Log.e(TAG, "Could not add device owner", e);
+        }
+        return false;
     }
 
     private void addAndAssertDeviceAdmin() {
@@ -193,7 +199,7 @@
     @Test
     public void testCanSuspendWhenDeviceOwner() throws Exception {
         assumeTrue(FeatureUtil.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN));
-        addAndAssertDeviceOwner();
+        assumeTrue(addDeviceOwner());
         SuspendTestUtils.suspend(null, null, null);
     }