add carrier id in subscriptionInfo

add carrier id in subscriptionInfo so that apps
can get subId, carrrier id and other subscription related info
from a single call.
Bug: 119676543
Test: unit test

Change-Id: Iee4652dde5b1b1820a837093328e2dcc58f0e69f
(cherry picked from commit 15ea95a4bdeeaa7eb9d26d1838504ea218baff0a)
Merged-in: Iee4652dde5b1b1820a837093328e2dcc58f0e69f
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 0025943..f4e697e 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -143,7 +143,7 @@
     private static final boolean DBG = true;
     private static final boolean VDBG = false; // STOPSHIP if true
 
-    private static final int DATABASE_VERSION = 32 << 16;
+    private static final int DATABASE_VERSION = 33 << 16;
     private static final int URL_UNKNOWN = 0;
     private static final int URL_TELEPHONY = 1;
     private static final int URL_CURRENT = 2;
@@ -385,7 +385,8 @@
                 + SubscriptionManager.IS_OPPORTUNISTIC + " INTEGER DEFAULT 0,"
                 + SubscriptionManager.GROUP_UUID + " TEXT,"
                 + SubscriptionManager.IS_METERED + " INTEGER DEFAULT 1,"
-                + SubscriptionManager.ISO_COUNTRY_CODE + " TEXT"
+                + SubscriptionManager.ISO_COUNTRY_CODE + " TEXT,"
+                + SubscriptionManager.CARRIER_ID + " INTEGER DEFAULT -1"
                 + ");";
     }
 
@@ -1197,6 +1198,20 @@
                 oldVersion = 32 << 16 | 6;
             }
 
+            if (oldVersion < (33 << 16 | 6)) {
+                try {
+                    // Try to update the siminfo table. It might not be there.
+                    db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
+                            + SubscriptionManager.CARRIER_ID + " INTEGER DEFAULT -1;");
+                } catch (SQLiteException e) {
+                    if (DBG) {
+                        log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
+                                "The table will get created in onOpen.");
+                    }
+                }
+                oldVersion = 33 << 16 | 6;
+            }
+
             if (DBG) {
                 log("dbh.onUpgrade:- db=" + db + " oldV=" + oldVersion + " newV=" + newVersion);
             }