Check null PDU instead of NPE for getSubmitPdu()

Bug: 111731144
Test: atest SmsMessageTest

Change-Id: Ifde540ae5a0d67a6a8e0986d52187cda99f8bbad
Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/SmsMessageTest.java b/tests/tests/telephony/current/src/android/telephony/cts/SmsMessageTest.java
index 165c5cd..792f8f3 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/SmsMessageTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/SmsMessageTest.java
@@ -23,7 +23,6 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import android.content.Context;
 import android.content.pm.PackageManager;
@@ -238,26 +237,22 @@
             return;
         }
 
+        SmsMessage.SubmitPdu smsPdu;
         String scAddress = null, destinationAddress = null;
         String message = null;
         boolean statusReportRequested = false;
 
-        try {
-            // null message, null destination
-            SmsMessage.getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested);
-            fail("Should throw NullPointerException");
-        } catch (NullPointerException expected) {
-            // expected
-        }
+        // Null message, null destination
+        smsPdu = SmsMessage.getSubmitPdu(scAddress, destinationAddress, message,
+                statusReportRequested);
+        assertNull(smsPdu);
 
         message = "This is a test message";
-        try {
-            // non-null message
-            SmsMessage.getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested);
-            fail("Should throw NullPointerException");
-        } catch (NullPointerException expected) {
-            // expected
-        }
+
+        // Non-null message, null destination
+        smsPdu = SmsMessage.getSubmitPdu(scAddress, destinationAddress, message,
+                statusReportRequested);
+        assertNull(smsPdu);
 
         if (mTelephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
             // TODO: temp workaround, OCTET encoding for EMS not properly supported
@@ -268,8 +263,8 @@
         destinationAddress = "18004664411";
         message = "This is a test message";
         statusReportRequested = false;
-        SmsMessage.SubmitPdu smsPdu =
-            SmsMessage.getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested);
+        smsPdu = SmsMessage.getSubmitPdu(
+                scAddress, destinationAddress, message, statusReportRequested);
         assertNotNull(smsPdu);
 
         smsPdu = SmsMessage.getSubmitPdu(scAddress, destinationAddress, (short)80,