diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index a625b47..a0a237d 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -195,6 +195,7 @@
     private INetworkStatsService mStatsService;
     private NetworkPolicyManager mPolicyManager;
     private TelephonyManager mTelephonyManager;
+    private SubscriptionManager mSubscriptionManager;
 
     private INetworkStatsSession mStatsSession;
 
@@ -286,13 +287,14 @@
                 ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
         mPolicyManager = NetworkPolicyManager.from(context);
         mTelephonyManager = TelephonyManager.from(context);
+        mSubscriptionManager = SubscriptionManager.from(context);
 
         mPrefs = getActivity().getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE);
 
         mPolicyEditor = new NetworkPolicyEditor(mPolicyManager);
         mPolicyEditor.read();
 
-        mSubInfoList = SimSettings.getSortedSubInfoList(getActivity());
+        mSubInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
         mMobileTagMap = initMobileTabTag(mSubInfoList);
 
         try {
@@ -942,7 +944,7 @@
         } else {
             //SUB SELECT
             isEnable = mTelephonyManager.getDataEnabled()
-                && (subId == SubscriptionManager.getDefaultDataSubId());
+                && (subId == mSubscriptionManager.getDefaultDataSubId());
         }
         return isEnable;
     }
@@ -1131,8 +1133,8 @@
 
     private void handleMultiSimDataDialog() {
         final SubscriptionInfo currentSir = getCurrentTabSubInfo(getActivity());
-        final SubscriptionInfo nextSir = SubscriptionManager.getSubscriptionInfoForSubscriber(
-                SubscriptionManager.getDefaultDataSubId());
+        final SubscriptionInfo nextSir = mSubscriptionManager.getActiveSubscriptionInfo(
+                mSubscriptionManager.getDefaultDataSubId());
 
         if (currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
             setMobileDataEnabled(true);
@@ -1149,7 +1151,7 @@
         builder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int id) {
-                SubscriptionManager.setDefaultDataSubId(currentSir.getSubscriptionId());
+                mSubscriptionManager.setDefaultDataSubId(currentSir.getSubscriptionId());
                 setMobileDataEnabled(true);
                 updateBody();
             }
@@ -2246,7 +2248,7 @@
         final NetworkTemplate template = intent.getParcelableExtra(EXTRA_NETWORK_TEMPLATE);
         if (template == null) {
             final int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
-                    SubscriptionManager.INVALID_SUB_ID);
+                    SubscriptionManager.INVALID_SUBSCRIPTION_ID);
             if (SubscriptionManager.isValidSubId(subId)) {
                 return TAB_MOBILE + String.valueOf(subId);
             }
@@ -2339,8 +2341,9 @@
         final ConnectivityManager conn = ConnectivityManager.from(context);
         final TelephonyManager tele = TelephonyManager.from(context);
 
-        final List<SubscriptionInfo> subInfoList = SubscriptionManager.getActiveSubscriptionInfoList();
-        // No activated Subscription
+        final List<SubscriptionInfo> subInfoList =
+                SubscriptionManager.from(context).getActiveSubscriptionInfoList();
+        // No activated Subscriptions
         if (subInfoList == null) {
             return false;
         }
@@ -2586,7 +2589,7 @@
         };
 
         private void addMobileTab(Context context, List<SubscriptionInfo> subInfoList) {
-            if (subInfoList != null) {
+            if (subInfoList != null && mMobileTagMap != null) {
                 for (SubscriptionInfo subInfo : mSubInfoList) {
                     if (hasReadyMobileRadio(context, subInfo.getSubscriptionId())) {
                         mTabHost.addTab(buildTabSpec(mMobileTagMap.get(subInfo.getSubscriptionId()),
@@ -2634,10 +2637,12 @@
         }
 
         private int getSubId(String currentTab) {
-            Set<Integer> set = mMobileTagMap.keySet();
-            for (Integer subId : set) {
-                if (mMobileTagMap.get(subId).equals(currentTab)) {
-                    return subId;
+            if (mMobileTagMap != null) {
+                Set<Integer> set = mMobileTagMap.keySet();
+                for (Integer subId : set) {
+                    if (mMobileTagMap.get(subId).equals(currentTab)) {
+                        return subId;
+                    }
                 }
             }
             Log.e(TAG, "currentTab = " + currentTab + " non mobile tab called this function");
diff --git a/src/com/android/settings/IccLockSettings.java b/src/com/android/settings/IccLockSettings.java
index d8744cc..cfe27bb 100644
--- a/src/com/android/settings/IccLockSettings.java
+++ b/src/com/android/settings/IccLockSettings.java
@@ -215,7 +215,7 @@
             mTabHost.clearAllTabs();
 
             for (int i = 0; i < numSims; ++i) {
-                final SubscriptionInfo subInfo = Utils.findRecordBySlotId(i);
+                final SubscriptionInfo subInfo = Utils.findRecordBySlotId(this, i);
                 mTabHost.addTab(buildTabSpec(String.valueOf(i),
                         String.valueOf(subInfo == null
                             ? context.getString(R.string.sim_editor_title, i + 1)
@@ -469,7 +469,7 @@
         @Override
         public void onTabChanged(String tabId) {
             final int slotId = Integer.parseInt(tabId);
-            final SubscriptionInfo sir = Utils.findRecordBySlotId(slotId);
+            final SubscriptionInfo sir = Utils.findRecordBySlotId(getBaseContext(), slotId);
 
             mPhone = (sir == null) ? null
                 : PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId()));
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index ab39689..5f74ff6 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -111,6 +111,7 @@
     private static final boolean ONLY_ONE_TRUST_AGENT = true;
 
     private DevicePolicyManager mDPM;
+    private SubscriptionManager mSubscriptionManager;
 
     private ChooseLockSettingsHelper mChooseLockSettingsHelper;
     private LockPatternUtils mLockPatternUtils;
@@ -136,6 +137,8 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
+        mSubscriptionManager = SubscriptionManager.from(getActivity());
+
         mLockPatternUtils = new LockPatternUtils(getActivity());
 
         mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
@@ -370,9 +373,10 @@
     /* Return true if a SIM is ready for locking.
      * TODO: consider adding to TelephonyManager or SubscritpionManasger.
      */
-    private static boolean isSimReady() {
+    private boolean isSimReady() {
         int simState = TelephonyManager.SIM_STATE_UNKNOWN;
-        final List<SubscriptionInfo> subInfoList = SubscriptionManager.getActiveSubscriptionInfoList();
+        final List<SubscriptionInfo> subInfoList =
+                mSubscriptionManager.getActiveSubscriptionInfoList();
         if (subInfoList != null) {
             for (SubscriptionInfo subInfo : subInfoList) {
                 simState = TelephonyManager.getDefault().getSimState(subInfo.getSimSlotIndex());
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index dc9e8a2..ad54c6b 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -988,15 +988,17 @@
      * finds a record with subId.
      * Since the number of SIMs are few, an array is fine.
      */
-    public static SubscriptionInfo findRecordBySubId(final int subId) {
+    public static SubscriptionInfo findRecordBySubId(Context context, final int subId) {
         final List<SubscriptionInfo> subInfoList =
-                SubscriptionManager.getActiveSubscriptionInfoList();
-        final int subInfoLength = subInfoList.size();
+                SubscriptionManager.from(context).getActiveSubscriptionInfoList();
+        if (subInfoList != null) {
+            final int subInfoLength = subInfoList.size();
 
-        for (int i = 0; i < subInfoLength; ++i) {
-            final SubscriptionInfo sir = subInfoList.get(i);
-            if (sir != null && sir.getSubscriptionId() == subId) {
-                return sir;
+            for (int i = 0; i < subInfoLength; ++i) {
+                final SubscriptionInfo sir = subInfoList.get(i);
+                if (sir != null && sir.getSubscriptionId() == subId) {
+                    return sir;
+                }
             }
         }
 
@@ -1007,16 +1009,18 @@
      * finds a record with slotId.
      * Since the number of SIMs are few, an array is fine.
      */
-    public static SubscriptionInfo findRecordBySlotId(final int slotId) {
+    public static SubscriptionInfo findRecordBySlotId(Context context, final int slotId) {
         final List<SubscriptionInfo> subInfoList =
-                SubscriptionManager.getActiveSubscriptionInfoList();
-        final int subInfoLength = subInfoList.size();
+                SubscriptionManager.from(context).getActiveSubscriptionInfoList();
+        if (subInfoList != null) {
+            final int subInfoLength = subInfoList.size();
 
-        for (int i = 0; i < subInfoLength; ++i) {
-            final SubscriptionInfo sir = subInfoList.get(i);
-            if (sir.getSimSlotIndex() == slotId) {
-                //Right now we take the first subscription on a SIM.
-                return sir;
+            for (int i = 0; i < subInfoLength; ++i) {
+                final SubscriptionInfo sir = subInfoList.get(i);
+                if (sir.getSimSlotIndex() == slotId) {
+                    //Right now we take the first subscription on a SIM.
+                    return sir;
+                }
             }
         }
 
diff --git a/src/com/android/settings/deviceinfo/ImeiInformation.java b/src/com/android/settings/deviceinfo/ImeiInformation.java
index 921ef8e..72d3158 100644
--- a/src/com/android/settings/deviceinfo/ImeiInformation.java
+++ b/src/com/android/settings/deviceinfo/ImeiInformation.java
@@ -42,9 +42,12 @@
     private static final String KEY_IMEI = "imei";
     private static final String KEY_IMEI_SV = "imei_sv";
 
+    private SubscriptionManager mSubscriptionManager;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        mSubscriptionManager = SubscriptionManager.from(this);
         final TelephonyManager telephonyManager =
             (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
         initPreferenceScreen(telephonyManager.getSimCount());
@@ -100,17 +103,17 @@
         }
     }
 
-    private Phone getPhoneFromSlotId(int slotId) {
-        final List<SubscriptionInfo> subInfos = SubscriptionManager.getSubscriptionInfoUsingSlotId(slotId);
+    private Phone getPhoneFromSlotId(int slotIdx) {
+        final SubscriptionInfo subInfo =
+                mSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(slotIdx);
 
-        if (subInfos == null || subInfos.size() < 1) {
+        if (subInfo == null) {
             return null;
         }
 
         final Phone[] phones = PhoneFactory.getPhones();
         for (int i = 0; i < phones.length; i++) {
-            // Currently we only operate with the first subscription of a SIM.
-            if (phones[i].getSubId() == subInfos.get(0).getSubscriptionId()) {
+            if (phones[i].getSubId() == subInfo.getSubscriptionId()) {
                 return phones[i];
             }
         }
diff --git a/src/com/android/settings/deviceinfo/SimStatus.java b/src/com/android/settings/deviceinfo/SimStatus.java
index 46addf3..11daf0c 100644
--- a/src/com/android/settings/deviceinfo/SimStatus.java
+++ b/src/com/android/settings/deviceinfo/SimStatus.java
@@ -11,7 +11,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
-￼* limitations under the License.
+ * limitations under the License.
  */
 
 package com.android.settings.deviceinfo;
@@ -143,7 +143,7 @@
         mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH);
 
         for (int i = 0; i < mTelephonyManager.getSimCount(); i++) {
-            final SubscriptionInfo sir = Utils.findRecordBySlotId(i);
+            final SubscriptionInfo sir = Utils.findRecordBySlotId(this, i);
             if (sir != null) {
                 mSelectableSubInfos.add(sir);
             }
@@ -355,7 +355,7 @@
         final Phone phone = PhoneFactory.getPhone(SubscriptionManager.getPhoneId(
                         mSir.getSubscriptionId()));
         if (UserHandle.myUserId() == UserHandle.USER_OWNER
-                && mSir.getSubscriptionId() != SubscriptionManager.INVALID_SUB_ID) {
+                && mSir.getSubscriptionId() != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             if (phone == null) {
                 Log.e(TAG, "Unable to locate a phone object for the given Subscription ID.");
                 return;
diff --git a/src/com/android/settings/sim/SimBootReceiver.java b/src/com/android/settings/sim/SimBootReceiver.java
index 2d9d15e..d3fb996 100644
--- a/src/com/android/settings/sim/SimBootReceiver.java
+++ b/src/com/android/settings/sim/SimBootReceiver.java
@@ -19,8 +19,6 @@
 import com.android.settings.R;
 import com.android.settings.Settings.SimSettingsActivity;
 
-import java.util.List;
-
 import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
@@ -31,13 +29,14 @@
 import android.content.res.Resources;
 import android.support.v4.app.NotificationCompat;
 import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionListener;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
-import android.util.Log;
+import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
 
 import com.android.settings.Utils;
 
+import java.util.List;
+
 public class SimBootReceiver extends BroadcastReceiver {
     private static final int SLOT_EMPTY = -1;
     private static final int NOTIFICATION_ID = 1;
@@ -47,16 +46,17 @@
     private SharedPreferences mSharedPreferences = null;
     private TelephonyManager mTelephonyManager;
     private Context mContext;
+    private SubscriptionManager mSubscriptionManager;
 
     @Override
     public void onReceive(Context context, Intent intent) {
         mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
         mContext = context;
+        mSubscriptionManager = SubscriptionManager.from(mContext);
         mSharedPreferences = mContext.getSharedPreferences(SHARED_PREFERENCES_NAME,
                 Context.MODE_PRIVATE);
 
-        SubscriptionManager.register(mContext, mSubscriptionListener,
-                SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED);
+        mSubscriptionManager.registerOnSubscriptionsChangedListener(mSubscriptionListener);
     }
 
     private void detectChangeAndNotify() {
@@ -71,12 +71,13 @@
         // by checking if the list is empty.
         // This is not completely correct, but works for most cases.
         // See Bug: 18377252
-        if (SubscriptionManager.getActiveSubscriptionInfoList().size() < 1) {
+        List<SubscriptionInfo> sil = mSubscriptionManager.getActiveSubscriptionInfoList();
+        if (sil == null || sil.size() < 1) {
             return;
         }
 
         for (int i = 0; i < numSlots; i++) {
-            final SubscriptionInfo sir = Utils.findRecordBySlotId(i);
+            final SubscriptionInfo sir = Utils.findRecordBySlotId(mContext, i);
             final String key = SLOT_PREFIX+i;
             final int lastSubId = getLastSubId(key);
 
@@ -133,9 +134,10 @@
         notificationManager.cancel(NOTIFICATION_ID);
     }
 
-    private final SubscriptionListener mSubscriptionListener = new SubscriptionListener() {
+    private final OnSubscriptionsChangedListener mSubscriptionListener =
+            new OnSubscriptionsChangedListener() {
         @Override
-        public void onSubscriptionInfoChanged() {
+        public void onSubscriptionsChanged() {
             detectChangeAndNotify();
         }
     };
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index 682f722..3869cd3 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -69,6 +69,7 @@
 
 public class SimSettings extends RestrictedSettingsFragment implements Indexable {
     private static final String TAG = "SimSettings";
+    private static final boolean DBG = false;
 
     private static final String DISALLOW_CONFIG_SIM = "no_config_sim";
     private static final String SIM_CARD_CATEGORY = "sim_cards";
@@ -118,6 +119,9 @@
 
     private PreferenceCategory mSimCards = null;
 
+    private SubscriptionManager mSubscriptionManager;
+    private Utils mUtils;
+
     public SimSettings() {
         super(DISALLOW_CONFIG_SIM);
     }
@@ -126,9 +130,13 @@
     public void onCreate(final Bundle bundle) {
         super.onCreate(bundle);
 
+        mSubscriptionManager = SubscriptionManager.from(getActivity());
+
         if (mSubInfoList == null) {
-            mSubInfoList = SubscriptionManager.getActiveSubscriptionInfoList();
+            mSubInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
+            // FIXME: b/18385348, needs to handle null from getActiveSubscriptionInfoList
         }
+        if (DBG) log("[onCreate] mSubInfoList=" + mSubInfoList);
 
         createPreferences();
         updateAllOptions();
@@ -148,7 +156,7 @@
         mAvailableSubInfos = new ArrayList<SubscriptionInfo>(numSlots);
         mSelectableSubInfos = new ArrayList<SubscriptionInfo>();
         for (int i = 0; i < numSlots; ++i) {
-            final SubscriptionInfo sir = Utils.findRecordBySlotId(i);
+            final SubscriptionInfo sir = Utils.findRecordBySlotId(getActivity(), i);
             mSimCards.addPreference(new SimPreference(getActivity(), sir, i));
             mAvailableSubInfos.add(sir);
             if (sir != null) {
@@ -166,7 +174,7 @@
 
         mAvailableSubInfos = new ArrayList<SubscriptionInfo>(numSlots);
         for (int i = 0; i < numSlots; ++i) {
-            final SubscriptionInfo sir = Utils.findRecordBySlotId(i);
+            final SubscriptionInfo sir = Utils.findRecordBySlotId(getActivity(), i);
             mAvailableSubInfos.add(sir);
             if (sir != null) {
             }
@@ -179,7 +187,7 @@
     }
 
     private void updateSimSlotValues() {
-        SubscriptionManager.getAllSubscriptionInfoList();
+        mSubscriptionManager.getAllSubscriptionInfoList();
 
         final int prefSize = mSimCards.getPreferenceCount();
         for (int i = 0; i < prefSize; ++i) {
@@ -198,9 +206,11 @@
 
     private void updateSmsValues() {
         final Preference simPref = findPreference(KEY_SMS);
-        final SubscriptionInfo sir = Utils.findRecordBySubId(SubscriptionManager.getDefaultSmsSubId());
+        final SubscriptionInfo sir = Utils.findRecordBySubId(getActivity(),
+                mSubscriptionManager.getDefaultSmsSubId());
         simPref.setTitle(R.string.sms_messages_title);
-        if (mSubInfoList.size() == 1) {
+        if (DBG) log("[updateSmsValues] mSubInfoList=" + mSubInfoList);
+        if (mSubInfoList != null && mSubInfoList.size() == 1) {
             simPref.setSummary(mSubInfoList.get(0).getDisplayName());
         } else if (sir != null) {
             simPref.setSummary(sir.getDisplayName());
@@ -212,9 +222,12 @@
 
     private void updateCellularDataValues() {
         final Preference simPref = findPreference(KEY_CELLULAR_DATA);
-        final SubscriptionInfo sir = Utils.findRecordBySubId(SubscriptionManager.getDefaultDataSubId());
+        final SubscriptionInfo sir = Utils.findRecordBySubId(getActivity(),
+                mSubscriptionManager.getDefaultDataSubId());
         simPref.setTitle(R.string.cellular_data_title);
-        if (mSubInfoList.size() == 1) {
+        if (DBG) log("[updateCellularDataValues] mSubInfoList=" + mSubInfoList);
+
+        if (mSubInfoList != null && mSubInfoList.size() == 1) {
             simPref.setSummary(mSubInfoList.get(0).getDisplayName());
         } else if (sir != null) {
             simPref.setSummary(sir.getDisplayName());
@@ -240,7 +253,10 @@
     public void onResume() {
         super.onResume();
 
-        mSubInfoList = SubscriptionManager.getActiveSubscriptionInfoList();
+        mSubInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
+        // FIXME: b/18385348, needs to handle null from getActiveSubscriptionInfoList
+        if (DBG) log("[onResme] mSubInfoList=" + mSubInfoList);
+
         updateAvailableSubInfos();
         updateAllOptions();
     }
@@ -275,7 +291,7 @@
 
                         if (id == DATA_PICK) {
                             sir = mSelectableSubInfos.get(value);
-                            SubscriptionManager.setDefaultDataSubId(sir.getSubscriptionId());
+                            mSubscriptionManager.setDefaultDataSubId(sir.getSubscriptionId());
                         } else if (id == CALLS_PICK) {
                             final TelecomManager telecomManager =
                                     TelecomManager.from(getActivity());
@@ -285,7 +301,7 @@
                                     value < 1 ? null : phoneAccountsList.get(value - 1));
                         } else if (id == SMS_PICK) {
                             sir = mSelectableSubInfos.get(value);
-                            SubscriptionManager.setDefaultSmsSubId(sir.getSubscriptionId());
+                            mSubscriptionManager.setDefaultSmsSubId(sir.getSubscriptionId());
                         }
 
                         updateActivitesCategory();
@@ -514,16 +530,16 @@
                     String displayName = nameText.getText().toString();
                     int subId = mSubInfoRecord.getSubscriptionId();
                     mSubInfoRecord.setDisplayName(displayName);
-                    SubscriptionManager.setDisplayName(displayName, subId,
+                    mSubscriptionManager.setDisplayName(displayName, subId,
                             SubscriptionManager.NAME_SOURCE_USER_INPUT);
-                    Utils.findRecordBySubId(subId).setDisplayName(displayName);
+                    Utils.findRecordBySubId(getActivity(), subId).setDisplayName(displayName);
 
                     final int tintSelected = tintSpinner.getSelectedItemPosition();
                     int subscriptionId = mSubInfoRecord.getSubscriptionId();
                     int tint = mTintArr[tintSelected];
                     mSubInfoRecord.setIconTint(tint);
-                    SubscriptionManager.setIconTint(tint, subscriptionId);
-                    Utils.findRecordBySubId(subscriptionId).setIconTint(tint);
+                    mSubscriptionManager.setIconTint(tint, subscriptionId);
+                    Utils.findRecordBySubId(getActivity(), subscriptionId).setIconTint(tint);
 
                     updateAllOptions();
                     update();
@@ -611,27 +627,8 @@
 
     }
 
-    /**
-     * Sort Subscription List in SIM Id, Subscription Id
-     * @param context The Context
-     * @return Sorted Subscription List or NULL if no activated Subscription
-     */
-    public static List<SubscriptionInfo> getSortedSubInfoList(Context context) {
-        List<SubscriptionInfo> infoList = SubscriptionManager.getActiveSubscriptionInfoList();
-        if (infoList != null) {
-            Collections.sort(infoList, new Comparator<SubscriptionInfo>() {
-
-                @Override
-                public int compare(SubscriptionInfo arg0, SubscriptionInfo arg1) {
-                    int flag = arg0.getSimSlotIndex() - arg1.getSimSlotIndex();
-                    if (flag == 0) {
-                        return arg0.getSubscriptionId() - arg1.getSubscriptionId();
-                    }
-                    return flag;
-                }
-            });
-        }
-        return infoList;
+    private void log(String s) {
+        Log.d(TAG, s);
     }
 
     /**
