History log of /system/connectivity/shill/wifi/wifi.cc
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
3a62e235646ec19bee71e8dbee5208282dcd13b5 20-Jan-2016 Alex Vakulenko <avakulenko@google.com> shill: Update libchrome APIs to r369476

The new libchrome has been ported from Chromium and some APIs have
changed. Make necessary changes at call sites.

Change-Id: Ib4c4b5438a2e249777c9c1b6509f085ad5d00049
/system/connectivity/shill/wifi/wifi.cc
c08d8a9193703486ef89bb9cc2e8e624d223088c 24-Nov-2015 Samuel Tan <samueltan@google.com> shill: check connectivity before calling OnConnectedAndReachable

We currently call WakeOnWiFi::OnConnectedAndReachable whenever our
IPv6 configuration is updated, even though this does not always means
that we have established IPv6 connectivity and IP-reachability.
Since kernel notifications for adding and deleting IPv6 are not
synced with the AP association process, we sometimes update our IPv6
configuration even before we have completed associating with an AP.
When this happens during dark resume, shill mistakenly assumes that
it is connected and pre-maturely re-suspends, preventing the association
process from completing.

Fix this by calling WiFi::IsConnectedToCurrentService() to check if
we are connected, before calling WakeOnWiFi::OnConnectedAndReachable
in WiFi::OnIPv6ConfigUpdated.

BUG=chromium:555722
TEST=shill compiles and all unit tests pass.

Change-Id: I8012886611854f44b7a6fcd4b780e3a5775429b6
/system/connectivity/shill/wifi/wifi.cc
830e5d7924cb43a034f3188cc1f674416d2f74e6 24-Nov-2015 Samuel Tan <samueltan@google.com> shill: rename WakeOnWiFi::OnDHCPLeaseObtained

Rename WakeOnWiFi::OnDHCPLeaseObtained to
WakeOnWiFi::OnConnectedAndReachable to more accurately
reflect the reason why this method is called.
The previous name did not apply to IPv6, since we do
not get DHCP leases when we establishing IPv6 connectivity.

BUG=None.
TEST=shill compiles and unit tests pass

Change-Id: I79fea0e5a1764949c0ce8445dc74b3a9a0534021
/system/connectivity/shill/wifi/wifi.cc
3bcaf3833b8f76755f3d747d2ad9e4a2219b29e1 23-Oct-2015 Peter Qiu <zqiu@google.com> Revert "Android: Use HAL API to setup station mode interface when WiFi device is enabled"

This reverts commit 7359e2b8729ba7498d97cc922a8dd687228c9c18.

This is no longer needed since the mode switching support
is added to apmanager.

Change-Id: I38a0c7dc5be5839e0e81eac629c2ea8e691f7bed
/system/connectivity/shill/wifi/wifi.cc
7359e2b8729ba7498d97cc922a8dd687228c9c18 16-Oct-2015 Paul Stewart <pstew@google.com> Android: Use HAL API to setup station mode interface when WiFi device is enabled

Currently on broadcom wifi device, changing the interface mode through
NL80211 command (set_interface) only changes the interface mode
but does not load the respective firmware file based on the mode.
The broadcom driver uses different firmware file for AP mode
vs station mode, with kernel currenlty defaulting to use AP mode
firmware file.

So in order to load the correct firmware file when switching from AP
mode to station mode, we need to use the WiFi driver HAL APIs (which
will load the correct firmware file based on the interface mode).

This is a short term fix to allow wifi device to continue to work
after switching back from AP mode.

For long term, we would either need to always use WiFi driver HAL
APIs to switch interface modes or fix the driver to load the correct
firmware file when switching mode through NL80211 command.

Bug: None
TEST=device setup on both boards

Change-Id: I38868b63bfcdf866d0a62cc763f81567b21800ac
/system/connectivity/shill/wifi/wifi.cc
da596539708c4b4df445d2bee01d1c8ab33901dd 03-Oct-2015 Peter Qiu <zqiu@google.com> Do not attempt to connect if supplicant is not present

When shill and apmanager is used by weaved for WiFi bootstrapping,
weaved will instruct shill to connect to a WiFi network right
after apmanager release the device back to shill. shill will
recreate the WiFi device after getting the device back. In this
case, the connect will happen before supplicant is detected by
shill. This causes shill to crash since it will attempt to use
supplicant proxy to initiate the connection.

Fix this by ignoring the connection attempt if supplicant is not
present. Once supplicant is detected, shill will auto-connect to
the target network (since weaved will configure it as auto-connectable)
when it is discovered in the scan result.

Bug: 24605760
TEST=Setup device using weaved, verify shill doesn't crash from logcat.
TEST=Run unittest on Chrome OS.

Change-Id: I3a61ac00bb12c8f2350db9aff1dca66e8bbb9070
/system/connectivity/shill/wifi/wifi.cc
035af5df4632b1635bd298f59054a5b4e56e53d8 02-Oct-2015 Samuel Tan <samueltan@google.com> Revert "shill: do not use disable_vht supplicant configuration option in Android"

This reverts commit ff4dce2615dfeff77a0e8a854d1ea4b61c59b9ec.

Change-Id: Ibc813f7bbbdd48999b9a97df5cc96838fda7d7fa
/system/connectivity/shill/wifi/wifi.cc
ff4dce2615dfeff77a0e8a854d1ea4b61c59b9ec 30-Sep-2015 Samuel Tan <samueltan@google.com> shill: do not use disable_vht supplicant configuration option in Android

Android uses an older version of WPA supplicant which does not support
the disable_vht network configuration option. Do not include this option
as an argument in shill's call to supplicant's AddNetwork D-Bus method.

BUG: 24511798
TEST: Run shill in android, attempt to connect to a network using shill's
Service API Connect method, read logs and ensure that the call to
supplicant's AddNetowrk method does not return a D-Bus failure.

Change-Id: Id100303c07f70051941c84ea556d9e7b2fe57351
/system/connectivity/shill/wifi/wifi.cc
b8fd4b77368949852b5ed62c14f0841d569d66b9 29-Sep-2015 Ningyuan Wang <nywang@google.com> shill: remove the redundant network enabling

We added the EnableNetwork() because DisableNetwork() issues an
asynchronous DBus call. Now the synchronous fix (CL 172052) landed.
Supplicant network will be enabled in SelectNetwork().
Therefore we no longer need this ad-hoc fix.

Bug: None
TEST=unittest and autotests

Change-Id: Iaf355807f7fec359545267a53b998e9bb686f5a3
/system/connectivity/shill/wifi/wifi.cc
66f155724c73e19fd524802fef6aa6122c548afa 29-Sep-2015 Ningyuan Wang <nywang@google.com> Revert "shill: remove the redundant network enabling"

This reverts commit 0db350e231b9f1ce1deff323421e1851ee8094d4.

Change-Id: I9dd2987b5c9537c97db4d5c6bdfed22d389190b5
/system/connectivity/shill/wifi/wifi.cc
0db350e231b9f1ce1deff323421e1851ee8094d4 28-Sep-2015 Ningyuan Wang <nywang@google.com> shill: remove the redundant network enabling

We added the EnableNetwork() because DisableNetwork() issues an
asynchronous DBus call. Now the synchronous fix (CL 172052) landed.
Supplicant network will be enabled in SelectNetwork().
Therefore we no longer need this ad-hoc fix.

Bug: None
TEST=autotests

Change-Id: Ib2f2434f8796e4cd22f5874fb0c0d8dd66f162fd
/system/connectivity/shill/wifi/wifi.cc
289a5a5e18bb1a676b3dfce111af4c2c00c7776e 21-Sep-2015 Samuel Tan <samueltan@google.com> shill: use different service_constants.h path for Android builds

Use the service_constants.h file from the external/cros/system_api/dbus
instead of chromeos/dbus/service_constants.h, since this header file
is installed into different directories when building shill for Android
and Chrome OS.

BUG: 22956441
Change-Id: I7e6ea46b4893588d2862792cf43aa83fdf7c30b4
TEST: shill still compiles using emerge.
/system/connectivity/shill/wifi/wifi.cc
235f80047714c04882fc1ebe3e04ec69315c36a3 19-Sep-2015 mukesh agrawal <quiche@google.com> shill: WiFi: remove use of glib

The call to g_ascii_isprint() stands in the way of
removing the need for glib. Provide our own
implementation of the necessary functionality, and
remove the call into glib.

Bug: None
BUG=chromium:533590
TEST=compile

Change-Id: I463c6e00c239e83a212ca7372b7dbf84d082bdad
/system/connectivity/shill/wifi/wifi.cc
5406888d4a4b8d1a1ebe0e849e7de940ad58e646 14-Sep-2015 Ningyuan Wang <nywang@google.com> shill: Send notification to wpa_supplicant upon suspend

Previously shill does not notify wpa_supplicant upon suspend.
In this case wpa_supplicant may handle the disconnection
inappropriately.

I add the dbus proxy of sending notifications. Shill will notify
wpa_supplicant through this proxy upon suspend.

BUG=24038255
TEST=auto tests on a veyron_jaq chromebook.

Change-Id: I0f0eb4eb3a635b38536e00a0775a1930ba299680
/system/connectivity/shill/wifi/wifi.cc
d8f8f16af7de6958c2a34a847e85e071dee9ae4a 09-Sep-2015 Ningyuan Wang <nywang@chromium.org> shill: enable the supplicant network when connecting

The supplicant network may be disabled upon disconnection.
This enables the supplicant network when we are trying to connect.

BUG=chromium:529821
TEST=Run autotests on a veyron-jaq chromebook

Change-Id: I67b8175397bda7410cce38bbebc67aca5bc58601
Reviewed-on: https://chromium-review.googlesource.com/298493
Commit-Ready: Ningyuan Wang <nywang@chromium.org>
Tested-by: Ningyuan Wang <nywang@chromium.org>
Reviewed-by: Zeping Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5 03-Sep-2015 Peter Qiu <zqiu@google.com> License shill to Apache2

This patch automatically replaced the license on all text files from
Chromium OS (BSD style) to AOSP (Apache2), keeping the original year as
a reference.

The license header was added to .gyp and .gypi, the NOTICE was added with a copy
of the Apache2 license and MODULE_LICENSE_* file was added.

BUG=23587594
TEST=grep 'Chromium OS Authors' doesn't find anything.

Change-Id: If41ede586c2465f5831fb7fee270ff41dbfdb596
/system/connectivity/shill/wifi/wifi.cc
8ff81329524eb3af0d8e7b2642a4a4c262d6b4fd 29-Aug-2015 Ningyuan Wang <nywang@chromium.org> shill: Add dbus interface for function "request_roam" in device object

I add a member function "RequestRoam" in device class to send dbus
command "roam" to wpa_supplicant.

In order to expose this function to the test scripts, I add the dbus
interface for this function. We can call this function through dbus
Device object.

BUG=chromium:523082
TEST=new autotest network_WiFi_RoamDbus
CQ-DEPEND=CL:295798,CL:295888

Change-Id: I161591b531af88f2ff50992914e61c9552e4b88e
Reviewed-on: https://chromium-review.googlesource.com/296047
Commit-Ready: Ningyuan Wang <nywang@chromium.org>
Tested-by: Ningyuan Wang <nywang@chromium.org>
Reviewed-by: Ningyuan Wang <nywang@google.com>
Reviewed-by: Ningyuan Wang <nywang@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
e5fe58dedad8d7fb509eb7eac82e77f8cc86ebc0 13-Aug-2015 Peter Qiu <zqiu@chromium.org> shill: use updated supplicant proxy creation APIs

This eliminates the need for DBusManager, since supplicant process
proxy will monitor for its own service availability.

Since we don't have to re-initialize process proxy during start/stop,
interface proxy will be used instead of process proxy to indicate if
we connected to supplicant or not.

BUG=chromium:517680
TEST=unittests, wifi_matfunc tests

Change-Id: If641bfd78b74f3bbd59ca7816c4435981b0cbfbd
Reviewed-on: https://chromium-review.googlesource.com/292967
Commit-Ready: Zeping Qiu <zqiu@chromium.org>
Tested-by: Zeping Qiu <zqiu@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
608ec29525f553d51f0a92e84176e3d4b45930a9 31-Jul-2015 Peter Qiu <zqiu@chromium.org> shill: use ControlInterface to create proxy objects

So that appropriate proxy objects can be created based on the type of
the control interface.

While there, remove ProxyFactory related files.

BUG=chromium:513791
TEST=USE="asan clang cellular wimax dhcpv6" FEATURES=test emerge-$BOARD shill

Change-Id: I465b0807ab4ccacac3891638db41384f43ef83c5
Reviewed-on: https://chromium-review.googlesource.com/289855
Reviewed-by: Zeping Qiu <zqiu@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
Tested-by: Zeping Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
4c9361f7eec1219a0b598092e56e8cb332d6f2ff 13-Jul-2015 Samuel Tan <samueltan@chromium.org> shill: report done early on suspend/dark resume actions if WiFi is disabled

When shill attempts to run suspend actions or dark resume actions
on a WiFi device while it is disabled, report done immediately
instead of waiting for the ResultAggregator to time out.

BUG=chromium:507876
TEST=Compile shill and run unit tests.

Change-Id: I613f842dc6cde04d46bd02bd13b539da9f9d665d
Reviewed-on: https://chromium-review.googlesource.com/285156
Reviewed-by: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
fc5236388674c3ae04255d98f5a3e93b789be185 14-Jul-2015 Peter Qiu <zqiu@chromium.org> shill: cleanup proxy interfaces for supplicant

Remove dbus-c++ dependencies from supplicant proxy interfaces and the
classes that uses supplicant proxy interfaces. Mainly the usage of
dbus-c++ specific types: DBus::Path (replaced by std::string) and
map<string, DBus::Variant> (replaced by KeyValueStore) types.

Also update the proxy interface APIs to return boolean status instead
of passing on the DBus exception errors. Ideally, we would like to
return an error object back to the caller as well, but that would require
a method to convert dbus errors to shill errors (additional errors to
cover all possible DBus errors). And currently, those errors are used
for logging purpose only (with an exception in RemoveNetwork), where it
is already done inside the proxy APIs.

BUG=chromium:570966
TEST=USE="asan clang" FEATURES=test emerge-$BOARD shill
TEST=Run wifi_matfunc tests

Change-Id: I227b5adc2306873480414db7d4e625bc1cc4f21b
Reviewed-on: https://chromium-review.googlesource.com/285632
Trybot-Ready: Zeping Qiu <zqiu@chromium.org>
Tested-by: Zeping Qiu <zqiu@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
1caa576e76930d7cef6f4b0fc79b280d23cb9855 08-Jul-2015 Rebecca Silberstein <silberst@chromium.org> shill: track DisconnectReason from supplicant

Supplicant reports a disconnect reason when handling a disconnect event. This
reason code can be used to troubleshoot and diagnose connectivity issues. Each
DisconnectReason property update is now processed by shill. Shill logs and
stores the reason code for the duration of the disconnected state of a service.
When the current or pending service moves from the disconnected state, the value
is cleared. The default value for the disconnect reason is an invalid reason
code to distinguish between explicitly set and default reason codes.

BUG=chromium:508225
TEST=Unit tests
TEST=manually tested on peppy

Change-Id: Ia590bd17e6086633ba29448d39b999379f8270f7
Reviewed-on: https://chromium-review.googlesource.com/284624
Trybot-Ready: Rebecca Silberstein <silberst@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Rebecca Silberstein <silberst@chromium.org>
Tested-by: Rebecca Silberstein <silberst@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
14ba19b3a0974811187f09f85a912a66963b8f3e 09-Jul-2015 Samuel Tan <samueltan@chromium.org> shill: only perform suspend and dark resume actions if WiFi device is enabled

Only perform OnBeforeSuspend and OnDarkResume actions if the WiFi
device is enabled. This prevents the WiFi device from performing
any wake-on-WiFi-related actions (e.g. NIC programming, scans) when
it is disabled.

This change reverses the small change made in CL:283958, moving the
device enabled check from Manager::OnDarkSuspendImminent to
WiFi::OnDarkResume. This approach is more principled as it allows
each device to decide what actions it should take when disabled.

BUG=chromium:507876
TEST=Compile shill and run unit tests.

Change-Id: Ie7f3d70d4a0148c6a5f28459076603bb34acee23
Reviewed-on: https://chromium-review.googlesource.com/284573
Tested-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
2b363903f38a515001c5edc7202403fcddb15a01 16-Jun-2015 Paul Stewart <pstew@chromium.org> shill: wifi: Switch pointer/ref spacing

Switch to Chrome style spacing.

BUG=chromium:501026
TEST=Unit tests

Change-Id: Ieff88b00706ed7c57049531a21427d9ea84b0a71
Reviewed-on: https://chromium-review.googlesource.com/278081
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
1897afaeb89003f5cc75a256f6fd7528e6abd54f 21-May-2015 Samuel Tan <samueltan@chromium.org> shill: report dark resume wake reason to powerd via DBus

Report the wake reason for the current dark resume to powerd via
powerd's ReportDarkResumeWakeReason DBus method. shill needs to
report the wake reason to powerd, so that powerd can log wake
duration metrics separately for different wake reasons. (powerd
cannot identify the wake reasons itself, since the reasons come
from the kernel's wireless subsystem.)

CQ-DEPEND=CL:270514
BUG=chromium:485315
TEST=Compile shill and run unit tests.

Change-Id: I6d160a3ab2efdf95dd3e50ffc6c3de66be6f80b7
Reviewed-on: https://chromium-review.googlesource.com/270553
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
bf64556fda15baabcc3d5865d84667ce4f42b231 19-May-2015 mukesh agrawal <quiche@chromium.org> shill: remove progressive scan variation support

We're not tracking the data from the progressive scan field
trial, so we should just remove it.

(Doing so now is motivated by the fact that we're removing the
manual control over progressive scan in crosh. So there's no
longer an escape hatch for a device that encounters problems
due to the field trial.)

BUG=chromium:250945
TEST=FEATURES=test emerge-peppy shill

Change-Id: I5e82e75e0f95e33a89c97abf9b33eab6157de08e
Reviewed-on: https://chromium-review.googlesource.com/272219
Tested-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: Zeping Qiu <zqiu@chromium.org>
Commit-Queue: mukesh agrawal <quiche@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
62abf31989c52dc1e4ee5aae71664ba81d6fe2db 05-May-2015 Peter Qiu <zqiu@chromium.org> shill: move ResolvePeerMacAddress to Device

It makes more sense to put ResolvePeerMacAddress in Device, which
will allow other devices to use this function in the future as well.

While there, move the hardware address conversion utility functions
(MakeHardwareAddressFromString and MakeStringFromHardwareAddress) to Device
class instead of WiFiEndpoint. These are generic device functions, not
specific to WiFi.

BUG=None
TEST=USE="asan clang" FEATURES=test emerge-$BOARD shill

Change-Id: I9ad47e02203ddd2124b249b1dd0c78a518d48197
Reviewed-on: https://chromium-review.googlesource.com/269396
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
Tested-by: Zeping Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
618d9d7ae7d1dac6ffac799d82a1f90218e349a6 04-May-2015 Peter Qiu <zqiu@chromium.org> shill: refactor TDLS related code in WiFi class

Move TDLS related code to the newly created class TDLSManager,
which will manage TDLS peer discovery and perform TDLS operations.

BUG=chromium:482826
TEST=USE="asan clang" FEATURES=test emerge-$BOARD shill
TEST=Run wifi_matfunc test suite

Change-Id: Ie63d871fe4e31de732251e128841ebfcf4a684f1
Reviewed-on: https://chromium-review.googlesource.com/269137
Trybot-Ready: Zeping Qiu <zqiu@chromium.org>
Tested-by: Zeping Qiu <zqiu@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
e20e8da79eb81ecf8cafd18b37bb40cbc8c84534 10-Apr-2015 Samuel Tan <samueltan@chromium.org> shill: add per-service roam threshold property

Add a per-WiFi service |roam_threshold_db| property that can be read, written,
and reset via DBus. The value of this property is used to set supplicant's roam
threshold property when we connect to a WiFi service, and overrides the WiFi
device-wide |roam_threshold_db| property if set.

CQ-DEPEND=CL:265149
BUG=chromium:38681
TEST=Compile shill and run unit tests.

Change-Id: I8cfd7a067ce7cc6f3d284b8ae5f1df6706c5c05d
Reviewed-on: https://chromium-review.googlesource.com/265221
Reviewed-by: Samuel Tan <samueltan@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
3c898323878e95b40abcfc6c7a993555d4675323 07-Apr-2015 Roshan Pius <rpius@chromium.org> shill: wifi: Maintain an internal table of TDLS peers after discovery.

WPA supplicant does not maintain a list of TDLS peers that have been
discovered by the user. This CL adds an intenal list of peers who have
been found by using the TDLS Discover protocol exhchange. The list
of peers are maintained for 30 seconds after the last "Discovery"
initiated by the user. We use this intenal list to return the status of
the peer if it is not known to wpa_supplicant.

BUG=chromium:471021
TEST=Following tests were performed:
`P2_TEST_FILTER="shill::WiFiMainTest.PerformTDLSOperation" FEATURES=test
emerge-${BOARD} shill`
`test_that ${host} network_WiFi_TDLSPing`

Change-Id: I58d620df83bedf0f61542e67e04cee21af5f7e8b
Reviewed-on: https://chromium-review.googlesource.com/264501
Reviewed-by: Roshan Pius <rpius@chromium.org>
Tested-by: Roshan Pius <rpius@chromium.org>
Commit-Queue: Roshan Pius <rpius@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
a388fdb2e74717ba2440a605f208647dd7cd3e06 03-Apr-2015 Peter Qiu <zqiu@chromium.org> shill: suppress reassociate attempt when network is unreliable

A network is considered unreliable when encountering multiple link
failures in a short period of time (currently set to 60 minutes). When
a network is unreliable, reassociate attempts will be skipped when link
failures are detected.

The unreliable status of the network will be reset when the device
resumes from suspend, or selected network changes, or after a period
of time without link failures after reconnection.

This will avoid unnecessary disconnect/reconnect attempts when the
network is unreliable due to other unforeseen factors.

BUG=chromium:472828
TEST=unittest

Change-Id: I2037d08692a9abec48afdb974a1e028c85eb2ad0
Reviewed-on: https://chromium-review.googlesource.com/263953
Trybot-Ready: Zeping Qiu <zqiu@chromium.org>
Tested-by: Zeping Qiu <zqiu@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
0965fae8c0f34f694dab364a9f4e329d466001ec 02-Apr-2015 Peter Qiu <zqiu@chromium.org> shill: fix shill crash when wpa_supplicant disappeared

When stopping the wifi device, make sure supplicant is present before
invoking calls to supplicant proxy. While there, also clean up
pending_scan_results_ to allow processing of future scan results.

BUG=chromium:472833
TEST=USE="asan clang" FEATURES=test emerge-$BOARD shill
Manual Test:
1. Stop wpa_supplicant using command "stop wpasupplicant"
2. Then restart wpa_supplicant using "start wpasupplicant"
3. Verify there is no shill crashes in "/var/spool/crash", and
wifi connection continues to work.

Change-Id: Ic1950064d30a4e62ca0b187e7e0c8093447a698a
Reviewed-on: https://chromium-review.googlesource.com/263699
Tested-by: Zeping Qiu <zqiu@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
4b8436a5136baa1716ca6a1013e2a4ad38ad2437 19-Mar-2015 Samuel Tan <samueltan@chromium.org> shill: retry frequency-specific passive scans in dark resume

Retry frequency-specific passive scans launched in dark resume up to
5 times since we may fail to receive AP beacons on some passive scans. This
will improve the reliability of frequency-specific passive scans in dark
resume.

Also, change log messages on suspend, dark resume, and full resume functions
in WiFi so that the WiFi device's connectivity status is logged by default
on these events.

BUG=chrome-os-partner:32269, chrome-os-partner:36471
TEST=Compile shill and run unit tests using:

P2_TEST_FILTER="shill::*" FEATURES="test" \
USE="wake_on_wifi clang asan" emerge-samus shill

P2_TEST_FILTER="shill::*" FEATURES="test" \
USE="-wake_on_wifi clang asan" emerge-samus shill

Manual testing as follows:
1) Flash a samus with test image and boot into it.
2) Run
ff_debug +wifi; ff_debug --level -3
3) Run
echo 0 > /var/lib/power_manager/disable_dark_resume; restart \
powerd
4) Enable the wake on WiFi SSID feature with the following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeOnWiFiFeaturesEnabled \
variant:string:packet_and_ssid
5) Set the net detect scan period to 30 seconds with the
following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:NetDetectScanPeriodSeconds variant:uint32:30
6) Connect samus to an AP (make sure AP is one that you can run ping from).
7) Run 'powerd_dbus_suspend' to suspend the system.
8) Wait 10 seconds, then disable the AP.
9) Wait 15 seconds, then re-enable the AP.
10) Wait, 80 seconds, then wake the samus by pressing any key.
11) Immediately upon waking the system, verify that the WiFi status icon is
in the connected state.
12) Run
grep 'BeforeSuspendActions.*connected' /var/log/net.log | tail -1
and verify that the line printed says "BeforeSuspendActions: connected".

Change-Id: Ic2e4096a7cfabec2c16fc2d27bd114372ab8795b
Reviewed-on: https://chromium-review.googlesource.com/261337
Tested-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
5d0b8076eee13cd9b3de1c62f982ef0dc430260c 17-Feb-2015 Samuel Tan <samueltan@chromium.org> shill: only scan on select channels when waking on SSID

When we wake on SSID and have SSID match results, instead of launching a passive
scan on all channels, passive scan only on channels where SSID matches were
reported to have occured in. This should reduce scan time, thus decreasing the
amount of time required to scan and connect to a network in dark resume when
wake on SSID occurs.

Also, change wake on WiFi throttling log message slightly to reflect that
the feature is temporarily, not permanantly, disabled.

BUG=chrome-os-partner:32269, chrome-os-partner:36471
TEST=Compile shill and run unit tests using:

P2_TEST_FILTER="shill::*" FEATURES="test" \
USE="wake_on_wifi clang asan" emerge-samus shill

P2_TEST_FILTER="shill::*" FEATURES="test" \
USE="-wake_on_wifi clang asan" emerge-samus shill

Manual testing as follows:
1) Flash a samus with test image and boot into it.
2) Run
ff_debug +wifi; ff_debug --level -3
3) Run
echo 0 > /var/lib/power_manager/disable_dark_resume; restart \
powerd
4) Enable the wake on WiFi SSID feature with the following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeOnWiFiFeaturesEnabled \
variant:string:packet_and_ssid
5) Set the net detect scan period to 30 seconds with the
following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:NetDetectScanPeriodSeconds variant:uint32:30
6) Connect samus to an AP (make sure AP is one that you can run ping from).
7) Run 'powerd_dbus_suspend' to suspend the system.
8) Wait 10 seconds, then disable the AP.
9) Wait 15 seconds, then re-enable the AP.
10) Wait, 80 seconds, then wake the samus by pressing any key.
11) Immediately upon waking the system, verify that the WiFi status icon is
in the connected state.
12) Run
grep 'BeforeSuspendActions.*connected' /var/log/net.log | tail -1
and verify that the line printed says "BeforeSuspendActions: connected".

Change-Id: Icef9d30a6ed239c9dd7af4b6c8ac42dd2269c5f7
Reviewed-on: https://chromium-review.googlesource.com/250550
Tested-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
3cd46cd843c0c4db3e931f8e3cc96e2f0c577d49 13-Mar-2015 Samuel Tan <samueltan@chromium.org> shill: handle WPA supplicant ScanDone failure

When WPA Supplicant reports that a scan has failed through the ScanDone signal,
reset the WiFi device scan state to idle 10 seconds later so that shill can
initiate scans again.

BUG=chromium:464568
TEST=Compile shill and run unit tests.

Change-Id: I4b90a8e1c4830334c3e4dc911494bba18bd14e9f
Reviewed-on: https://chromium-review.googlesource.com/260350
Tested-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
d1bec5d563afc9074a1875e2302d5ecf54c95f95 06-Mar-2015 Samuel Tan <samueltan@chromium.org> shill: log metrics when scans are launched in dark resume

Have shill parse NL80211_CMD_TRIGGER_SCAN scan started notifications, and log
metrics if a scan is started in dark resume.

BUG=chromium:462801
TEST=Compile shill and run unit tests.

Change-Id: I920ae3bd1026f5dc2b1e16c71627bcfe13e8b1e1
Reviewed-on: https://chromium-review.googlesource.com/257740
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
235dcec779704b782f0608421d890fe6d183e7cc 10-Mar-2015 Samuel Tan <samueltan@chromium.org> shill: save wiphy_index in WiFi

Save the wiphy interface index in WiFi instead of only in WakeOnWiFi since the
former will need this index for netlink message parsing.

Also,
- Move wiphy index parsing from WakeOnWiFi to WiFi
- Move wiphy index parsing unit tests from WakeOnWiFi to WiFi
- Complete WiFiMainTest.OnNewWiphy unit test

BUG=chromium:462801
TEST=Compile shill and run unit tests.

Change-Id: I62db65542d13156bd88c939b1c3d35b0583081fe
Reviewed-on: https://chromium-review.googlesource.com/258521
Tested-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
af2eb39fb2d2e035e276322df567e0ad4895ce0a 03-Mar-2015 Peter Qiu <zqiu@chromium.org> shill: disconnect pending_service_ when its credential changes

This will allow a new connection attempt for the pending_service_ to
start immediately without waiting for the pending connection timeout.

BUG=chromium:460329
TEST=Run network_WiFi_ProfileGUID test

Change-Id: I9d791840e4e566d5247cf4347234cc2f0788389c
Reviewed-on: https://chromium-review.googlesource.com/255540
Trybot-Ready: Zeping Qiu <zqiu@chromium.org>
Tested-by: Zeping Qiu <zqiu@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
381a0bb9927ded7963004fcd6793a77a3fca327b 20-Feb-2015 Samuel Tan <samueltan@chromium.org> shill: add flag to suppress auto-connects in Manager

Add flag that explicitly suppresses autoconnect attempts in Manager, and use
it to ensure that no autoconnect attempts are attempted between the triggering
of a passive scan in dark resume and the completion of that scan.

Also, force WPA supplicant to flush its BSS cache before launching scans in
dark resume to ensure that shill and WPA supplicant have an accurate view of
what endpoints are available while in dark resume.

BUG=chrome-os-partner:36839, chromium:439193
TEST=Compile shill and run unit tests.

Change-Id: Ic199bfe9d536fc7970172d20c398c81167e29a4e
Reviewed-on: https://chromium-review.googlesource.com/252572
Reviewed-by: Samuel Tan <samueltan@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
2d36a6e266deb96db1d3cf4b18dcc9d863795f28 19-Feb-2015 Samuel Tan <samueltan@chromium.org> shill: check if in dark resume before launching periodic scan

Check if we are in in a suspending/dark resume state (i.e.
PowerManager::suspending()) before launching a periodic scan in
WiFi::ScanTimerHandler. This ensures that we do not launch shill-initiated
scheduled scans while in dark resume.

Also add unit tests for WiFi::StartScanTimer.

BUG=chromium:459821, chromium:439193
TEST=Compile shill and run unit tests.

Change-Id: Ie727e068e1c48692e270b8c44662f10fb1299aaf
Reviewed-on: https://chromium-review.googlesource.com/252571
Tested-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
d51b24406ed78691abe1c8110029a197c351a6e9 23-Feb-2015 Peter Qiu <zqiu@chromium.org> shill: expose DBus method to enable/disable scheduled scan

Add a DBus method "SetSchedScan" to org.chromium.flimflam.Manager interface
for enabling/disabling scheduled scan. This is useful for testing purposes,
where we want to disable scheduled scan to prevent driver's scheduled scan
from interfering with user-initiated scans.

BUG=chromium:460756
TEST=Use dbus-send command to disable scheduled scan, and confirm it is
disabled through log messages. Then reenable scheduled scan using
dbus-send command, and confirm it is enabled through log messages.
CQ-DEPEND=CL:251733

Change-Id: Idfdaf8e397dca7b9044c17a53934cc629eb1d45e
Reviewed-on: https://chromium-review.googlesource.com/252220
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Zeping Qiu <zqiu@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
050c073a14d89a426f3e5cfa09ec11d0f12e7757 13-Feb-2015 Paul Stewart <pstew@chromium.org> shill: WiFi: Batch up scan results in single task

Instead of posting individual tasks to the event loop, retain the
entire list of pending scan results from wpa_supplicant in a local
vector. When the task executes, iterate directly over the vector
of scan results, and execute the ScanDone task if that even arrived
while there were BSS events queued up. This reduces the load on
the event loop, and should speed the process of processing scan
results.

BUG=chromium:458231
TEST=Unit tests + wifi_matfunc

Change-Id: Ie9103adaa77332658200432fd26f32be07e62688
Reviewed-on: https://chromium-review.googlesource.com/249650
Reviewed-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Zeping Qiu <zqiu@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
4bf0b5ccd6d4efac04e14b51ac2fe60550222e3c 13-Feb-2015 Samuel Tan <samueltan@chromium.org> shill: organize WiFi and WakeOnWiFi log messages

Change the log scopes and levels for several wake on WiFi related log messags
in wifi.cc and wake_on_wifi.cc so that no unnecessary messages are logged
outside of net.log and messages useful for general debugging are visible at
the default shill log level. With this change, all wake on WiFi related logs
will only be logged in net.log (using SLOG instead of LOG(INFO)), and no
messages reflecting the normal, expected operation of shill is logged to
LOG(ERROR).

BUG=None.
TEST=Compile shill and run unit tests using the following commands:

P2_TEST_FILTER="shill::*" FEATURES="test" \
USE="wake_on_wifi clang asan" emerge-samus shill

P2_TEST_FILTER="shill::*" FEATURES="test" \
USE="-wake_on_wifi clang asan" emerge-samus shill

Change-Id: Ib508bd6b07ffe22d0f4fb4e85acf14841c209071
Reviewed-on: https://chromium-review.googlesource.com/249542
Tested-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
d70ecdf36c94516b71cca8212caeb71da8c63d02 12-Jan-2015 Samuel Tan <samueltan@chromium.org> shill: configure NIC to wake on SSID

Enable shill to program the NIC to wake the system
from suspend on the appearance of whitelisted SSIDs.

BUG=chrome-os-partner:32269
TEST=Compile shill and run unit tests using:

P2_TEST_FILTER="shill::*" FEATURES="test" \
USE="wake_on_wifi clang asan" emerge-samus shill

P2_TEST_FILTER="shill::*" FEATURES="test" \
USE="-wake_on_wifi clang asan" emerge-samus shill

Manual testing as follows:
1) Flash a samus with test image and boot into it.
2) Run
ff_debug +wifi; ff_debug --level -3
3) Run
echo 0 > /var/lib/power_manager/disable_dark_resume; restart \
powerd
4) Run
echo disabled > /sys/bus/i2c/devices/i2c-ATML0000\:01/power/wakeup
5) Enable the wake on WiFi SSID feature with the following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeOnWiFiFeaturesEnabled \
variant:string:ssid
6) Set the net detect scan period to 60 seconds with the
following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:NetDetectScanPeriodSeconds variant:uint32:60
7) Connect samus to an AP.
8) Disable the AP. Verify that the samus is fully disconnected by the
WiFi icon state (a cross over empty WiFi bars).
9) Run 'powerd_dbus_suspend' to suspend the system.
10) 10 seconds after step 9, re-enable the AP.
11) Wait 120 seconds (start counting right after performing step 9).
12) Wake the samus by pressing any key.
13) Verify that the samus is connected to WiFi immediately after waking
by ensuring that it wakes up with the WiFi icon in the connected
state.

Change-Id: Ibfe5fa810770c0faa292c1f9fe423e3ee61668cf
Reviewed-on: https://chromium-review.googlesource.com/240579
Reviewed-by: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
34f424e672439bdf237a755f85245ebd7b66e8e2 17-Jan-2015 Paul Stewart <pstew@chromium.org> shill: Error: Attribute source from PopulateAndLog

Have callers pass the source file/line of PopulateAndLog calls so
the log message can disambiguate the ultimate source of the error.

BUG=chromium:449528
TEST=Unit tests + manual: restart shill and "grep error.cc /var/log/net.log"

Change-Id: I7bb54e966b047025a3ec7ef18acce5b8bed3d031
Reviewed-on: https://chromium-review.googlesource.com/241522
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
402bf2959e8b2c68627a7b66203ec84760bf2e03 23-Dec-2014 Samuel Tan <samueltan@chromium.org> shill: report done early in dark resume after scan

Report done early in dark resume after scanning for networks if
we do not find any networks that are available for auto-connect.

Also:
- rename the |have_service_configured_for_autoconnect| to
|has_service_configured_for_autoconnect| to match the
naming of the corresponding function in WiFiProvider.

BUG=chromium:444652
TEST=Compile shill and run unit tests using the following commands:

P2_TEST_FILTER="shill::*" FEATURES="test" USE="wake_on_wifi \
clang asan" emerge-samus shill

P2_TEST_FILTER="shill::*" FEATURES="test" USE="-wake_on_wifi \
clang asan" emerge-samus shill

Manual testing as follows:
1) Boot into a samus test image.
2) Run 'ff_debug +wifi; ff_debug --level -3'
3) Run 'echo 0 > /var/lib/power_manager/disable_dark_resume; restart \
powerd'
4) Enable all wake on WiFi features with the following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeOnWiFiFeaturesEnabled \
variant:string:"packet_and_ssid"
5) Set the wake-to-scan frequency to 60 seconds with the
following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeToScanFrequency variant:uint32:60
6) To work around a trackpad wakeup bug, disable trackpad wakeup using
the following command:
echo disabled > /sys/bus/i2c/devices/i2c-ATML0000\:01/power/wakeup
7) Connect samus to an AP.
8) Disable the AP. Verify that the samus is fully disconnected by the WiFi
icon state (a cross over empty WiFi bars).
9) Run 'powerd_dbus_suspend' to suspend the system.
10) Wait ~60 seconds and verify that the samus wakes on dark resume
by observing that light bar turns on while the screen is off.
11) Verify that the samus exits dark resume and suspends again after ~5 seconds
by observing that the lightbar turns off ~5 seconds after turning on.
12) Repeat steps 10-11 one more time.
13) Re-enable the AP immediately after the last dark resume cycle finishes
(i.e. right after light bar turns off).
14) Wait ~60 seconds for the next dark resume cycle to begin.
15) Verify that this dark resume cycle lasts for at least 2-3 more seconds than
the previous dark resume cycles observed in steps 10-12.
16) Wake the samus by pressing any key.
17) Verify that the samus is connected by verifying that the WiFi icon in the
bottom right corner is solid and filled (i.e. not crossed out or animating).

Note: these instructions assume that the AP can be fully re-enabled in
60 seconds, and that the DUT can scan and connect to this AP within 8.5 seconds.
The D-Link DGL-5500 is an example of such an AP that is appropriate for
this test.

Change-Id: I8a3c00e49dacf9e8580e24f9a0d84efb9e28b99c
Reviewed-on: https://chromium-review.googlesource.com/237494
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
0e0ac0de9ac592495f780d7c372ba1212d4d374c 30-Dec-2014 Samuel Tan <samueltan@chromium.org> shill: metrics: add metrics to track receipt of unmatched scan results

Add metric that tracks how often shill receives scan results from
a scan not initiated directly by shill in the current dark resume
cycle.

BUG=chromium:444652
TEST=Compile shill.

Change-Id: Ife09a75cc131cffaba0863b7211a4bb36f90a0c9
Reviewed-on: https://chromium-review.googlesource.com/237960
Reviewed-by: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
3c3c36a37a885d0a2e180998587af8390744f757 17-Dec-2014 Samuel Tan <samueltan@chromium.org> shill: do not report suspend readiness on gateway ARP

Pass a boolean from DHCPConfig::ProcessEventSignal to
IPConfig::UpdateProperties and Device::OnIPConfigUpdated that
indicates if a gateway ARP was received, and use this boolean
to determine whether or not to report suspend readiness when
WiFi::OnIPConfigUpdated is called in dark resume. This allows
us to accept both a Gateway ARP and BOUND event during dark
resume, and only report suspend readiness when the latter event
is received.

BUG=chromium:442610
TEST=Compile shill and run unit tests using:

P2_TEST_FILTER="shill::*" FEATURES="test" USE="clang asan" \
emerge-samus shill

Manual testing as follows:

1) Boot into a samus test image.
2) Run 'ff_debug +wifi; ff_debug --level -3'
3) Run 'echo 0 > /var/lib/power_manager/disable_dark_resume; restart \
powerd'
4) Enable all wake on WiFi features with the following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeOnWiFiFeaturesEnabled \
variant:string:"packet_and_ssid"
5) Set the wake-to-scan frequency to 30 seconds with the
following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeToScanFrequency variant:uint32:30
6) Connect samus to an AP.
7) Disable the AP. Verify that the samus is fully disconnected by the WiFi
icon state (a cross over empty WiFi bars).
8) Run 'powerd_dbus_suspend' to suspend the system.
9) Wait ~10 seconds for the system to fully suspend, then immediately re-enable
the AP.
10) Wait for another ~20 seconds for the system to enter dark resume (light bar
will turn on in dark resume).
11) After the dark resume concludes (~10 more seconds; light bar should turn
off), wait another 30 seconds and verify that the system does not enter
dark resume again (i.e. light bar does not light up again). This signifies
that the system has established a connection in the last dark resume. If
the system enters dark resume, repeat this step until the system no longer
enters dark resume again.
12) Wake the samus by pressing any way, and verify that the WiFi icon is in the
fully connected state.
13) Open /var/log/net.log
14) Search for the log messages containing "Gateway ARP received" and
"IPv4 DHCP lease obtained". Verify that the former is logged before the
latter, and that the two events are logged within the same second.
15) Verify that the log message containing the substring "OnDHCPLeaseObtained"
appears immediately after the "IPv4 DHCP lease obtained message".

Change-Id: I8185c8683ed1a5e65779d67cca100faafbad6654
Reviewed-on: https://chromium-review.googlesource.com/236099
Tested-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
c420dd27964a85c8dec8f09d9049287ccba5f95a 15-Dec-2014 Samuel Tan <samueltan@chromium.org> shill: check for auto-connectable service before starting wake to scan timer

Check whether shill has any services configured for auto-connect before
starting a wake to scan timer when suspending in a disconnected state
(when wake on SSID is supported and enabled).

BUG=chromium:441502
TEST=Compile shill and run unit tests using the following commands:

P2_TEST_FILTER="shill::*" FEATURES="test" USE="wake_on_wifi \
clang asan" emerge-samus shill

P2_TEST_FILTER="shill::*" FEATURES="test" USE="-wake_on_wifi \
clang asan" emerge-samus shill

Manual testing as follows:
1) Boot into a samus test image.
2) Run 'ff_debug +wifi; ff_debug --level -3'
3) Run 'echo 0 > /var/lib/power_manager/disable_dark_resume; restart \
powerd'
4) Enable all wake on WiFi features with the following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeOnWiFiFeaturesEnabled \
variant:string:"packet_and_ssid"
5) Set the wake-to-scan frequency to 15 seconds with the
following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeToScanFrequency variant:uint32:15
6) Connect samus to an AP.
7) Disable the AP. Verify that the samus is fully disconnected by the WiFi
icon state (a cross over empty WiFi bars).
8) Run 'powerd_dbus_suspend' to suspend the system.
9) Wait ~15 seconds and verify that the samus wakes on dark resume
by observing that light bar turns on while the screen is off.
10) Wake the samus by pressing any key.
11) Open Settings UI, select the WiFi service the samus is currently
connected to, and uncheck the "Automatically connect to this
network" checkbox.
12) Repeat step 8.
13) Wait ~15 seconds and verify that the samus does not wake up in
dark resume.

Change-Id: I1c5fe8196cbb9f3d1c7a6f509e14460611854a32
Reviewed-on: https://chromium-review.googlesource.com/235816
Reviewed-by: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
Commit-Queue: Eric Caruso <ejcaruso@chromium.org>
Trybot-Ready: Eric Caruso <ejcaruso@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
3fc8dae6b16f31cdc6e2b0733a5df85442ea26ec 06-Dec-2014 Samuel Tan <samueltan@chromium.org> shill: force passive scanning in dark resume

No active scans should be launched when looking for preferred
networks while in dark resume for security reasons.
To achieve this, this CL bypasses WPA supplicant and manually
requests the NIC to perform a passive scan via its NL80211 interface.
This is necessary since the version of WPA supplicant used in ChromeOS
does not properly launch passive scans when it is requested to do
so via its DBus API.

Note: 1-2 SSID-specific probe requests will still be launched when
a preferred network is found while in dark resume. This is part of the
association process and is not a security issue since the association
process already passes information (e.g. MAC addresses) over the air.

BUG=chromium:439193
TEST=Compile shill and run unit tests using the following commands:

P2_TEST_FILTER="shill::*" FEATURES="test" USE="wake_on_wifi \
clang asan" emerge-samus shill

P2_TEST_FILTER="shill::*" FEATURES="test" USE="-wake_on_wifi \
clang asan" emerge-samus shill

Manual testing as follows:

1) Boot into a samus test image.
2) Run 'ff_debug +wifi; ff_debug --level -3'
3) Run 'echo 0 > /var/lib/power_manager/disable_dark_resume; restart \
powerd'
4) Enable all wake on WiFi features with the following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeOnWiFiFeaturesEnabled \
variant:string:"packet_and_ssid"
5) Set the wake-to-scan frequency to 15 seconds with the
following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeToScanFrequency variant:uint32:15
6) Connect samus to an AP.
7) Disable the AP. Verify that the samus is fully disconnected by the WiFi
icon state (a cross over empty WiFi bars).
8) Run 'powerd_dbus_suspend' to suspend the system.
9) At the same time as #8, start capturing packets on Wireshark on a separate
machine in monitor mode with the following filter applied:

wlan.sa==11:11:11:11:11:11 && wlan.fc.type_subtype==4

where 11:11:11:11:11:11 is the MAC address of the samus under test.
10) Wait for ~35 seconds for 2 dark resume cycles to elapse. The light bar on
the samus lights up when in dark resume, and turns off when it is suspends
again, so observing the light bar will also tell you when 2 dark resume
cycles have elapsed.
11) During #10, verify that no packet (Probe Requests) matching the Wireshark
filters were captured.
12) After the 2nd dark resume concludes, re-enable the AP before the 3rd
dark resume cycle begins (i.e. within ~10 seconds of the 2nd dark resume
concluding).
13) During the third dark resume cycle, (~50 seconds after the system was first
suspended), verify that 1 or 2 Probe Request packets matching the Wireshark
filters were captured.
14) After the third dark resume cycle, wait another ~30 seconds and verify that
the system does not enter dark resume again (by verifying that the light
bar does not light up again).
15) Wake the samus by pressing any key, and verify that the WiFI icon is in
the fully connected state.
16) Wait ~10 more seconds and ensure that the samus does not scan for networks
(by observing that the WiFi icon does not play the scan animation).

Change-Id: Id19ab8bb42b5406fb8f5b1aa25e6149ecb40322b
Reviewed-on: https://chromium-review.googlesource.com/233951
Reviewed-by: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
0951ccbfca977a9cf218b2e4308aa26fb4d06ef9 10-Dec-2014 Alex Vakulenko <avakulenko@chromium.org> Update libchrome to r307740 and fix build errors

Updated libchrome, libchrome_crypto, metrics, feedback to the
latest revisions from Chrome (r307740).

Fixed build breaks due to the changes in upstream code:

- scope_ptr no longer needs explicit PassAs<T>() calls.
- scope_ptr<T> no longer has implicit conversion to T*.
Must use scope_ptr<T>::get() instead.
- base/file_util.h moved to base/files/file_util.h
- ARRAYSIZE_UNSAFE() removed in favor of arraysize()
- base::AppendToFile() and base::WriteFileDescriptor() now
return bool instead of the number of bytes written.
- dbus::Bus::AddFilterFunction() now returns void.
- C++11 features are enabled in libchromeos, so all targets
linking with it now have to support C++11
- OVERRIDE macro is removed in favor of native C++11
'override' keyword.

BUG=chromium:416628, chromium:411508
TEST=Build the world on x86, x64, ARM. The following builders
were tried:
x86-generic-full amd64-generic-full arm-generic-full
amd64-generic-asan daisy-full nyan-full pre-cq-group
daisy-release-group sandybridge-release-group
pineview-release-group
CQ-DEPEND=CL:234450,CL:234980

Change-Id: I374bebe2211d533c4431c82efb8be1cdcb1f405d
Reviewed-on: https://chromium-review.googlesource.com/234440
Reviewed-by: Bertrand Simonnet <bsimonnet@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
3a0950c3a22d1b090aa2a68c2e7f48f26bd4a758 04-Dec-2014 Samuel Tan <samueltan@chromium.org> shill: check connectivity before scanning on resume

Change WiFi::OnAfterResume logic such that we only initiate a
scan on resume if we are not connected.

In the corner case where we appear to be connected on resume but
are actually on our way to disconnecting, this change will slow
the reconnect time since a scan will only be triggered some time
after WiFi::OnAfterResume is executed. However, this prevents
a background scan from being launched if we are indeed connected
on resume, which decreases WiFi throughput and increases latency.

BUG=chromium:438831
TEST=Compile shill and run unit tests using:

P2_TEST_FILTER="shill::*" FEATURES="test" USE="clang asan" \
emerge-samus shill

Change-Id: Ia7aed7ef7c1ff6f993d2200d8b97b2787ed718d2
Reviewed-on: https://chromium-review.googlesource.com/233033
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
1964b5de186ef06fa89a78b27c3a112686bc36f7 02-Dec-2014 Samuel Tan <samueltan@chromium.org> shill: add metric for WiFi connection status after wake

Add metric that tracks if the WiFi device is connected to
a service after waking from suspend, if the relevant wake
on WiFi features are enabled and supported.

Also added unit tests for previously WiFi metrics reporting
functions.

BUG=chromium:427731
TEST=Compile shill and run unit tests using:

P2_TEST_FILTER="shill::*" FEATURES="test" USE="wake_on_wifi \
clang asan" emerge-samus shill

P2_TEST_FILTER="shill::*" FEATURES="test" USE="-wake_on_wifi \
clang asan" emerge-samus shill

Change-Id: Ie1251e455bab3b5bb9f9e666c83a466a06079979
Reviewed-on: https://chromium-review.googlesource.com/232816
Tested-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
787a1cebf2452c14bf392ab99902e686ea4a6fb4 12-Nov-2014 Samuel Tan <samueltan@chromium.org> shill: add lucid sleep dark resume logic

Add logic in WiFi::OnDarkResume and WiFi::OnBeforeSuspend
that decides what actions to take before suspend and when
waking in dark resume to maintain and re-establish WiFi
connectivity during system suspend.

Also:
- Add |in_dark_resume_| to PowerManager to allow
autoconnect to work while in dark resume but not
during normal suspend.
- Rename WakeOnWiFi::kIPAddress to WakeOnWiFi::kPattern
to more accurately reflect how this enum represents a
wake trigger (wake on pattern), rather than a feature
implemented using this trigger (wake on packet).
- Refactor parts of wifi_unittest.cc and
wake_on_wifi_unittest.cc to be cleaner, test this new
logic and more thoroughly test existing code.

BUG=chrome-os-partner:32270
TEST=Run unit tests using the following commands:

P2_TEST_FILTER="shill::*" FEATURES="test" USE="wake_on_wifi
clang asan" emerge-samus shill

P2_TEST_FILTER="shill::*" FEATURES="test" USE="-wake_on_wifi
clang asan" emerge-samus shill

Manual testing as follows:

1) Boot into a samus test image.
2) Run 'ff_debug +wifi; ff_debug --level -3'
3) Run 'echo 1 > /sys/power/dark_resume_always'
4) Run 'echo 0 > /var/lib/power_manager/disable_dark_resume; restart \
powerd'
5) Enable all wake on WiFi features with the following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeOnWiFiFeaturesEnabled \
variant:string:"packet_and_ssid"
6) Set the wake-to-scan frequency to 30 seconds with the
following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.SetProperty \
string:WakeToScanFrequency variant:uint32:30
7) Connect samus to an AP.
8) Run 'powerd_dbus_suspend' to suspend the system.
9) Wait ~12 seconds, then disable/turn off the AP.
10) Wait ~12 seconds, then reenable/turn on the AP.
11) Wait ~45 seconds, then press any button to wake the samus.
Note: you might have to press the same key on the samus repeatedly
until the samus fully wakes (space works well).
12) Observe the WiFi icon on the bottom right of the screen immediately
upon wake and verify that it is already in the connected state
rather than in the scanning state (i.e. scan animation playing).

Change-Id: Ic08e78fd4823011a50aef686acc80d300bff2b21
Reviewed-on: https://chromium-review.googlesource.com/229188
Tested-by: Samuel Tan <samueltan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
a57713b11fb958e732bc12c02f52bcbc942aeda2 02-Dec-2014 Peter Qiu <zqiu@chromium.org> shill: Remove interface from supplicant when stopping wifi device

This allows other application/daemon (such as apmanager) to take over the
ownership of the interface/device when it is claimed from shill.

BUG=chromium:435704
TEST=unittests, manual test with apmanager

Change-Id: I3c6123b93bf1981165d085802a28abe90f783d20
Reviewed-on: https://chromium-review.googlesource.com/232711
Reviewed-by: Peter Qiu <zqiu@chromium.org>
Commit-Queue: Peter Qiu <zqiu@chromium.org>
Tested-by: Peter Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
da69ecfa906572120eb4f6c405e7d4be38dc9701 19-Nov-2014 Ben Chan <benchan@chromium.org> shill: supplicant: Move supplicant code to its own sub-directory.

This CL is part of a series of CLs, which aim to reorganzie shill's flat
source code structure into a more modular form by moving technology
specific code into their own sub-directories.

BUG=chromium:433419
TEST=`FEATURES=test emerge-$BOARD shill`
TEST=`USE='clang asan' FEATURES=test emerge-$BOARD shill`

Change-Id: I119663a90062f7faf3038a2455d53d4ae8c5e297
Reviewed-on: https://chromium-review.googlesource.com/230750
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc
d6a8b519e3057f52313e502f502a4819a942e089 18-Nov-2014 Ben Chan <benchan@chromium.org> shill: wifi: Move wifi code to its own sub-directory.

This CL is part of a series of CLs, which aim to reorganzie shill's flat
source code structure into a more modular form by moving technology
specific code into their own sub-directories.

BUG=chromium:433419
TEST=`FEATURES=test emerge-$BOARD shill`
TEST=`USE='clang asan' FEATURES=test emerge-$BOARD shill`

Change-Id: Ic6bf64e7fe263fd0b2277877d78cf776f179e7d7
Reviewed-on: https://chromium-review.googlesource.com/230460
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
/system/connectivity/shill/wifi/wifi.cc