summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhalid Zubair <kzubair@cyngn.com>2015-12-04 11:02:29 -0800
committerRoman Birg <roman@cyngn.com>2016-07-08 14:54:12 -0700
commit41ada58f12e770903137746e17cc0fafa2a5d42a (patch)
tree68cdf4fa2de1cae7d321d0b480326ee3b2fc7d5f
parent73cb2716f3b92a91cdf2344c5b4f3b51cc5a27b7 (diff)
downloadandroid_frameworks_opt_net_wifi-41ada58f12e770903137746e17cc0fafa2a5d42a.tar.gz
android_frameworks_opt_net_wifi-41ada58f12e770903137746e17cc0fafa2a5d42a.tar.bz2
android_frameworks_opt_net_wifi-41ada58f12e770903137746e17cc0fafa2a5d42a.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.java39
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 320db8d59..a22f98514 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();
}
};