diff options
author | Khalid Zubair <kzubair@cyngn.com> | 2015-12-04 11:02:29 -0800 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2016-07-08 13:00:32 -0700 |
commit | 95acd463594aae6fc3b707ff34d641e475fecb34 (patch) | |
tree | 34eb93ed1f59f7f7482e05bbc2cdd66aa60c5646 | |
parent | 1fcc0ddc855c0ffbbf41b351d8f63bf13a3beaa1 (diff) | |
download | frameworks_opt_net_wifi-95acd463594aae6fc3b707ff34d641e475fecb34.tar.gz frameworks_opt_net_wifi-95acd463594aae6fc3b707ff34d641e475fecb34.tar.bz2 frameworks_opt_net_wifi-95acd463594aae6fc3b707ff34d641e475fecb34.zip |
wifi: fixup hotspot disconnect on subscriber change
The hotspot should be disconnected only if the IMSI changes (for GSM
devices). SubscriptionInfo#getSubscriptionId() does not return the
IMSI and returns a handle used by the framework. Switch to using the
TelephonyManager#getSubscriberId().
Ticket: CYNGNOS-877, SAMBAR-1151
Change-Id: I7a00600497a9d884dda08a9969cf7f34f9054e2b
-rw-r--r-- | service/java/com/android/server/wifi/WifiController.java | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiController.java b/service/java/com/android/server/wifi/WifiController.java index 320db8d..a22f985 100644 --- a/service/java/com/android/server/wifi/WifiController.java +++ b/service/java/com/android/server/wifi/WifiController.java @@ -38,6 +38,7 @@ import android.os.WorkSource; import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; +import android.telephony.TelephonyManager; import android.util.Slog; import android.widget.Toast; @@ -633,30 +634,54 @@ class WifiController extends StateMachine { mSubListener = new SubscriptionManager.OnSubscriptionsChangedListener() { boolean firstChange = true; SubscriptionInfo lastSub; + String lastSubscriberId; + @Override public void onSubscriptionsChanged() { + TelephonyManager tm = (TelephonyManager) + mContext.getSystemService(Context.TELEPHONY_SERVICE); final SubscriptionInfo currentSub = SubscriptionManager.from(mContext) .getDefaultDataSubscriptionInfo(); + + if (currentSub == null) { + // don't disable when we're not sure yet. + return; + } + + String currentSubscriberId = + tm.getSubscriberId(currentSub.getSubscriptionId()); + + if (currentSubscriberId == null) { + // don't disable when we're not sure yet. + return; + } + if (firstChange) { lastSub = currentSub; + lastSubscriberId = currentSubscriberId; // we always get a state change on registration. firstChange = false; return; } - if (currentSub == null) { - // don't disable when we're not sure yet. - return; - } - if (lastSub != null && currentSub.getSubscriptionId() - == lastSub.getSubscriptionId()) { + + // SubscriptionInfo#getSubscriptionId() returns a + // framework handle and is not an IMSI. Don't use it to + // determine if the sub changed. + // + // TelephonyManager#getSubscriberId() returns the IMSI, + // so use that instead + if (currentSubscriberId.equals(lastSubscriberId)) { // don't disable if it's the same subscription return; } + lastSub = currentSub; + lastSubscriberId = currentSubscriberId; + Toast.makeText(mContext, com.android.internal.R.string.subscription_change_disabled_wifi_ap, Toast.LENGTH_SHORT).show(); - log("disabling Wifi AP due to Subscription change"); + log("disabling Wifi AP due to Subscriber Id (IMSI) change"); WifiController.this.obtainMessage(CMD_SET_AP, 0, 0, null).sendToTarget(); } }; |