Merge "Add compatibility change preference"
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 70b92c9..d180b70 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -536,4 +536,60 @@
         icons.setTintList(Utils.getColorAttr(context, android.R.attr.colorControlNormal));
         return icons;
     }
+
+    /**
+     * This method is migrated from
+     * {@link android.telephony.TelephonyManager.getNetworkOperatorName}. Which provides
+     *
+     * 1. Better support under multi-SIM environment.
+     * 2. Similar design which aligned with operator name displayed in status bar
+     */
+    public static CharSequence getCurrentCarrierNameForDisplay(Context context, int subId) {
+        SubscriptionManager sm = context.getSystemService(SubscriptionManager.class);
+        if (sm != null) {
+            SubscriptionInfo subInfo = getSubscriptionInfo(sm, subId);
+            if (subInfo != null) {
+                return subInfo.getCarrierName();
+            }
+        }
+        return getOperatorNameFromTelephonyManager(context);
+    }
+
+    public static CharSequence getCurrentCarrierNameForDisplay(Context context) {
+        SubscriptionManager sm = context.getSystemService(SubscriptionManager.class);
+        if (sm != null) {
+            int subId = sm.getDefaultSubscriptionId();
+            SubscriptionInfo subInfo = getSubscriptionInfo(sm, subId);
+            if (subInfo != null) {
+                return subInfo.getCarrierName();
+            }
+        }
+        return getOperatorNameFromTelephonyManager(context);
+    }
+
+    private static SubscriptionInfo getSubscriptionInfo(SubscriptionManager subManager,
+            int subId) {
+        List<SubscriptionInfo> subInfos = subManager.getAccessibleSubscriptionInfoList();
+        if (subInfos == null) {
+            subInfos = subManager.getActiveSubscriptionInfoList();
+        }
+        if (subInfos == null) {
+            return null;
+        }
+        for (SubscriptionInfo subInfo : subInfos) {
+            if (subInfo.getSubscriptionId() == subId) {
+                return subInfo;
+            }
+        }
+        return null;
+    }
+
+    private static String getOperatorNameFromTelephonyManager(Context context) {
+        TelephonyManager tm =
+                (TelephonyManager) context.getSystemService(TelephonyManager.class);
+        if (tm == null) {
+            return null;
+        }
+        return tm.getNetworkOperatorName();
+    }
 }
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSoftApManager.java b/src/com/android/settings/wifi/tether/WifiTetherSoftApManager.java
index 3de5869..2db037f 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSoftApManager.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSoftApManager.java
@@ -36,7 +36,7 @@
     }
 
     public void registerSoftApCallback() {
-        mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(mHandler));
+        mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), mSoftApCallback);
     }
 
     public void unRegisterSoftApCallback() {
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index 28c987b..263f83d 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -59,6 +59,7 @@
 
     static_libs: [
         "SettingsLib-robo-testutils",
+	"app-compat-annotations",
     ],
 
     java_resource_dirs: ["config"],