From 907e01eb7083c54aa1e840ea4e76a6518a028a72 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Fri, 7 Aug 2015 10:57:01 -0700 Subject: [PATCH] Wait a bit longer for wifi to shut down before rewriting the config We've seen case of it taking longer than 1500ms for the wifi system to actually shut down after the triggering settings element is written, so extend the wait time a bit. We've seen it take more than 1500ms but not more than 2500ms, so that's the new heuristic. This will of course all become happily obsolete once we start applying restored AP definitions programmatically rather than by filesystem-level operations. Bug 22979342 Change-Id: I6acf1baac23d4100124093128b82abf242b11a0e --- .../com/android/providers/settings/SettingsBackupAgent.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java index d99f741366bda..e74334b220cd7 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java @@ -447,8 +447,10 @@ public class SettingsBackupAgent extends BackupAgentHelper { Settings.Global.putInt(cr, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0); } - // !!! Give the wifi stack a moment to quiesce - try { Thread.sleep(1500); } catch (InterruptedException e) {} + // !!! Give the wifi stack a moment to quiesce. We've observed the + // response to disabling WIFI_SCAN_ALWAYS_AVAILABLE taking more + // than 1500ms, so we wait a generous 2500 here before proceeding. + try { Thread.sleep(2500); } catch (InterruptedException e) {} if (restoredSupplicantData != null) { restoreWifiSupplicant(FILE_WIFI_SUPPLICANT, restoredSupplicantData, restoredSupplicantData.length);