Fix CTS for Null Handling

fail test gracefully if takeScreenshot()
returns Null. Same fix pushed to 11-test
with change #1838913

Test: run CtsPrefrenceTestCases

bug: 199433039
Change-Id: Ie2a92049d24530f1c9d7750a901ee45130ca7c2e
diff --git a/tests/tests/preference/src/android/preference/cts/TestUtils.java b/tests/tests/preference/src/android/preference/cts/TestUtils.java
index 1992b95..e69e98f 100644
--- a/tests/tests/preference/src/android/preference/cts/TestUtils.java
+++ b/tests/tests/preference/src/android/preference/cts/TestUtils.java
@@ -16,6 +16,8 @@
 
 package android.preference.cts;
 
+import static org.junit.Assert.assertNotNull;
+
 import android.app.Activity;
 import android.app.Instrumentation;
 import android.app.UiAutomation;
@@ -69,6 +71,7 @@
         waitForIdle();
 
         Bitmap bt = mAutomation.takeScreenshot();
+        assertNotNull("Screenshot must not return null", bt);
 
         // Crop-out the status bar to avoid flakiness with changing notifications / time.
         int statusBarHeight = getStatusBarHeight();