diff options
author | Steve Kondik <steve@cyngn.com> | 2016-03-10 19:46:12 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-03-10 19:46:12 -0800 |
commit | 81f882faf55fdc6411077bc42a850b563d61c9fd (patch) | |
tree | f587cf98f8f1ac0f14eeed8cabf5b9caca2522cc | |
parent | dff4b4ffc15321cdc7617946b1642cd07365d171 (diff) | |
parent | e5048be9b96c84659631fd5a95a2c80242df859d (diff) | |
download | android_frameworks_opt_net_wifi-81f882faf55fdc6411077bc42a850b563d61c9fd.tar.gz android_frameworks_opt_net_wifi-81f882faf55fdc6411077bc42a850b563d61c9fd.tar.bz2 android_frameworks_opt_net_wifi-81f882faf55fdc6411077bc42a850b563d61c9fd.zip |
Merge tag 'android-6.0.1_r22' of https://android.googlesource.com/platform/frameworks/opt/net/wifi into dr15staging/cm-13.0+r22
Android 6.0.1 release 22
Change-Id: I3feacc91c693dba8f11bdc6513f204c9d47f2d18
5 files changed, 290 insertions, 68 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java index 67a699a67..b0919b8bf 100644 --- a/service/java/com/android/server/wifi/WifiConfigStore.java +++ b/service/java/com/android/server/wifi/WifiConfigStore.java @@ -4192,6 +4192,31 @@ public class WifiConfigStore extends IpConfigStore { return false; } + static boolean isSimConfig(WifiConfiguration config) { + if (config == null) { + return false; + } + + if (config.enterpriseConfig == null) { + return false; + } + + int method = config.enterpriseConfig.getEapMethod(); + return (method == WifiEnterpriseConfig.Eap.SIM + || method == WifiEnterpriseConfig.Eap.AKA + || method == WifiEnterpriseConfig.Eap.AKA_PRIME); + } + + void resetSimNetworks() { + for(WifiConfiguration config : mConfiguredNetworks.values()) { + if (isSimConfig(config)) { + /* This configuration may have cached Pseudonym IDs; lets remove them */ + mWifiNative.setNetworkVariable(config.networkId, "identity", "NULL"); + mWifiNative.setNetworkVariable(config.networkId, "anonymous_identity", "NULL"); + } + } + } + boolean isNetworkConfigured(WifiConfiguration config) { // Check if either we have a network Id or a WifiConfiguration // matching the one we are trying to add. diff --git a/service/java/com/android/server/wifi/WifiController.java b/service/java/com/android/server/wifi/WifiController.java index 600b41e01..49d0c624a 100644 --- a/service/java/com/android/server/wifi/WifiController.java +++ b/service/java/com/android/server/wifi/WifiController.java @@ -94,19 +94,20 @@ class WifiController extends StateMachine { private static final int BASE = Protocol.BASE_WIFI_CONTROLLER; - static final int CMD_EMERGENCY_MODE_CHANGED = BASE + 1; - static final int CMD_SCREEN_ON = BASE + 2; - static final int CMD_SCREEN_OFF = BASE + 3; - static final int CMD_BATTERY_CHANGED = BASE + 4; - static final int CMD_DEVICE_IDLE = BASE + 5; - static final int CMD_LOCKS_CHANGED = BASE + 6; - static final int CMD_SCAN_ALWAYS_MODE_CHANGED = BASE + 7; - static final int CMD_WIFI_TOGGLED = BASE + 8; - static final int CMD_AIRPLANE_TOGGLED = BASE + 9; - static final int CMD_SET_AP = BASE + 10; - static final int CMD_DEFERRED_TOGGLE = BASE + 11; - static final int CMD_USER_PRESENT = BASE + 12; - static final int CMD_AP_START_FAILURE = BASE + 13; + static final int CMD_EMERGENCY_MODE_CHANGED = BASE + 1; + static final int CMD_SCREEN_ON = BASE + 2; + static final int CMD_SCREEN_OFF = BASE + 3; + static final int CMD_BATTERY_CHANGED = BASE + 4; + static final int CMD_DEVICE_IDLE = BASE + 5; + static final int CMD_LOCKS_CHANGED = BASE + 6; + static final int CMD_SCAN_ALWAYS_MODE_CHANGED = BASE + 7; + static final int CMD_WIFI_TOGGLED = BASE + 8; + static final int CMD_AIRPLANE_TOGGLED = BASE + 9; + static final int CMD_SET_AP = BASE + 10; + static final int CMD_DEFERRED_TOGGLE = BASE + 11; + static final int CMD_USER_PRESENT = BASE + 12; + static final int CMD_AP_START_FAILURE = BASE + 13; + static final int CMD_EMERGENCY_CALL_STATE_CHANGED = BASE + 14; private static final int WIFI_DISABLED = 0; private static final int WIFI_ENABLED = 1; @@ -380,6 +381,7 @@ class WifiController extends StateMachine { case CMD_WIFI_TOGGLED: case CMD_AIRPLANE_TOGGLED: case CMD_EMERGENCY_MODE_CHANGED: + case CMD_EMERGENCY_CALL_STATE_CHANGED: case CMD_AP_START_FAILURE: break; case CMD_USER_PRESENT: @@ -507,6 +509,7 @@ class WifiController extends StateMachine { transitionTo(mApStaDisabledState); } break; + case CMD_EMERGENCY_CALL_STATE_CHANGED: case CMD_EMERGENCY_MODE_CHANGED: if (msg.arg1 == 1) { transitionTo(mEcmState); @@ -646,6 +649,7 @@ class WifiController extends StateMachine { } } break; + case CMD_EMERGENCY_CALL_STATE_CHANGED: case CMD_EMERGENCY_MODE_CHANGED: if (msg.arg1 == 1) { mWifiStateMachine.setHostApRunning(null, false); @@ -666,15 +670,55 @@ class WifiController extends StateMachine { } class EcmState extends State { + // we can enter EcmState either because an emergency call started or because + // emergency callback mode started. This count keeps track of how many such + // events happened; so we can exit after all are undone + + private int mEcmEntryCount; @Override public void enter() { mWifiStateMachine.setSupplicantRunning(false); mWifiStateMachine.clearANQPCache(); + mEcmEntryCount = 1; } @Override public boolean processMessage(Message msg) { - if (msg.what == CMD_EMERGENCY_MODE_CHANGED && msg.arg1 == 0) { + if (msg.what == CMD_EMERGENCY_CALL_STATE_CHANGED) { + if (msg.arg1 == 1) { + // nothing to do - just says emergency call started + mEcmEntryCount++; + } else if (msg.arg1 == 0) { + // emergency call ended + decrementCountAndReturnToAppropriateState(); + } + return HANDLED; + } else if (msg.what == CMD_EMERGENCY_MODE_CHANGED) { + + if (msg.arg1 == 1) { + // Transitioned into emergency callback mode + mEcmEntryCount++; + } else if (msg.arg1 == 0) { + // out of emergency callback mode + decrementCountAndReturnToAppropriateState(); + } + return HANDLED; + } else { + return NOT_HANDLED; + } + } + + private void decrementCountAndReturnToAppropriateState() { + boolean exitEcm = false; + + if (mEcmEntryCount == 0) { + loge("mEcmEntryCount is 0; exiting Ecm"); + exitEcm = true; + } else if (--mEcmEntryCount == 0) { + exitEcm = true; + } + + if (exitEcm) { if (mSettingsStore.isWifiToggleEnabled()) { if (mDeviceIdle == false) { checkLocksAndTransitionWhenDeviceActive(); @@ -686,9 +730,6 @@ class WifiController extends StateMachine { } else { transitionTo(mApStaDisabledState); } - return HANDLED; - } else { - return NOT_HANDLED; } } } diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 14af922d8..84c659dcc 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -35,7 +35,11 @@ import android.text.TextUtils; import android.util.Base64; import android.util.LocalLog; import android.util.Log; - +import android.content.Context; +import android.content.Intent; +import android.app.PendingIntent; +import android.content.IntentFilter; +import android.content.BroadcastReceiver; import com.android.server.connectivity.KeepalivePacketData; import java.io.ByteArrayOutputStream; @@ -50,6 +54,7 @@ import java.util.List; import java.util.Locale; import java.util.zip.Deflater; import libcore.util.HexEncoding; +import android.app.AlarmManager; /** * Native calls for bring up/shut down of the supplicant daemon and for * sending requests to the supplicant daemon @@ -123,9 +128,18 @@ public class WifiNative { private native String doStringCommandNative(String command); - public WifiNative(String interfaceName) { + private final Context mContext; + private final PnoMonitor mPnoMonitor; + public WifiNative(String interfaceName, Context context) { mInterfaceName = interfaceName; + mContext = context; mTAG = "WifiNative-" + interfaceName; + if (mContext != null) { + mPnoMonitor = new PnoMonitor(); + } else { + mPnoMonitor = null; + } + if (!interfaceName.equals("p2p0")) { mInterfacePrefix = "IFNAME=" + interfaceName + " "; } else { @@ -134,6 +148,10 @@ public class WifiNative { } } + public WifiNative(String interfaceName) { + this(interfaceName, null); + } + void enableVerboseLogging(int verbose) { if (verbose > 0) { DBG = true; @@ -656,14 +674,91 @@ public class WifiNative { return doBooleanCommand("DRIVER COUNTRY"); } + //PNO Monitor + private class PnoMonitor { + private static final int MINIMUM_PNO_GAP = 5 * 1000; + private static final String ACTION_TOGGLE_PNO = + "com.android.server.Wifi.action.TOGGLE_PNO"; + long mLastPnoChangeTimeStamp = -1L; + boolean mExpectedPnoState = false; + boolean mCurrentPnoState = false;; + boolean mWaitForTimer = false; + final Object mPnoLock = new Object(); + private final AlarmManager mAlarmManager = + (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); + private final PendingIntent mPnoIntent; + + public PnoMonitor() { + Intent intent = new Intent(ACTION_TOGGLE_PNO, null); + intent.setPackage("android"); + mPnoIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); + + mContext.registerReceiver( + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + synchronized(mPnoLock) { + if (DBG) Log.d(mTAG, "PNO timer expire, PNO should change to " + + mExpectedPnoState); + if (mCurrentPnoState != mExpectedPnoState) { + if (DBG) Log.d(mTAG, "change PNO from " + mCurrentPnoState + " to " + + mExpectedPnoState); + boolean ret = setPno(mExpectedPnoState); + if (!ret) { + Log.e(mTAG, "set PNO failure"); + } + } else { + if (DBG) Log.d(mTAG, "Do not change PNO since current is expected"); + } + mWaitForTimer = false; + } + } + }, + new IntentFilter(ACTION_TOGGLE_PNO)); + } + + private boolean setPno(boolean enable) { + String cmd = enable ? "SET pno 1" : "SET pno 0"; + boolean ret = doBooleanCommand(cmd); + mLastPnoChangeTimeStamp = System.currentTimeMillis(); + if (ret) { + mCurrentPnoState = enable; + } + return ret; + } + + public boolean enableBackgroundScan(boolean enable) { + synchronized(mPnoLock) { + if (mWaitForTimer) { + //already has a timer + mExpectedPnoState = enable; + if (DBG) Log.d(mTAG, "update expected PNO to " + mExpectedPnoState); + } else { + if (mCurrentPnoState == enable) { + return true; + } + long timeDifference = System.currentTimeMillis() - mLastPnoChangeTimeStamp; + if (timeDifference >= MINIMUM_PNO_GAP) { + return setPno(enable); + } else { + mExpectedPnoState = enable; + mWaitForTimer = true; + if (DBG) Log.d(mTAG, "start PNO timer with delay:" + timeDifference); + mAlarmManager.set(AlarmManager.RTC_WAKEUP, + System.currentTimeMillis() + timeDifference, mPnoIntent); + } + } + return true; + } + } + } + public boolean enableBackgroundScan(boolean enable) { - boolean ret; - if (enable) { - ret = doBooleanCommand("SET pno 1"); + if (mPnoMonitor != null) { + return mPnoMonitor.enableBackgroundScan(enable); } else { - ret = doBooleanCommand("SET pno 0"); + return false; } - return ret; } public void enableAutoConnect(boolean enable) { @@ -781,6 +876,16 @@ public class WifiNative { } } + public boolean simAuthFailedResponse(int id) { + // should be used with type GSM-AUTH + return doBooleanCommand("CTRL-RSP-SIM-" + id + ":GSM-FAIL"); + } + + public boolean umtsAuthFailedResponse(int id) { + // should be used with type UMTS-AUTH + return doBooleanCommand("CTRL-RSP-SIM-" + id + ":UMTS-FAIL"); + } + public boolean simIdentityResponse(int id, String response) { synchronized (mLock) { return doBooleanCommand("CTRL-RSP-IDENTITY-" + id + ":" + response); @@ -1673,10 +1778,15 @@ public class WifiNative { synchronized public static WifiScanner.ScanData[] getScanResults(boolean flush) { synchronized (mLock) { + WifiScanner.ScanData[] sd = null; if (isHalStarted()) { - return getScanResultsNative(sWlan0Index, flush); + sd = getScanResultsNative(sWlan0Index, flush); + } + + if (sd != null) { + return sd; } else { - return null; + return new WifiScanner.ScanData[0]; } } } diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 98dc0f417..ed09d2c10 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -70,6 +70,7 @@ import android.util.Slog; import com.android.internal.R; import com.android.internal.app.IBatteryStats; import com.android.internal.telephony.IccCardConstants; +import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.TelephonyIntents; import com.android.internal.util.AsyncChannel; import com.android.server.am.BatteryStatsService; @@ -99,6 +100,7 @@ import java.util.List; import static com.android.server.wifi.WifiController.CMD_AIRPLANE_TOGGLED; import static com.android.server.wifi.WifiController.CMD_BATTERY_CHANGED; +import static com.android.server.wifi.WifiController.CMD_EMERGENCY_CALL_STATE_CHANGED; import static com.android.server.wifi.WifiController.CMD_EMERGENCY_MODE_CHANGED; import static com.android.server.wifi.WifiController.CMD_LOCKS_CHANGED; import static com.android.server.wifi.WifiController.CMD_SCAN_ALWAYS_MODE_CHANGED; @@ -374,6 +376,8 @@ public final class WifiServiceImpl extends IWifiManager.Stub { public void onReceive(Context context, Intent intent) { String state = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE); if (state.equals(IccCardConstants.INTENT_VALUE_ICC_ABSENT)) { + Log.d(TAG, "resetting networks because SIM was removed"); + mWifiStateMachine.resetSimAuthNetworks(); Log.d(TAG, "resetting country code because SIM is removed"); mWifiStateMachine.resetCountryCode(); } @@ -1420,6 +1424,9 @@ public final class WifiServiceImpl extends IWifiManager.Stub { boolean emergencyMode = intent.getBooleanExtra("phoneinECMState", false); mWifiController.sendMessage(CMD_EMERGENCY_MODE_CHANGED, emergencyMode ? 1 : 0, 0); } + } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALL_STATE_CHANGED)) { + boolean inCall = intent.getBooleanExtra(PhoneConstants.PHONE_IN_EMERGENCY_CALL, false); + mWifiController.sendMessage(CMD_EMERGENCY_CALL_STATE_CHANGED, inCall ? 1 : 0, 0); } else if (action.equals(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED)) { handleIdleModeChanged(); } else if (action.equals(WifiManager.WIFI_AP_STATE_CHANGED_ACTION)) { @@ -1470,6 +1477,13 @@ public final class WifiServiceImpl extends IWifiManager.Stub { intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); intentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED); intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); + + boolean trackEmergencyCallState = mContext.getResources().getBoolean( + com.android.internal.R.bool.config_wifi_turn_off_during_emergency_call); + if (trackEmergencyCallState) { + intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALL_STATE_CHANGED); + } + mContext.registerReceiver(mReceiver, intentFilter); } diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index e02579937..8afbad3c5 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -756,6 +756,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno /* alert from firmware */ static final int CMD_FIRMWARE_ALERT = BASE + 100; + /* SIM is removed; reset any cached data for it */ + static final int CMD_RESET_SIM_NETWORKS = BASE + 101; + /** * Make this timer 40 seconds, which is about the normal DHCP timeout. * In no valid case, the WiFiStateMachine should remain stuck in ObtainingIpAddress @@ -1150,7 +1153,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno mP2pSupported = mContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_WIFI_DIRECT); - mWifiNative = new WifiNative(mInterfaceName); + mWifiNative = new WifiNative(mInterfaceName, mContext); mWifiConfigStore = new WifiConfigStore(context,this, mWifiNative); mWifiAutoJoinController = new WifiAutoJoinController(context, this, mWifiConfigStore, mWifiConnectionStatistics, mWifiNative); @@ -1975,14 +1978,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno || workSource != null)) { mScanWorkSource = workSource != null ? workSource : new WorkSource(callingUid); - WorkSource batteryWorkSource = mScanWorkSource; if (mScanWorkSource.size() == 1 && mScanWorkSource.get(0) < 0) { // WiFi uses negative UIDs to mean special things. BatteryStats don't care! - batteryWorkSource = new WorkSource(Process.WIFI_UID); + mScanWorkSource = new WorkSource(Process.WIFI_UID); } try { - mBatteryStats.noteWifiScanStartedFromSource(batteryWorkSource); + mBatteryStats.noteWifiScanStartedFromSource(mScanWorkSource); } catch (RemoteException e) { log(e.toString()); } @@ -2539,6 +2541,14 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } /** + * reset cached SIM credential data + */ + public synchronized void resetSimAuthNetworks() { + sendMessage(CMD_RESET_SIM_NETWORKS); + } + + + /** * Get Network object of current wifi network * @return Network object of current wifi network */ @@ -2718,13 +2728,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno * ****************************************************** */ - private void logStateAndMessage(Message message, String state) { + private void logStateAndMessage(Message message, State state) { messageHandlingStatus = 0; if (mLogMessages) { - //long now = SystemClock.elapsedRealtimeNanos(); - //String ts = String.format("[%,d us]", now/1000); - - logd(" " + state + " " + getLogRecString(message)); + logd(" " + state.getClass().getSimpleName() + " " + getLogRecString(message)); } } @@ -5738,7 +5745,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno class DefaultState extends State { @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch (message.what) { case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED: { @@ -6027,7 +6034,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch (message.what) { case CMD_START_SUPPLICANT: /* Stop a running supplicant after a runtime restart @@ -6138,7 +6145,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case WifiMonitor.SUP_CONNECTION_EVENT: @@ -6240,7 +6247,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case CMD_STOP_SUPPLICANT: /* Supplicant stopped by user */ @@ -6339,9 +6346,15 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno mWifiP2pChannel.sendMessage(WifiP2pServiceImpl.SET_COUNTRY_CODE, country); break; + case CMD_GET_IBSS_SUPPORTED: deferMessage(message); break; + + case CMD_RESET_SIM_NETWORKS: + log("resetting EAP-SIM/AKA/AKA' networks since SIM was removed"); + mWifiConfigStore.resetSimNetworks(); + break; default: return NOT_HANDLED; } @@ -6382,7 +6395,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case WifiMonitor.SUP_CONNECTION_EVENT: @@ -6431,7 +6444,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: @@ -6591,7 +6604,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case CMD_START_SCAN: @@ -6789,7 +6802,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case WifiStateMachine.CMD_DISABLE_P2P_RSP: @@ -6825,7 +6838,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno class DriverStoppingState extends State { @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: @@ -6858,7 +6871,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno class DriverStoppedState extends State { @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch (message.what) { case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: StateChangeResult stateChangeResult = (StateChangeResult) message.obj; @@ -6890,7 +6903,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case CMD_SET_OPERATIONAL_MODE: @@ -7448,7 +7461,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno String bssid; String ssid; NetworkUpdateResult result; - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch (message.what) { case WifiMonitor.ASSOCIATION_REJECTION_EVENT: @@ -8540,7 +8553,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch (message.what) { case DhcpStateMachine.CMD_PRE_DHCP_ACTION: @@ -8863,6 +8876,17 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno case CMD_STOP_RSSI_MONITORING_OFFLOAD: stopRssiMonitoringOffload(); break; + case CMD_RESET_SIM_NETWORKS: + if (mLastNetworkId != WifiConfiguration.INVALID_NETWORK_ID) { + WifiConfiguration config = + mWifiConfigStore.getWifiConfiguration(mLastNetworkId); + if (mWifiConfigStore.isSimConfig(config)) { + mWifiNative.disconnect(); + transitionTo(mDisconnectingState); + } + } + /* allow parent state to reset data for other networks */ + return NOT_HANDLED; default: return NOT_HANDLED; } @@ -8951,7 +8975,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case CMD_STATIC_IP_SUCCESS: @@ -9010,7 +9034,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch (message.what) { case WifiWatchdogStateMachine.POOR_LINK_DETECTED: @@ -9074,7 +9098,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); WifiConfiguration config; switch (message.what) { case CMD_IP_CONFIGURATION_LOST: @@ -9259,7 +9283,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno @Override public boolean processMessage(Message message) { WifiConfiguration config = null; - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch (message.what) { case CMD_RESTART_AUTOJOIN_OFFLOAD: @@ -9557,7 +9581,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch (message.what) { case CMD_SET_OPERATIONAL_MODE: if (message.arg1 != CONNECT_MODE) { @@ -9661,7 +9685,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno public boolean processMessage(Message message) { boolean ret = HANDLED; - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch (message.what) { case CMD_NO_NETWORKS_PERIODIC_SCAN: @@ -9931,7 +9955,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch (message.what) { case WifiMonitor.WPS_SUCCESS_EVENT: @@ -10055,7 +10079,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case CMD_START_SUPPLICANT: @@ -10099,7 +10123,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno class SoftApStartedState extends State { @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case CMD_STOP_AP: @@ -10143,7 +10167,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case CMD_TETHER_STATE_CHANGE: @@ -10184,7 +10208,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno class TetheredState extends State { @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case CMD_TETHER_STATE_CHANGE: @@ -10220,7 +10244,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } @Override public boolean processMessage(Message message) { - logStateAndMessage(message, getClass().getSimpleName()); + logStateAndMessage(message, this); switch(message.what) { case CMD_TETHER_STATE_CHANGE: @@ -10486,16 +10510,19 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno String kc = makeHex(result, 1+kc_offset, kc_len); sb.append(":" + kc + ":" + sres); logv("kc:" + kc + " sres:" + sres); + + String response = sb.toString(); + logv("Supplicant Response -" + response); + mWifiNative.simAuthResponse(requestData.networkId, "GSM-AUTH", response); } else { loge("bad response - " + tmResponse); + mWifiNative.simAuthFailedResponse(requestData.networkId); } } - String response = sb.toString(); - logv("Supplicant Response -" + response); - mWifiNative.simAuthResponse(requestData.networkId, "GSM-AUTH", response); } else { loge("could not get telephony manager"); + mWifiNative.simAuthFailedResponse(requestData.networkId); } } @@ -10539,6 +10566,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } } + boolean good_response = false; if (tmResponse != null && tmResponse.length() > 4) { byte[] result = android.util.Base64.decode(tmResponse, android.util.Base64.DEFAULT); @@ -10554,6 +10582,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno String ik = makeHex(result, res_len + ck_len + 4, ik_len); sb.append(":" + ik + ":" + ck + ":" + res); logv("ik:" + ik + "ck:" + ck + " res:" + res); + good_response = true; } else if (tag == (byte) 0xdc) { loge("synchronisation failure"); int auts_len = result[1]; @@ -10561,18 +10590,21 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno res_type = "UMTS-AUTS"; sb.append(":" + auts); logv("auts:" + auts); + good_response = true; } else { loge("bad response - unknown tag = " + tag); - return; } } else { loge("bad response - " + tmResponse); - return; } - String response = sb.toString(); - logv("Supplicant Response -" + response); - mWifiNative.simAuthResponse(requestData.networkId, res_type, response); + if (good_response) { + String response = sb.toString(); + if (VDBG) logv("Supplicant Response -" + response); + mWifiNative.simAuthResponse(requestData.networkId, res_type, response); + } else { + mWifiNative.umtsAuthFailedResponse(requestData.networkId); + } } /** |