Fixed NPE in TelephonyBackupAgent

Country iso might not be always available for some cases.
For those cases, we should avoid using it.

Fix: 150248923
Test: Manual
Change-Id: Ia383c109d4bb9956ab21e868781683984fd1986b
diff --git a/src/com/android/providers/telephony/TelephonyBackupAgent.java b/src/com/android/providers/telephony/TelephonyBackupAgent.java
index 58e3388..5c764c8 100644
--- a/src/com/android/providers/telephony/TelephonyBackupAgent.java
+++ b/src/com/android/providers/telephony/TelephonyBackupAgent.java
@@ -706,8 +706,15 @@
         if (subscriptionInfo == null) {
             return null;
         }
-        return PhoneNumberUtils.formatNumberToE164(subscriptionInfo.getNumber(),
-                subscriptionInfo.getCountryIso().toUpperCase(Locale.US));
+        // country iso might not be always available in some corner cases (e.g. mis-configured SIM,
+        // carrier config, or test SIM has incorrect IMSI, etc...). In that case, just return the
+        // unformatted number.
+        if (!TextUtils.isEmpty(subscriptionInfo.getCountryIso())) {
+            return PhoneNumberUtils.formatNumberToE164(subscriptionInfo.getNumber(),
+                    subscriptionInfo.getCountryIso().toUpperCase(Locale.US));
+        } else {
+            return subscriptionInfo.getNumber();
+        }
     }
 
     private void writeSmsToWriter(JsonWriter jsonWriter, Cursor cursor,