diff options
author | Ningyuan Wang <nywang@google.com> | 2017-04-05 03:11:48 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-04-05 03:11:48 +0000 |
commit | 03e86a9700434d0a8938479610a4b091ed94dbdf (patch) | |
tree | e14dbe7f5cb3e416e8ecd24e0cb9fbf6826f140b /service | |
parent | 81d73518dbbfbbfdf6a2d6c08a3101088fd5e722 (diff) | |
parent | e08dd98aa0f94d479f2b81120e76ef8c0ec779db (diff) |
Merge "Add a watch dog for WaitForP2pDisableState" into oc-dev
am: e08dd98aa0
Change-Id: I31de98c580601739d0cb31ac497a36ad93bd8405
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index b8d7e6ab6..fb807b7a0 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -596,6 +596,12 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss int disconnectingWatchdogCount = 0; static final int DISCONNECTING_GUARD_TIMER_MSEC = 5000; + /* Disable p2p watchdog */ + static final int CMD_DISABLE_P2P_WATCHDOG_TIMER = BASE + 112; + + int mDisableP2pWatchdogCount = 0; + static final int DISABLE_P2P_GUARD_TIMER_MSEC = 2000; + /* P2p commands */ /* We are ok with no response here since we wont do much with it anyway */ public static final int CMD_ENABLE_P2P = BASE + 131; @@ -2625,6 +2631,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss sb.append(Integer.toString(msg.arg2)); sb.append(" cur=").append(disconnectingWatchdogCount); break; + case CMD_DISABLE_P2P_WATCHDOG_TIMER: + sb.append(" "); + sb.append(Integer.toString(msg.arg1)); + sb.append(" "); + sb.append(Integer.toString(msg.arg2)); + sb.append(" cur=").append(mDisableP2pWatchdogCount); + break; case CMD_START_RSSI_MONITORING_OFFLOAD: case CMD_STOP_RSSI_MONITORING_OFFLOAD: case CMD_RSSI_THRESHOLD_BREACH: @@ -4394,7 +4407,12 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mTransitionToState = mSupplicantStoppingState; break; } - p2pSendMessage(WifiStateMachine.CMD_DISABLE_P2P_REQ); + if (p2pSendMessage(WifiStateMachine.CMD_DISABLE_P2P_REQ)) { + sendMessageDelayed(obtainMessage(CMD_DISABLE_P2P_WATCHDOG_TIMER, + mDisableP2pWatchdogCount, 0), DISABLE_P2P_GUARD_TIMER_MSEC); + } else { + transitionTo(mTransitionToState); + } } @Override public boolean processMessage(Message message) { @@ -4404,6 +4422,12 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss case WifiStateMachine.CMD_DISABLE_P2P_RSP: transitionTo(mTransitionToState); break; + case WifiStateMachine.CMD_DISABLE_P2P_WATCHDOG_TIMER: + if (mDisableP2pWatchdogCount == message.arg1) { + logd("Timeout waiting for CMD_DISABLE_P2P_RSP"); + transitionTo(mTransitionToState); + } + break; /* Defer wifi start/shut and driver commands */ case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: case CMD_START_SUPPLICANT: @@ -6881,16 +6905,30 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss return null; } - private void p2pSendMessage(int what) { + /** + * Send message to WifiP2pServiceImpl. + * @return true if message is sent. + * false if there is no channel configured for WifiP2pServiceImpl. + */ + private boolean p2pSendMessage(int what) { if (mWifiP2pChannel != null) { mWifiP2pChannel.sendMessage(what); + return true; } + return false; } - private void p2pSendMessage(int what, int arg1) { + /** + * Send message to WifiP2pServiceImpl with an additional param |arg1|. + * @return true if message is sent. + * false if there is no channel configured for WifiP2pServiceImpl. + */ + private boolean p2pSendMessage(int what, int arg1) { if (mWifiP2pChannel != null) { mWifiP2pChannel.sendMessage(what, arg1); + return true; } + return false; } /** |