Merge "Carrier ID table rollout latest_carrier_list_rollout_20200121"
diff --git a/src/com/android/providers/telephony/SmsProvider.java b/src/com/android/providers/telephony/SmsProvider.java
index 6cc00d6..a5dfa79 100644
--- a/src/com/android/providers/telephony/SmsProvider.java
+++ b/src/com/android/providers/telephony/SmsProvider.java
@@ -42,6 +42,7 @@
 import android.provider.Telephony.Threads;
 import android.telephony.SmsManager;
 import android.telephony.SmsMessage;
+import android.telephony.SubscriptionManager;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -53,6 +54,7 @@
 public class SmsProvider extends ContentProvider {
     private static final Uri NOTIFICATION_URI = Uri.parse("content://sms");
     private static final Uri ICC_URI = Uri.parse("content://sms/icc");
+    private static final Uri ICC_SUBID_URI = Uri.parse("content://sms/icc_subId");
     static final String TABLE_SMS = "sms";
     static final String TABLE_RAW = "raw";
     private static final String TABLE_SR_PENDING = "sr_pending";
@@ -247,12 +249,45 @@
                 break;
 
             case SMS_ALL_ICC:
-                return getAllMessagesFromIcc();
+            case SMS_ALL_ICC_SUBID:
+                {
+                    int subId;
+                    if (match == SMS_ALL_ICC) {
+                        subId = SmsManager.getDefaultSmsSubscriptionId();
+                    } else {
+                        try {
+                            subId = Integer.parseInt(url.getPathSegments().get(1));
+                        } catch (NumberFormatException e) {
+                            throw new IllegalArgumentException("Wrong path segements, uri= " + url);
+                        }
+                    }
+                    Cursor ret = getAllMessagesFromIcc(subId);
+                    ret.setNotificationUri(getContext().getContentResolver(),
+                            match == SMS_ALL_ICC ? ICC_URI : ICC_SUBID_URI);
+                    return ret;
+                }
 
             case SMS_ICC:
-                String messageIndexString = url.getPathSegments().get(1);
-
-                return getSingleMessageFromIcc(messageIndexString);
+            case SMS_ICC_SUBID:
+                {
+                    int subId;
+                    int messageIndex;
+                    try {
+                        if (match == SMS_ICC) {
+                            subId = SmsManager.getDefaultSmsSubscriptionId();
+                            messageIndex = Integer.parseInt(url.getPathSegments().get(1));
+                        } else {
+                            subId = Integer.parseInt(url.getPathSegments().get(1));
+                            messageIndex = Integer.parseInt(url.getPathSegments().get(2));
+                        }
+                    } catch (NumberFormatException e) {
+                        throw new IllegalArgumentException("Wrong path segements, uri= " + url);
+                    }
+                    Cursor ret = getSingleMessageFromIcc(subId, messageIndex);
+                    ret.setNotificationUri(getContext().getContentResolver(),
+                            match == SMS_ICC ? ICC_URI : ICC_SUBID_URI);
+                    return ret;
+                }
 
             default:
                 Log.e(TAG, "Invalid request: " + url);
@@ -332,45 +367,51 @@
     }
 
     /**
-     * Return a Cursor containing just one message from the ICC.
+     * Gets single message from the ICC for a subscription ID.
+     *
+     * @param subId the subscription ID.
+     * @param messageIndex the message index of the messaage in the ICC.
+     * @return a cursor containing just one message from the ICC for the subscription ID.
      */
-    private Cursor getSingleMessageFromIcc(String messageIndexString) {
-        int messageIndex = -1;
-        try {
-            messageIndex = Integer.parseInt(messageIndexString);
-        } catch (NumberFormatException exception) {
-            throw new IllegalArgumentException("Bad SMS ICC ID: " + messageIndexString);
+    private Cursor getSingleMessageFromIcc(int subId, int messageIndex) {
+        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+            throw new IllegalArgumentException("Invalid Subscription ID " + subId);
         }
+        SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
         List<SmsMessage> messages;
-        final SmsManager smsManager = SmsManager.getDefault();
-        // Use phone id to avoid AppOps uid mismatch in telephony
+
+        // Use phone app permissions to avoid UID mismatch in AppOpsManager.noteOp() call.
         long token = Binder.clearCallingIdentity();
         try {
             messages = smsManager.getMessagesFromIcc();
         } finally {
             Binder.restoreCallingIdentity(token);
         }
-        if (messages == null) {
-            throw new IllegalArgumentException("ICC message not retrieved");
-        }
+
         final SmsMessage message = messages.get(messageIndex);
         if (message == null) {
             throw new IllegalArgumentException(
-                    "Message not retrieved. ID: " + messageIndexString);
+                    "No message in index " + messageIndex + " for subId " + subId);
         }
         MatrixCursor cursor = new MatrixCursor(ICC_COLUMNS, 1);
         cursor.addRow(convertIccToSms(message, 0));
-        return withIccNotificationUri(cursor);
+        return cursor;
     }
 
     /**
-     * Return a Cursor listing all the messages stored on the ICC.
+     * Gets all the messages in the ICC for a subscription ID.
+     *
+     * @param subId the subscription ID.
+     * @return a cursor listing all the message in the ICC for the subscription ID.
      */
-    private Cursor getAllMessagesFromIcc() {
-        SmsManager smsManager = SmsManager.getDefault();
+    private Cursor getAllMessagesFromIcc(int subId) {
+        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+            throw new IllegalArgumentException("Invalid Subscription ID " + subId);
+        }
+        SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
         List<SmsMessage> messages;
 
-        // use phone app permissions to avoid UID mismatch in AppOpsManager.noteOp() call
+        // Use phone app permissions to avoid UID mismatch in AppOpsManager.noteOp() call
         long token = Binder.clearCallingIdentity();
         try {
             messages = smsManager.getMessagesFromIcc();
@@ -386,11 +427,6 @@
                 cursor.addRow(convertIccToSms(message, i));
             }
         }
-        return withIccNotificationUri(cursor);
-    }
-
-    private Cursor withIccNotificationUri(Cursor cursor) {
-        cursor.setNotificationUri(getContext().getContentResolver(), ICC_URI);
         return cursor;
     }
 
@@ -466,11 +502,16 @@
         try {
             Uri insertUri = insertInner(url, initialValues, callerUid, callerPkg);
 
-            // The raw table is used by the telephony layer for storing an sms before
-            // sending out a notification that an sms has arrived. We don't want to notify
-            // the default sms app of changes to this table.
-            final boolean notifyIfNotDefault = sURLMatcher.match(url) != SMS_RAW_MESSAGE;
-            notifyChange(notifyIfNotDefault, insertUri, callerPkg);
+            int match = sURLMatcher.match(url);
+            // Skip notifyChange() if insertUri is null for SMS_ALL_ICC or SMS_ALL_ICC_SUBID caused
+            // by failure of insertMessageToIcc()(e.g. SIM full).
+            if (insertUri != null || (match != SMS_ALL_ICC && match != SMS_ALL_ICC_SUBID)) {
+                // The raw table is used by the telephony layer for storing an sms before sending
+                // out a notification that an sms has arrived. We don't want to notify the default
+                // sms app of changes to this table.
+                final boolean notifyIfNotDefault = match != SMS_RAW_MESSAGE;
+                notifyChange(notifyIfNotDefault, insertUri, callerPkg);
+            }
             return insertUri;
         } finally {
             Binder.restoreCallingIdentity(token);
@@ -536,6 +577,47 @@
                 table = "canonical_addresses";
                 break;
 
+            case SMS_ALL_ICC:
+            case SMS_ALL_ICC_SUBID:
+                int subId;
+                if (match == SMS_ALL_ICC) {
+                    subId = SmsManager.getDefaultSmsSubscriptionId();
+                } else {
+                    try {
+                        subId = Integer.parseInt(url.getPathSegments().get(1));
+                    } catch (NumberFormatException e) {
+                        throw new IllegalArgumentException(
+                                "Wrong path segements for SMS_ALL_ICC_SUBID, uri= " + url);
+                    }
+                }
+
+                if (initialValues == null) {
+                    throw new IllegalArgumentException("ContentValues is null");
+                }
+
+                String scAddress = initialValues.getAsString(Sms.SERVICE_CENTER);
+                String address = initialValues.getAsString(Sms.ADDRESS);
+                String message = initialValues.getAsString(Sms.BODY);
+                boolean isRead = true;
+                Integer obj = initialValues.getAsInteger(Sms.TYPE);
+
+                if (obj == null || address == null || message == null) {
+                    throw new IllegalArgumentException("Missing SMS data");
+                }
+
+                type = obj.intValue();
+                if (!isSupportedType(type)) {
+                    throw new IllegalArgumentException("Unsupported message type= " + type);
+                }
+                obj = initialValues.getAsInteger(Sms.READ); // 0: Unread, 1: Read
+                if (obj != null && obj.intValue() == 0) {
+                    isRead = false;
+                }
+
+                Long date = initialValues.getAsLong(Sms.DATE);
+                return insertMessageToIcc(subId, scAddress, address, message, type, isRead,
+                        date != null ? date : 0) ? url : null;
+
             default:
                 Log.e(TAG, "Invalid request: " + url);
                 return null;
@@ -669,6 +751,63 @@
         return null;
     }
 
+    private boolean isSupportedType(int messageType) {
+        return (messageType == Sms.MESSAGE_TYPE_INBOX)
+                || (messageType == Sms.MESSAGE_TYPE_OUTBOX)
+                || (messageType == Sms.MESSAGE_TYPE_SENT);
+    }
+
+    private int getMessageStatusForIcc(int messageType, boolean isRead) {
+        if (messageType == Sms.MESSAGE_TYPE_SENT) {
+            return SmsManager.STATUS_ON_ICC_SENT;
+        } else if (messageType == Sms.MESSAGE_TYPE_OUTBOX) {
+            return SmsManager.STATUS_ON_ICC_UNSENT;
+        } else { // Sms.MESSAGE_BOX_INBOX
+            if (isRead) {
+                return SmsManager.STATUS_ON_ICC_READ;
+            } else {
+                return SmsManager.STATUS_ON_ICC_UNREAD;
+            }
+        }
+    }
+
+    /**
+     * Inserts new message to the ICC for a subscription ID.
+     *
+     * @param subId the subscription ID.
+     * @param scAddress the SMSC for this message.
+     * @param address destination or originating address.
+     * @param message the message text.
+     * @param messageType type of the message.
+     * @param isRead ture if the message has been read. Otherwise false.
+     * @param date the date the message was received.
+     * @return true for succeess. Otherwise false.
+     */
+    private boolean insertMessageToIcc(int subId, String scAddress, String address, String message,
+            int messageType, boolean isRead, long date) {
+        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+            throw new IllegalArgumentException("Invalid Subscription ID " + subId);
+        }
+        SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
+
+        int status = getMessageStatusForIcc(messageType, isRead);
+        SmsMessage.SubmitPdu smsPdu =
+                SmsMessage.getSmsPdu(subId, status, scAddress, address, message, date);
+
+        if (smsPdu == null) {
+            throw new IllegalArgumentException("Failed to create SMS PDU");
+        }
+
+        // Use phone app permissions to avoid UID mismatch in AppOpsManager.noteOp() call.
+        long token = Binder.clearCallingIdentity();
+        try {
+            return smsManager.copyMessageToIcc(
+                    smsPdu.encodedScAddress, smsPdu.encodedMessage, status);
+        } finally {
+            Binder.restoreCallingIdentity(token);
+        }
+    }
+
     @Override
     public int delete(Uri url, String where, String[] whereArgs) {
         int count;
@@ -734,9 +873,30 @@
                 break;
 
             case SMS_ICC:
-                String messageIndexString = url.getPathSegments().get(1);
-
-                return deleteMessageFromIcc(messageIndexString);
+            case SMS_ICC_SUBID:
+                int subId;
+                int messageIndex;
+                boolean success;
+                try {
+                    if (match == SMS_ICC) {
+                        subId = SmsManager.getDefaultSmsSubscriptionId();
+                        messageIndex = Integer.parseInt(url.getPathSegments().get(1));
+                    } else {
+                        subId = Integer.parseInt(url.getPathSegments().get(1));
+                        messageIndex = Integer.parseInt(url.getPathSegments().get(2));
+                    }
+                } catch (NumberFormatException e) {
+                    throw new IllegalArgumentException("Wrong path segements, uri= " + url);
+                }
+                success = deleteMessageFromIcc(subId, messageIndex);
+                // Notify changes even failure case since there might be some changes should be
+                // known.
+                getContext().getContentResolver().notifyChange(
+                        match == SMS_ICC ? ICC_URI : ICC_SUBID_URI,
+                        null,
+                        true,
+                        UserHandle.USER_ALL);
+                return success ? 1 : 0; // return deleted count
 
             default:
                 throw new IllegalArgumentException("Unknown URL");
@@ -749,24 +909,23 @@
     }
 
     /**
-     * Delete the message at index from ICC.  Return true iff
-     * successful.
+     * Deletes the message at index from the ICC for a subscription ID.
+     *
+     * @param subId the subscription ID.
+     * @param messageIndex the message index of the message in the ICC.
+     * @return true for succeess. Otherwise false.
      */
-    private int deleteMessageFromIcc(String messageIndexString) {
-        SmsManager smsManager = SmsManager.getDefault();
-        // Use phone id to avoid AppOps uid mismatch in telephony
+    private boolean deleteMessageFromIcc(int subId, int messageIndex) {
+        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+            throw new IllegalArgumentException("Invalid Subscription ID " + subId);
+        }
+        SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
+
+        // Use phone app permissions to avoid UID mismatch in AppOpsManager.noteOp() call.
         long token = Binder.clearCallingIdentity();
         try {
-            return smsManager.deleteMessageFromIcc(
-                    Integer.parseInt(messageIndexString))
-                    ? 1 : 0;
-        } catch (NumberFormatException exception) {
-            throw new IllegalArgumentException(
-                    "Bad SMS ICC ID: " + messageIndexString);
+            return smsManager.deleteMessageFromIcc(messageIndex);
         } finally {
-            ContentResolver cr = getContext().getContentResolver();
-            cr.notifyChange(ICC_URI, null, true, UserHandle.USER_ALL);
-
             Binder.restoreCallingIdentity(token);
         }
     }
@@ -910,6 +1069,8 @@
     private static final int SMS_QUEUED = 26;
     private static final int SMS_UNDELIVERED = 27;
     private static final int SMS_RAW_MESSAGE_PERMANENT_DELETE = 28;
+    private static final int SMS_ALL_ICC_SUBID = 29;
+    private static final int SMS_ICC_SUBID = 30;
 
     private static final UriMatcher sURLMatcher =
             new UriMatcher(UriMatcher.NO_MATCH);
@@ -941,6 +1102,8 @@
         sURLMatcher.addURI("sms", "sr_pending", SMS_STATUS_PENDING);
         sURLMatcher.addURI("sms", "icc", SMS_ALL_ICC);
         sURLMatcher.addURI("sms", "icc/#", SMS_ICC);
+        sURLMatcher.addURI("sms", "icc_subId/#", SMS_ALL_ICC_SUBID);
+        sURLMatcher.addURI("sms", "icc_subId/#/#", SMS_ICC_SUBID);
         //we keep these for not breaking old applications
         sURLMatcher.addURI("sms", "sim", SMS_ALL_ICC);
         sURLMatcher.addURI("sms", "sim/#", SMS_ICC);
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 1472156..a478aa6 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 = 43 << 16;
+    private static final int DATABASE_VERSION = 44 << 16;
     private static final int URL_UNKNOWN = 0;
     private static final int URL_TELEPHONY = 1;
     private static final int URL_CURRENT = 2;
@@ -235,7 +235,7 @@
     private static final String IS_NOT_OWNED_BY_DPC = OWNED_BY + "!=" + OWNED_BY_DPC;
 
     private static final String ORDER_BY_SUB_ID =
-            SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + " ASC";
+            Telephony.SimInfo.UNIQUE_KEY_SUBSCRIPTION_ID + " ASC";
 
     private static final int INVALID_APN_ID = -1;
     private static final List<String> CARRIERS_UNIQUE_FIELDS = new ArrayList<String>();
@@ -402,67 +402,67 @@
     @VisibleForTesting
     public static String getStringForSimInfoTableCreation(String tableName) {
         return "CREATE TABLE " + tableName + "("
-                + SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID
+                + Telephony.SimInfo.UNIQUE_KEY_SUBSCRIPTION_ID
                 + " INTEGER PRIMARY KEY AUTOINCREMENT,"
-                + SubscriptionManager.ICC_ID + " TEXT NOT NULL,"
-                + SubscriptionManager.SIM_SLOT_INDEX
-                + " INTEGER DEFAULT " + SubscriptionManager.SIM_NOT_INSERTED + ","
-                + SubscriptionManager.DISPLAY_NAME + " TEXT,"
-                + SubscriptionManager.CARRIER_NAME + " TEXT,"
-                + SubscriptionManager.NAME_SOURCE
-                + " INTEGER DEFAULT " + SubscriptionManager.NAME_SOURCE_DEFAULT_SOURCE + ","
-                + SubscriptionManager.COLOR + " INTEGER DEFAULT "
-                + SubscriptionManager.COLOR_DEFAULT + ","
-                + SubscriptionManager.NUMBER + " TEXT,"
-                + SubscriptionManager.DISPLAY_NUMBER_FORMAT
-                + " INTEGER NOT NULL DEFAULT " + SubscriptionManager.DISPLAY_NUMBER_DEFAULT + ","
-                + SubscriptionManager.DATA_ROAMING
-                + " INTEGER DEFAULT " + SubscriptionManager.DATA_ROAMING_DEFAULT + ","
-                + SubscriptionManager.MCC + " INTEGER DEFAULT 0,"
-                + SubscriptionManager.MNC + " INTEGER DEFAULT 0,"
-                + SubscriptionManager.MCC_STRING + " TEXT,"
-                + SubscriptionManager.MNC_STRING + " TEXT,"
-                + SubscriptionManager.EHPLMNS + " TEXT,"
-                + SubscriptionManager.HPLMNS + " TEXT,"
-                + SubscriptionManager.SIM_PROVISIONING_STATUS
-                + " INTEGER DEFAULT " + SubscriptionManager.SIM_PROVISIONED + ","
-                + SubscriptionManager.IS_EMBEDDED + " INTEGER DEFAULT 0,"
-                + SubscriptionManager.CARD_ID + " TEXT NOT NULL,"
-                + SubscriptionManager.ACCESS_RULES + " BLOB,"
-                + SubscriptionManager.ACCESS_RULES_FROM_CARRIER_CONFIGS + " BLOB,"
-                + SubscriptionManager.IS_REMOVABLE + " INTEGER DEFAULT 0,"
-                + SubscriptionManager.CB_EXTREME_THREAT_ALERT + " INTEGER DEFAULT 1,"
-                + SubscriptionManager.CB_SEVERE_THREAT_ALERT + " INTEGER DEFAULT 1,"
-                + SubscriptionManager.CB_AMBER_ALERT + " INTEGER DEFAULT 1,"
-                + SubscriptionManager.CB_EMERGENCY_ALERT + " INTEGER DEFAULT 1,"
-                + SubscriptionManager.CB_ALERT_SOUND_DURATION + " INTEGER DEFAULT 4,"
-                + SubscriptionManager.CB_ALERT_REMINDER_INTERVAL + " INTEGER DEFAULT 0,"
-                + SubscriptionManager.CB_ALERT_VIBRATE + " INTEGER DEFAULT 1,"
-                + SubscriptionManager.CB_ALERT_SPEECH + " INTEGER DEFAULT 1,"
-                + SubscriptionManager.CB_ETWS_TEST_ALERT + " INTEGER DEFAULT 0,"
-                + SubscriptionManager.CB_CHANNEL_50_ALERT + " INTEGER DEFAULT 1,"
-                + SubscriptionManager.CB_CMAS_TEST_ALERT + " INTEGER DEFAULT 0,"
-                + SubscriptionManager.CB_OPT_OUT_DIALOG + " INTEGER DEFAULT 1,"
-                + SubscriptionManager.ENHANCED_4G_MODE_ENABLED + " INTEGER DEFAULT -1,"
-                + SubscriptionManager.VT_IMS_ENABLED + " INTEGER DEFAULT -1,"
-                + SubscriptionManager.WFC_IMS_ENABLED + " INTEGER DEFAULT -1,"
-                + SubscriptionManager.WFC_IMS_MODE + " INTEGER DEFAULT -1,"
-                + SubscriptionManager.WFC_IMS_ROAMING_MODE + " INTEGER DEFAULT -1,"
-                + SubscriptionManager.WFC_IMS_ROAMING_ENABLED + " INTEGER DEFAULT -1,"
-                + SubscriptionManager.IS_OPPORTUNISTIC + " INTEGER DEFAULT 0,"
-                + SubscriptionManager.GROUP_UUID + " TEXT,"
-                + SubscriptionManager.IS_METERED + " INTEGER DEFAULT 1,"
-                + SubscriptionManager.ISO_COUNTRY_CODE + " TEXT,"
-                + SubscriptionManager.CARRIER_ID + " INTEGER DEFAULT -1,"
-                + SubscriptionManager.PROFILE_CLASS + " INTEGER DEFAULT "
-                + SubscriptionManager.PROFILE_CLASS_DEFAULT + ","
-                + SubscriptionManager.SUBSCRIPTION_TYPE + " INTEGER DEFAULT "
-                + SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM + ","
-                + SubscriptionManager.WHITE_LISTED_APN_DATA + " INTEGER DEFAULT 0,"
-                + SubscriptionManager.GROUP_OWNER + " TEXT,"
-                + SubscriptionManager.DATA_ENABLED_OVERRIDE_RULES + " TEXT,"
-                + SubscriptionManager.IMSI + " TEXT,"
-                + SubscriptionManager.UICC_APPLICATIONS_ENABLED + " INTEGER DEFAULT 1"
+                + Telephony.SimInfo.ICC_ID + " TEXT NOT NULL,"
+                + Telephony.SimInfo.SIM_SLOT_INDEX
+                + " INTEGER DEFAULT " + Telephony.SimInfo.SIM_NOT_INSERTED + ","
+                + Telephony.SimInfo.DISPLAY_NAME + " TEXT,"
+                + Telephony.SimInfo.CARRIER_NAME + " TEXT,"
+                + Telephony.SimInfo.NAME_SOURCE
+                + " INTEGER DEFAULT " + Telephony.SimInfo.NAME_SOURCE_DEFAULT + ","
+                + Telephony.SimInfo.COLOR + " INTEGER DEFAULT "
+                + Telephony.SimInfo.COLOR_DEFAULT + ","
+                + Telephony.SimInfo.NUMBER + " TEXT,"
+                + Telephony.SimInfo.DISPLAY_NUMBER_FORMAT
+                + " INTEGER NOT NULL DEFAULT " + Telephony.SimInfo.DISPLAY_NUMBER_DEFAULT + ","
+                + Telephony.SimInfo.DATA_ROAMING
+                + " INTEGER DEFAULT " + Telephony.SimInfo.DATA_ROAMING_DEFAULT + ","
+                + Telephony.SimInfo.MCC + " INTEGER DEFAULT 0,"
+                + Telephony.SimInfo.MNC + " INTEGER DEFAULT 0,"
+                + Telephony.SimInfo.MCC_STRING + " TEXT,"
+                + Telephony.SimInfo.MNC_STRING + " TEXT,"
+                + Telephony.SimInfo.EHPLMNS + " TEXT,"
+                + Telephony.SimInfo.HPLMNS + " TEXT,"
+                + Telephony.SimInfo.SIM_PROVISIONING_STATUS
+                + " INTEGER DEFAULT " + Telephony.SimInfo.SIM_PROVISIONED + ","
+                + Telephony.SimInfo.IS_EMBEDDED + " INTEGER DEFAULT 0,"
+                + Telephony.SimInfo.CARD_ID + " TEXT NOT NULL,"
+                + Telephony.SimInfo.ACCESS_RULES + " BLOB,"
+                + Telephony.SimInfo.ACCESS_RULES_FROM_CARRIER_CONFIGS + " BLOB,"
+                + Telephony.SimInfo.IS_REMOVABLE + " INTEGER DEFAULT 0,"
+                + Telephony.SimInfo.CB_EXTREME_THREAT_ALERT + " INTEGER DEFAULT 1,"
+                + Telephony.SimInfo.CB_SEVERE_THREAT_ALERT + " INTEGER DEFAULT 1,"
+                + Telephony.SimInfo.CB_AMBER_ALERT + " INTEGER DEFAULT 1,"
+                + Telephony.SimInfo.CB_EMERGENCY_ALERT + " INTEGER DEFAULT 1,"
+                + Telephony.SimInfo.CB_ALERT_SOUND_DURATION + " INTEGER DEFAULT 4,"
+                + Telephony.SimInfo.CB_ALERT_REMINDER_INTERVAL + " INTEGER DEFAULT 0,"
+                + Telephony.SimInfo.CB_ALERT_VIBRATE + " INTEGER DEFAULT 1,"
+                + Telephony.SimInfo.CB_ALERT_SPEECH + " INTEGER DEFAULT 1,"
+                + Telephony.SimInfo.CB_ETWS_TEST_ALERT + " INTEGER DEFAULT 0,"
+                + Telephony.SimInfo.CB_CHANNEL_50_ALERT + " INTEGER DEFAULT 1,"
+                + Telephony.SimInfo.CB_CMAS_TEST_ALERT + " INTEGER DEFAULT 0,"
+                + Telephony.SimInfo.CB_OPT_OUT_DIALOG + " INTEGER DEFAULT 1,"
+                + Telephony.SimInfo.ENHANCED_4G_MODE_ENABLED + " INTEGER DEFAULT -1,"
+                + Telephony.SimInfo.VT_IMS_ENABLED + " INTEGER DEFAULT -1,"
+                + Telephony.SimInfo.WFC_IMS_ENABLED + " INTEGER DEFAULT -1,"
+                + Telephony.SimInfo.WFC_IMS_MODE + " INTEGER DEFAULT -1,"
+                + Telephony.SimInfo.WFC_IMS_ROAMING_MODE + " INTEGER DEFAULT -1,"
+                + Telephony.SimInfo.WFC_IMS_ROAMING_ENABLED + " INTEGER DEFAULT -1,"
+                + Telephony.SimInfo.IS_OPPORTUNISTIC + " INTEGER DEFAULT 0,"
+                + Telephony.SimInfo.GROUP_UUID + " TEXT,"
+                + Telephony.SimInfo.IS_METERED + " INTEGER DEFAULT 1,"
+                + Telephony.SimInfo.ISO_COUNTRY_CODE + " TEXT,"
+                + Telephony.SimInfo.CARRIER_ID + " INTEGER DEFAULT -1,"
+                + Telephony.SimInfo.PROFILE_CLASS + " INTEGER DEFAULT "
+                + Telephony.SimInfo.PROFILE_CLASS_DEFAULT + ","
+                + Telephony.SimInfo.SUBSCRIPTION_TYPE + " INTEGER DEFAULT "
+                + Telephony.SimInfo.SUBSCRIPTION_TYPE_LOCAL_SIM + ","
+                + Telephony.SimInfo.GROUP_OWNER + " TEXT,"
+                + Telephony.SimInfo.DATA_ENABLED_OVERRIDE_RULES + " TEXT,"
+                + Telephony.SimInfo.IMSI + " TEXT,"
+                + Telephony.SimInfo.UICC_APPLICATIONS_ENABLED + " INTEGER DEFAULT 1,"
+                + Telephony.SimInfo.ALLOWED_NETWORK_TYPES + " BIGINT DEFAULT -1 "
                 + ");";
     }
 
@@ -900,9 +900,9 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE +
-                            " ADD COLUMN " + SubscriptionManager.MCC + " INTEGER DEFAULT 0;");
+                            " ADD COLUMN " + Telephony.SimInfo.MCC + " INTEGER DEFAULT 0;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE +
-                            " ADD COLUMN " + SubscriptionManager.MNC + " INTEGER DEFAULT 0;");
+                            " ADD COLUMN " + Telephony.SimInfo.MNC + " INTEGER DEFAULT 0;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -915,7 +915,7 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN " +
-                            SubscriptionManager.CARRIER_NAME + " TEXT DEFAULT '';");
+                            Telephony.SimInfo.CARRIER_NAME + " TEXT DEFAULT '';");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -998,29 +998,29 @@
                     // These columns may already be present in which case execSQL will throw an
                     // exception
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_EXTREME_THREAT_ALERT + " INTEGER DEFAULT 1;");
+                            + Telephony.SimInfo.CB_EXTREME_THREAT_ALERT + " INTEGER DEFAULT 1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_SEVERE_THREAT_ALERT + " INTEGER DEFAULT 1;");
+                            + Telephony.SimInfo.CB_SEVERE_THREAT_ALERT + " INTEGER DEFAULT 1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_AMBER_ALERT + " INTEGER DEFAULT 1;");
+                            + Telephony.SimInfo.CB_AMBER_ALERT + " INTEGER DEFAULT 1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_EMERGENCY_ALERT + " INTEGER DEFAULT 1;");
+                            + Telephony.SimInfo.CB_EMERGENCY_ALERT + " INTEGER DEFAULT 1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_ALERT_SOUND_DURATION + " INTEGER DEFAULT 4;");
+                            + Telephony.SimInfo.CB_ALERT_SOUND_DURATION + " INTEGER DEFAULT 4;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_ALERT_REMINDER_INTERVAL + " INTEGER DEFAULT 0;");
+                            + Telephony.SimInfo.CB_ALERT_REMINDER_INTERVAL + " INTEGER DEFAULT 0;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_ALERT_VIBRATE + " INTEGER DEFAULT 1;");
+                            + Telephony.SimInfo.CB_ALERT_VIBRATE + " INTEGER DEFAULT 1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_ALERT_SPEECH + " INTEGER DEFAULT 1;");
+                            + Telephony.SimInfo.CB_ALERT_SPEECH + " INTEGER DEFAULT 1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_ETWS_TEST_ALERT + " INTEGER DEFAULT 0;");
+                            + Telephony.SimInfo.CB_ETWS_TEST_ALERT + " INTEGER DEFAULT 0;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_CHANNEL_50_ALERT + " INTEGER DEFAULT 1;");
+                            + Telephony.SimInfo.CB_CHANNEL_50_ALERT + " INTEGER DEFAULT 1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_CMAS_TEST_ALERT + " INTEGER DEFAULT 0;");
+                            + Telephony.SimInfo.CB_CMAS_TEST_ALERT + " INTEGER DEFAULT 0;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.CB_OPT_OUT_DIALOG + " INTEGER DEFAULT 1;");
+                            + Telephony.SimInfo.CB_OPT_OUT_DIALOG + " INTEGER DEFAULT 1;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1054,8 +1054,8 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN " +
-                            SubscriptionManager.SIM_PROVISIONING_STATUS + " INTEGER DEFAULT " +
-                            SubscriptionManager.SIM_PROVISIONED + ";");
+                            Telephony.SimInfo.SIM_PROVISIONING_STATUS + " INTEGER DEFAULT " +
+                            Telephony.SimInfo.SIM_PROVISIONED + ";");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1073,11 +1073,11 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN " +
-                            SubscriptionManager.IS_EMBEDDED + " INTEGER DEFAULT 0;");
+                            Telephony.SimInfo.IS_EMBEDDED + " INTEGER DEFAULT 0;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN " +
-                            SubscriptionManager.ACCESS_RULES + " BLOB;");
+                            Telephony.SimInfo.ACCESS_RULES + " BLOB;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN " +
-                            SubscriptionManager.IS_REMOVABLE + " INTEGER DEFAULT 0;");
+                            Telephony.SimInfo.IS_REMOVABLE + " INTEGER DEFAULT 0;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1105,18 +1105,18 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.ENHANCED_4G_MODE_ENABLED
+                            + Telephony.SimInfo.ENHANCED_4G_MODE_ENABLED
                             + " INTEGER DEFAULT -1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.VT_IMS_ENABLED + " INTEGER DEFAULT -1;");
+                            + Telephony.SimInfo.VT_IMS_ENABLED + " INTEGER DEFAULT -1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.WFC_IMS_ENABLED + " INTEGER DEFAULT -1;");
+                            + Telephony.SimInfo.WFC_IMS_ENABLED + " INTEGER DEFAULT -1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.WFC_IMS_MODE + " INTEGER DEFAULT -1;");
+                            + Telephony.SimInfo.WFC_IMS_MODE + " INTEGER DEFAULT -1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.WFC_IMS_ROAMING_MODE + " INTEGER DEFAULT -1;");
+                            + Telephony.SimInfo.WFC_IMS_ROAMING_MODE + " INTEGER DEFAULT -1;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.WFC_IMS_ROAMING_ENABLED + " INTEGER DEFAULT -1;");
+                            + Telephony.SimInfo.WFC_IMS_ROAMING_ENABLED + " INTEGER DEFAULT -1;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + CARRIERS_TABLE + " upgrade. " +
@@ -1160,17 +1160,17 @@
                 // of the new column SubscriptionManager.CARD_ID, and replace the SIMINFO_TABLE with
                 // the new table.
                 Cursor c = null;
-                String[] proj = {SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID};
+                String[] proj = {Telephony.SimInfo.UNIQUE_KEY_SUBSCRIPTION_ID};
                 recreateSimInfoDB(c, db, proj);
                 if (VDBG) {
                     c = db.query(SIMINFO_TABLE, proj, null, null, null, null, null);
                     log("dbh.onUpgrade:- after upgrading " + SIMINFO_TABLE
                             + " total number of rows: " + c.getCount());
                     c.close();
-                    c = db.query(SIMINFO_TABLE, proj, SubscriptionManager.CARD_ID + " IS NOT NULL",
+                    c = db.query(SIMINFO_TABLE, proj, Telephony.SimInfo.CARD_ID + " IS NOT NULL",
                             null, null, null, null);
                     log("dbh.onUpgrade:- after upgrading total number of rows with "
-                            + SubscriptionManager.CARD_ID + ": " + c.getCount());
+                            + Telephony.SimInfo.CARD_ID + ": " + c.getCount());
                     c.close();
                 }
                 oldVersion = 25 << 16 | 6;
@@ -1196,9 +1196,9 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE +
-                            " ADD COLUMN " + SubscriptionManager.MCC_STRING + " TEXT;");
+                            " ADD COLUMN " + Telephony.SimInfo.MCC_STRING + " TEXT;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE +
-                            " ADD COLUMN " + SubscriptionManager.MNC_STRING + " TEXT;");
+                            " ADD COLUMN " + Telephony.SimInfo.MNC_STRING + " TEXT;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1206,8 +1206,8 @@
                     }
                 }
                 // Migrate the old integer values over to strings
-                String[] proj = {SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID,
-                        SubscriptionManager.MCC, SubscriptionManager.MNC};
+                String[] proj = {Telephony.SimInfo.UNIQUE_KEY_SUBSCRIPTION_ID,
+                        Telephony.SimInfo.MCC, Telephony.SimInfo.MNC};
                 try (Cursor c = db.query(SIMINFO_TABLE, proj, null, null, null, null, null)) {
                     while (c.moveToNext()) {
                         fillInMccMncStringAtCursor(mContext, db, c);
@@ -1220,7 +1220,7 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.IS_OPPORTUNISTIC + " INTEGER DEFAULT 0;");
+                            + Telephony.SimInfo.IS_OPPORTUNISTIC + " INTEGER DEFAULT 0;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1250,7 +1250,7 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                        + SubscriptionManager.GROUP_UUID + " TEXT;");
+                        + Telephony.SimInfo.GROUP_UUID + " TEXT;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1264,7 +1264,7 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.IS_METERED + " INTEGER DEFAULT 1;");
+                            + Telephony.SimInfo.IS_METERED + " INTEGER DEFAULT 1;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1278,7 +1278,7 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.ISO_COUNTRY_CODE + " TEXT;");
+                            + Telephony.SimInfo.ISO_COUNTRY_CODE + " TEXT;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1292,7 +1292,7 @@
                 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;");
+                            + Telephony.SimInfo.CARRIER_ID + " INTEGER DEFAULT -1;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1306,8 +1306,8 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN " +
-                            SubscriptionManager.PROFILE_CLASS + " INTEGER DEFAULT " +
-                            SubscriptionManager.PROFILE_CLASS_DEFAULT + ";");
+                            Telephony.SimInfo.PROFILE_CLASS + " INTEGER DEFAULT " +
+                            Telephony.SimInfo.PROFILE_CLASS_DEFAULT + ";");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1321,8 +1321,8 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                        + SubscriptionManager.SUBSCRIPTION_TYPE + " INTEGER DEFAULT "
-                        + SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM + ";");
+                        + Telephony.SimInfo.SUBSCRIPTION_TYPE + " INTEGER DEFAULT "
+                        + Telephony.SimInfo.SUBSCRIPTION_TYPE_LOCAL_SIM + ";");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1348,13 +1348,13 @@
             }
 
             if (oldVersion < (37 << 16 | 6)) {
-                // Add new columns SubscriptionManager.EHPLMNS and SubscriptionManager.HPLMNS into
+                // Add new columns Telephony.SimInfo.EHPLMNS and Telephony.SimInfo.HPLMNS into
                 // the database.
                 try {
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE +
-                            " ADD COLUMN " + SubscriptionManager.EHPLMNS + " TEXT;");
+                            " ADD COLUMN " + Telephony.SimInfo.EHPLMNS + " TEXT;");
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE +
-                            " ADD COLUMN " + SubscriptionManager.HPLMNS + " TEXT;");
+                            " ADD COLUMN " + Telephony.SimInfo.HPLMNS + " TEXT;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade for ehplmns. " +
@@ -1364,25 +1364,11 @@
                 oldVersion = 37 << 16 | 6;
             }
 
-            if (oldVersion < (38 << 16 | 6)) {
-                try {
-                    // Try to update the siminfo table. It might not be there.
-                    db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.WHITE_LISTED_APN_DATA + " INTEGER DEFAULT 0;");
-                } catch (SQLiteException e) {
-                    if (DBG) {
-                        log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
-                                "The table will get created in onOpen.");
-                    }
-                }
-                oldVersion = 38 << 16 | 6;
-            }
-
             if (oldVersion < (39 << 16 | 6)) {
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.GROUP_OWNER + " TEXT;");
+                            + Telephony.SimInfo.GROUP_OWNER + " TEXT;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1396,7 +1382,7 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.DATA_ENABLED_OVERRIDE_RULES + " TEXT;");
+                            + Telephony.SimInfo.DATA_ENABLED_OVERRIDE_RULES + " TEXT;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1410,7 +1396,7 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.IMSI + " TEXT;");
+                            + Telephony.SimInfo.IMSI + " TEXT;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1424,7 +1410,7 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN " +
-                        SubscriptionManager.ACCESS_RULES_FROM_CARRIER_CONFIGS + " BLOB;");
+                            Telephony.SimInfo.ACCESS_RULES_FROM_CARRIER_CONFIGS + " BLOB;");
                 } catch (SQLiteException e) {
                     if (DBG) {
                         log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
@@ -1437,7 +1423,7 @@
                 try {
                     // Try to update the siminfo table. It might not be there.
                     db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
-                            + SubscriptionManager.UICC_APPLICATIONS_ENABLED
+                            + Telephony.SimInfo.UICC_APPLICATIONS_ENABLED
                             + " INTEGER DEFAULT 1;");
                 } catch (SQLiteException e) {
                     if (DBG) {
@@ -1448,6 +1434,20 @@
                 oldVersion = 43 << 16 | 6;
             }
 
+            if (oldVersion < (44 << 16 | 6)) {
+                try {
+                    // Try to update the siminfo table. It might not be there.
+                    db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
+                            + Telephony.SimInfo.ALLOWED_NETWORK_TYPES
+                            + " BIGINT DEFAULT -1;");
+                } catch (SQLiteException e) {
+                    if (DBG) {
+                        log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
+                                "The table will get created in onOpen.");
+                    }
+                }
+                oldVersion = 44 << 16 | 6;
+            }
 
             if (DBG) {
                 log("dbh.onUpgrade:- db=" + db + " oldV=" + oldVersion + " newV=" + newVersion);
@@ -1512,51 +1512,51 @@
 
         private void copySimInfoValuesV24(ContentValues cv, Cursor c) {
             // String vals
-            getStringValueFromCursor(cv, c, SubscriptionManager.ICC_ID);
-            getStringValueFromCursor(cv, c, SubscriptionManager.DISPLAY_NAME);
-            getStringValueFromCursor(cv, c, SubscriptionManager.CARRIER_NAME);
-            getStringValueFromCursor(cv, c, SubscriptionManager.NUMBER);
+            getStringValueFromCursor(cv, c, Telephony.SimInfo.ICC_ID);
+            getStringValueFromCursor(cv, c, Telephony.SimInfo.DISPLAY_NAME);
+            getStringValueFromCursor(cv, c, Telephony.SimInfo.CARRIER_NAME);
+            getStringValueFromCursor(cv, c, Telephony.SimInfo.NUMBER);
 
             // bool/int vals
-            getIntValueFromCursor(cv, c, SubscriptionManager.SIM_SLOT_INDEX);
-            getIntValueFromCursor(cv, c, SubscriptionManager.NAME_SOURCE);
-            getIntValueFromCursor(cv, c, SubscriptionManager.COLOR);
-            getIntValueFromCursor(cv, c, SubscriptionManager.DISPLAY_NUMBER_FORMAT);
-            getIntValueFromCursor(cv, c, SubscriptionManager.DATA_ROAMING);
-            getIntValueFromCursor(cv, c, SubscriptionManager.MCC);
-            getIntValueFromCursor(cv, c, SubscriptionManager.MNC);
-            getIntValueFromCursor(cv, c, SubscriptionManager.SIM_PROVISIONING_STATUS);
-            getIntValueFromCursor(cv, c, SubscriptionManager.IS_EMBEDDED);
-            getIntValueFromCursor(cv, c, SubscriptionManager.IS_REMOVABLE);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_EXTREME_THREAT_ALERT);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_SEVERE_THREAT_ALERT);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_AMBER_ALERT);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_EMERGENCY_ALERT);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_ALERT_SOUND_DURATION);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_ALERT_REMINDER_INTERVAL);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_ALERT_VIBRATE);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_ALERT_SPEECH);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_ETWS_TEST_ALERT);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_CHANNEL_50_ALERT);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_CMAS_TEST_ALERT);
-            getIntValueFromCursor(cv, c, SubscriptionManager.CB_OPT_OUT_DIALOG);
-            getIntValueFromCursor(cv, c, SubscriptionManager.ENHANCED_4G_MODE_ENABLED);
-            getIntValueFromCursor(cv, c, SubscriptionManager.VT_IMS_ENABLED);
-            getIntValueFromCursor(cv, c, SubscriptionManager.WFC_IMS_ENABLED);
-            getIntValueFromCursor(cv, c, SubscriptionManager.WFC_IMS_MODE);
-            getIntValueFromCursor(cv, c, SubscriptionManager.WFC_IMS_ROAMING_MODE);
-            getIntValueFromCursor(cv, c, SubscriptionManager.WFC_IMS_ROAMING_ENABLED);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.SIM_SLOT_INDEX);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.NAME_SOURCE);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.COLOR);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.DISPLAY_NUMBER_FORMAT);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.DATA_ROAMING);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.MCC);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.MNC);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.SIM_PROVISIONING_STATUS);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.IS_EMBEDDED);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.IS_REMOVABLE);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_EXTREME_THREAT_ALERT);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_SEVERE_THREAT_ALERT);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_AMBER_ALERT);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_EMERGENCY_ALERT);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_ALERT_SOUND_DURATION);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_ALERT_REMINDER_INTERVAL);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_ALERT_VIBRATE);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_ALERT_SPEECH);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_ETWS_TEST_ALERT);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_CHANNEL_50_ALERT);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_CMAS_TEST_ALERT);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.CB_OPT_OUT_DIALOG);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.ENHANCED_4G_MODE_ENABLED);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.VT_IMS_ENABLED);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.WFC_IMS_ENABLED);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.WFC_IMS_MODE);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.WFC_IMS_ROAMING_MODE);
+            getIntValueFromCursor(cv, c, Telephony.SimInfo.WFC_IMS_ROAMING_ENABLED);
 
             // Blob vals
-            getBlobValueFromCursor(cv, c, SubscriptionManager.ACCESS_RULES);
+            getBlobValueFromCursor(cv, c, Telephony.SimInfo.ACCESS_RULES);
         }
 
         private void getCardIdfromIccid(ContentValues cv, Cursor c) {
-            int columnIndex = c.getColumnIndex(SubscriptionManager.ICC_ID);
+            int columnIndex = c.getColumnIndex(Telephony.SimInfo.ICC_ID);
             if (columnIndex != -1) {
                 String fromCursor = c.getString(columnIndex);
                 if (!TextUtils.isEmpty(fromCursor)) {
-                    cv.put(SubscriptionManager.CARD_ID, fromCursor);
+                    cv.put(Telephony.SimInfo.CARD_ID, fromCursor);
                 }
             }
         }
@@ -3811,33 +3811,33 @@
                                     | ContentResolver.NOTIFY_SKIP_NOTIFY_FOR_DESCENDANTS,
                             UserHandle.USER_ALL);
                     // notify observers on specific user settings changes.
-                    if (values.containsKey(SubscriptionManager.WFC_IMS_ENABLED)) {
+                    if (values.containsKey(Telephony.SimInfo.WFC_IMS_ENABLED)) {
                         getContext().getContentResolver().notifyChange(
                                 getNotifyContentUri(SubscriptionManager.WFC_ENABLED_CONTENT_URI,
                                         usingSubId, subId), null, true, UserHandle.USER_ALL);
                     }
-                    if (values.containsKey(SubscriptionManager.ENHANCED_4G_MODE_ENABLED)) {
+                    if (values.containsKey(Telephony.SimInfo.ENHANCED_4G_MODE_ENABLED)) {
                         getContext().getContentResolver().notifyChange(
                                 getNotifyContentUri(SubscriptionManager
                                                 .ADVANCED_CALLING_ENABLED_CONTENT_URI,
                                         usingSubId, subId), null, true, UserHandle.USER_ALL);
                     }
-                    if (values.containsKey(SubscriptionManager.VT_IMS_ENABLED)) {
+                    if (values.containsKey(Telephony.SimInfo.VT_IMS_ENABLED)) {
                         getContext().getContentResolver().notifyChange(
                                 getNotifyContentUri(SubscriptionManager.VT_ENABLED_CONTENT_URI,
                                         usingSubId, subId), null, true, UserHandle.USER_ALL);
                     }
-                    if (values.containsKey(SubscriptionManager.WFC_IMS_MODE)) {
+                    if (values.containsKey(Telephony.SimInfo.WFC_IMS_MODE)) {
                         getContext().getContentResolver().notifyChange(
                                 getNotifyContentUri(SubscriptionManager.WFC_MODE_CONTENT_URI,
                                         usingSubId, subId), null, true, UserHandle.USER_ALL);
                     }
-                    if (values.containsKey(SubscriptionManager.WFC_IMS_ROAMING_MODE)) {
+                    if (values.containsKey(Telephony.SimInfo.WFC_IMS_ROAMING_MODE)) {
                         getContext().getContentResolver().notifyChange(getNotifyContentUri(
                                 SubscriptionManager.WFC_ROAMING_MODE_CONTENT_URI,
                                 usingSubId, subId), null, true, UserHandle.USER_ALL);
                     }
-                    if (values.containsKey(SubscriptionManager.WFC_IMS_ROAMING_ENABLED)) {
+                    if (values.containsKey(Telephony.SimInfo.WFC_IMS_ROAMING_ENABLED)) {
                         getContext().getContentResolver().notifyChange(getNotifyContentUri(
                                 SubscriptionManager.WFC_ROAMING_ENABLED_CONTENT_URI,
                                 usingSubId, subId), null, true, UserHandle.USER_ALL);
@@ -3999,10 +3999,10 @@
         int mcc, mnc;
         String subId;
         try {
-            mcc = c.getInt(c.getColumnIndexOrThrow(SubscriptionManager.MCC));
-            mnc = c.getInt(c.getColumnIndexOrThrow(SubscriptionManager.MNC));
+            mcc = c.getInt(c.getColumnIndexOrThrow(Telephony.SimInfo.MCC));
+            mnc = c.getInt(c.getColumnIndexOrThrow(Telephony.SimInfo.MNC));
             subId = c.getString(c.getColumnIndexOrThrow(
-                    SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID));
+                    Telephony.SimInfo.UNIQUE_KEY_SUBSCRIPTION_ID));
         } catch (IllegalArgumentException e) {
             Log.e(TAG, "Possible database corruption -- some columns not found.");
             return;
@@ -4011,10 +4011,10 @@
         String mccString = String.format(Locale.getDefault(), "%03d", mcc);
         String mncString = getBestStringMnc(context, mccString, mnc);
         ContentValues cv = new ContentValues(2);
-        cv.put(SubscriptionManager.MCC_STRING, mccString);
-        cv.put(SubscriptionManager.MNC_STRING, mncString);
+        cv.put(Telephony.SimInfo.MCC_STRING, mccString);
+        cv.put(Telephony.SimInfo.MNC_STRING, mncString);
         db.update(SIMINFO_TABLE, cv,
-                SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=?",
+                Telephony.SimInfo.UNIQUE_KEY_SUBSCRIPTION_ID + "=?",
                 new String[]{subId});
     }
 
diff --git a/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java b/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
index 26df3c0..8ddd7f7 100644
--- a/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
@@ -25,6 +25,7 @@
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;
+import android.provider.Telephony;
 import android.telephony.SubscriptionManager;
 import android.text.TextUtils;
 import android.util.Log;
@@ -242,22 +243,22 @@
             Log.d(TAG, "InMemoryTelephonyProviderV5DbHelper onCreate creating the siminfo table");
             db.execSQL(
                     "CREATE TABLE siminfo ("
-                    + SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID
+                    + Telephony.SimInfo.UNIQUE_KEY_SUBSCRIPTION_ID
                     + " INTEGER PRIMARY KEY AUTOINCREMENT,"
-                    + SubscriptionManager.ICC_ID + " TEXT NOT NULL,"
-                    + SubscriptionManager.SIM_SLOT_INDEX
-                        + " INTEGER DEFAULT " + SubscriptionManager.SIM_NOT_INSERTED + ","
-                    + SubscriptionManager.DISPLAY_NAME + " TEXT,"
-                    + SubscriptionManager.NAME_SOURCE
-                        + " INTEGER DEFAULT " + SubscriptionManager.NAME_SOURCE_DEFAULT_SOURCE + ","
-                    + SubscriptionManager.COLOR
-                        + " INTEGER DEFAULT " + SubscriptionManager.COLOR_DEFAULT + ","
-                    + SubscriptionManager.NUMBER + " TEXT,"
-                    + SubscriptionManager.DISPLAY_NUMBER_FORMAT + " INTEGER NOT NULL"
-                        + " DEFAULT " + SubscriptionManager.DISPLAY_NUMBER_DEFAULT + ","
-                    + SubscriptionManager.DATA_ROAMING
-                        + " INTEGER DEFAULT " + SubscriptionManager.DATA_ROAMING_DEFAULT + ","
-                    + SubscriptionManager.CARD_ID + " TEXT NOT NULL"
+                    + Telephony.SimInfo.ICC_ID + " TEXT NOT NULL,"
+                    + Telephony.SimInfo.SIM_SLOT_INDEX
+                        + " INTEGER DEFAULT " + Telephony.SimInfo.SIM_NOT_INSERTED + ","
+                    + Telephony.SimInfo.DISPLAY_NAME + " TEXT,"
+                    + Telephony.SimInfo.NAME_SOURCE
+                        + " INTEGER DEFAULT " + Telephony.SimInfo.NAME_SOURCE_DEFAULT + ","
+                    + Telephony.SimInfo.COLOR
+                        + " INTEGER DEFAULT " + Telephony.SimInfo.COLOR_DEFAULT + ","
+                    + Telephony.SimInfo.NUMBER + " TEXT,"
+                    + Telephony.SimInfo.DISPLAY_NUMBER_FORMAT + " INTEGER NOT NULL"
+                        + " DEFAULT " + Telephony.SimInfo.DISPLAY_NUMBER_DEFAULT + ","
+                    + Telephony.SimInfo.DATA_ROAMING
+                        + " INTEGER DEFAULT " + Telephony.SimInfo.DATA_ROAMING_DEFAULT + ","
+                    + Telephony.SimInfo.CARD_ID + " TEXT NOT NULL"
                     + ");");
         }
 
diff --git a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
index efd5120..340e2af 100644
--- a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
@@ -1454,7 +1454,7 @@
 
         // update wfc_enabled
         ContentValues values = new ContentValues();
-        values.put(SubscriptionManager.WFC_IMS_ENABLED, true);
+        values.put(Telephony.SimInfo.WFC_IMS_ENABLED, true);
         final String selection = SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=?";
         final String[] selectionArgs = { "" + insertSubId };
         mContentResolver.update(SimInfo.CONTENT_URI, values, selection, selectionArgs);
@@ -1471,7 +1471,7 @@
 
         // update WFC using subId
         values = new ContentValues();
-        values.put(SubscriptionManager.WFC_IMS_ENABLED, false);
+        values.put(Telephony.SimInfo.WFC_IMS_ENABLED, false);
         mContentResolver.update(SubscriptionManager.getUriForSubscriptionId(insertSubId),
                 values, null, null);
         assertEquals(1, notifyWfcCount);