History log of /system/connectivity/shill/wifi/wifi_unittest.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_unittest.cc
fa1eb722d0742d89c26b9c5c81d02ef2a138cbf2 21-Dec-2015 Alex Vakulenko <avakulenko@google.com> shill: Disable RTTI

There is no longer a reliance on RTTI in libbrillo, so disable RTTI
in the rest of Brillo codebase.

Shill also used dynamic_cast<> in many places but it looks like there
is no reason for that. Using static_cast<> in those places seems to
work just as well and doesn't require RTTI.

Bug: 26292405, chromium:220387
TEST: Compiles, all unit tests pass on Dragonboard
Was able to bootstrap a device from scratch and networking
seems to work fine.

Change-Id: Id0c47168e634e354b4279f613246e6667df6fb5f
/system/connectivity/shill/wifi/wifi_unittest.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_unittest.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_unittest.cc
15d5431798155cc83a3fcb8abe0d1a2d5128f7b6 09-Oct-2015 Rebecca Silberstein <silberst@google.com> RE-LAND: shill: use DhcpProperties for dhcpv4 config

In some deployments, DHCP properties need to be specified for DHCP
requests. These properties will be set via the PropertyStore and stored
in the user profile (per service) and the default profile.

To implement this, the manager and service classes will each have an
instance of DhcpProperties to track the property settings stored in the
applicable profile. When a device creates a dhcp_config object to
configure the dhcpcd options, it will merge any applicable
DhcpProperties values set in the default and user profiles.

Users were previously able to set the hostname for DHCP requests using
the Manager.Hostname property. This value is now included in the new
DhcpProperties object. Two options are currently supported:
DhcpProperties.Hostname and DhcpProperties.VendorClass.

This change also includes new tests for the new object and the
affiliated functions. Existing tests were also updated to cover this
new functionality.

Bug: 24162121
TEST="FEATURES=test emerge-daisy shill"
TEST=compiled for brillo

Change-Id: I045ab0dbf866ea0084a8f77b28bfff24970bb92c
/system/connectivity/shill/wifi/wifi_unittest.cc
f95fe0f32645a56ba4a1dfb2dfbcaabf80b0b3f2 31-Oct-2015 Rebecca Silberstein <silberst@google.com> Revert "shill: use DhcpProperties for dhcpv4 config"

This reverts commit 5ac8c7b32241582e2e39469297de6b7cab2c7d19.

Change-Id: I7b8e747aca30a2d09dc474d2c5ef31ffcccf8032
/system/connectivity/shill/wifi/wifi_unittest.cc
5ac8c7b32241582e2e39469297de6b7cab2c7d19 09-Oct-2015 Rebecca Silberstein <silberst@google.com> shill: use DhcpProperties for dhcpv4 config

In some deployments, DHCP properties need to be specified for DHCP
requests. These properties will be set via the PropertyStore and stored
in the user profile (per service) and the default profile.

To implement this, the manager and service classes will each have an
instance of DhcpProperties to track the property settings stored in the
applicable profile. When a device creates a dhcp_config object to
configure the dhcpcd options, it will merge any applicable
DhcpProperties values set in the default and user profiles.

Users were previously able to set the hostname for DHCP requests using
the Manager.Hostname property. This value is now included in the new
DhcpProperties object. Two options are currently supported:
DhcpProperties.Hostname and DhcpProperties.VendorClass.

This change also includes new tests for the new object and the
affiliated functions. Existing tests were also updated to cover this
new functionality.

Bug: 24162121
TEST="USE="asan clang" FEATURES=test emerge-samus shill"

Change-Id: I9e25ced863661cfd73164faf9032df25b208c6c2
/system/connectivity/shill/wifi/wifi_unittest.cc
03e6719bae1e0903d94853b896673a033196bcf5 13-Oct-2015 Alex Vakulenko <avakulenko@google.com> shill: Rename "chromeos" -> "brillo" in include paths and namespaces

libchromeos is transitioning to libbrillo and chromeos namespaces
and include directory is changing to brillo.

Bug: 24872993
TEST=built for aosp and brillo, all unit tests pass on dragonboard

Change-Id: I804311e49ee780ca96e05f6a581e8c95709d4e1d
/system/connectivity/shill/wifi/wifi_unittest.cc
6f99f2cb25bead57398151880118a7794d5428a3 07-Oct-2015 Samuel Tan <samueltan@google.com> shill: change unittest string matching expectations for __func__

In Android, __func__ prints out the entire function signature, whereas
in CrOS, __func__ only prints the function name. Change unittest
expectations to account for this.

BUG: 24705085
Change-Id: I968def135b5f448980d2d5818948e6276f23d9b2
TEST: shill unittests pass in Android and Chrome OS.
/system/connectivity/shill/wifi/wifi_unittest.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_unittest.cc
5edcb5c2e3c071bc2466bb112a0e4a93fd7433f3 24-Sep-2015 Samuel Tan <samueltan@google.com> shill: remove unnecessary declarations of ::testing::Throw

::testing::Throw is not used in any of shill's unit tests, so
remove the "using" statements for Throw from the unittest
source files.

BUG: None
Change-Id: Icb6cde9121374f8b1615c51f43d3fc251ede17a4
TEST: Compile shill and run unit tests.
/system/connectivity/shill/wifi/wifi_unittest.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_unittest.cc
bad1c10ffd2d4ac14f7bd9f4ef6a8982e711f566 19-Sep-2015 mukesh agrawal <quiche@google.com> shill: remove references to GLib

There are a number of references to GLib (the object),
even though no one uses GLib in a substantive way.
Remove these obsolete references.

Bug: 23386647
TEST=unit tests

Change-Id: I8d574980bc8e853c8b87ef64b581d64a71491201
/system/connectivity/shill/wifi/wifi_unittest.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_unittest.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_unittest.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_unittest.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_unittest.cc
57282d5403b23162de1ded91ec8d73bdc19c922a 29-Jul-2015 Paul Stewart <pstew@chromium.org> shill: netlink: Remove libgenl / libnl dependencies

shill no longer depends on libgenl / libnl in any meaningful
ways. This CL removes the last incidental dependencies and
removes the link line for it:

- Use of nla_total_len / nla_attr_size can be restated
trivially using constants from linux/netlink.h.
- The NLA_* type values no longer need to match up with
libnl, since we don't use this for policy anymore.
The NetlinkAttribute::Type is actually marginally more
descriptive.
- Remove defunct includes, references and comments.

BUG=chromium:512152
TEST=Unit tests

Change-Id: I8cb7d28f8382a0cfac0a3fe82acb1736ba321e27
Reviewed-on: https://chromium-review.googlesource.com/289236
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_unittest.cc
b5b41b5ce5d06e9df1dbd7f319cc49ff982eb84e 24-Jul-2015 Paul Stewart <pstew@chromium.org> shill: NetlinkManager: Use NetlinkPacket for incoming data

Create NetlinkPacket instances for dispatching incoming netlink
frames. As opposed to raw nlmsghdr pointers, NetlinkPacket
objects can persistently contain both the bounds of the packet
(since it is contained in a ByteString) as well as a counter
for the data consumed from the payload so far.

Use of this new data structure also resolves some tricky issues
about "constness" with regards to the data passed to the
NetlinkMessage. Previously, the code had a number of instances
of "const_cast". Although NetlinkPacket objects are passed via
non-const pointer, the class itself does not provide any
non-const methods apart from those related to the consumption
of data out of the payload. As a result, we have a reasonable
guarantee that there will not be any non-obvious modification
of either headers or payload as it is being processed.

For purposes of unit tests which do have cases for header and
payload modification, a MutableNetlinkPacket object is
introduced to supply those needs in a manner that does not
expose NetlinkPacket further.

All NetlinkMessage objects have been converted to use this new
datatype.

BUG=chromium:512152
TEST=Unit tests

Change-Id: I07180d8dcc70852998920fdbe97f9ef1511c1b2b
Reviewed-on: https://chromium-review.googlesource.com/287913
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
/system/connectivity/shill/wifi/wifi_unittest.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_unittest.cc
77994d69bae79ce07d3830c4f83144503a06b224 17-Jul-2015 Samuel Tan <samueltan@chromium.org> shill: call WiFiObjectTest::InstallMockWakeOnWiFi in WiFiObjectTest::SetUp

Move the call to WiFiObjectTest::InstallMockWakeOnWiFi from the constructor of
WiFiObjectTest to WiFiObjectTest::SetUp. This ensures that the destructor of
the SimpleAlarmTimer in WakeOnWiFi is only invoked after the EventDispatcher
(in WiFiMainTest) has been initialized (failing to ensure this results in a
deadlock).

Please refer to the bug for more details on how calling
WiFiObjectTest::InstallMockWakeOnWiFi in the constructor of WiFiObjectTest
results in a deadlock.

BUG=chromium:509138
TEST=The following command succeeds without hanging:

USE="asan clang" FEATURES=test P2_TEST_FILTER=shill::WiFiMainTest.* \
emerge-$BOARD shill

Change-Id: I986ed285207480ae0a2179e98d5b881ca29bbcfb
Reviewed-on: https://chromium-review.googlesource.com/286223
Reviewed-by: Zeping Qiu <zqiu@chromium.org>
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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.cc
8e0151e84f077cc9c0646d5bafd925ed235a1c12 04-Jun-2015 Peter Qiu <zqiu@chromium.org> shill: refactor DHCPConfig

To better support DHCPv6 configurations, move IPv4 specific code
from DHCPConfig to the newly created DHCP4Config. The idea is to
have the base class DHCPConfig supports the basic interaction with
dhcpcd daemon, and the derived class (IP specific) for processing
events and parsing IP configurations.

An upcoming CL will add a new class DHCP6Config for processing
IPv6 configurations.

BUG=chromium:496302
TEST=USE="asan clang" FEATURES=test emerge-$BOARD shill
TEST=Run network_Dhcp* client tests and wifi_matfunc suite

Change-Id: I1f23ec46a52b42fccf7bbc8906c5f5e506f2d1c8
Reviewed-on: https://chromium-review.googlesource.com/275274
Tested-by: Zeping Qiu <zqiu@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
/system/connectivity/shill/wifi/wifi_unittest.cc
675d0b0f04936050a357722f52dc078a3ab671d8 03-Jun-2015 Peter Qiu <zqiu@chromium.org> shill: move dhcp codes to dhcp directory

Number of files related to dhcp will increase significantly after
refactoring DHCPConfig and adding support for DHCPv6. So move
these files to a dedicated directory.

BUG=chromium:496302
TEST=USE="asan clang" FEATURES=test emerge-$BOARD shill

Change-Id: I7f47365158fc5e1d902946dc3403720402f9b6ad
Reviewed-on: https://chromium-review.googlesource.com/275019
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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.cc
0932171ae1b59449130783c28ac54332d06d4e23 31-Dec-2014 Samuel Tan <samueltan@chromium.org> shill: parse wakeup reason reported by kernel

Parse the wakeup reason broadcasted by the kernel, including the
SSIDs reported by the kernel on net detect wakes, and log this
reported wakeup reason.

Also:
- Change nlmsg_type of of messages used in wake_on_wifi_unittest.cc so that
they all have nlmsg_type of 0x13, which is type we assume all messages have
in this set of unit tests (i.e. kNl80211FamilyId).
- Remove unused constants.
- Remove unnecessary function call and expectation from
WiFiMainTest.OnBeforeSuspend_CallsWakeOnWiFi and
WiFiMainTest.OnDarkResume_CallsWakeOnWiFi.

BUG=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) 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:packet_and_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 (make sure AP is one that you can run ping from).
8) Enable waking on packets from the AP with the following command:
dbus-send --system --print-reply --dest=org.chromium.flimflam \
/device/wlan0 org.chromium.flimflam.Device.AddWakeOnPacketConnection \
string:"1.1.1.1"
where 1.1.1.1 is the IP address of the AP.
9) Run
grep "Wakeup reason: Pattern" /var/log/net.log | wc -l
and verify that the output is 0.
10) Run 'powerd_dbus_suspend' to suspend the system.
11) Wait 15 seconds, then ping the samus from the AP.
12) Wait 5 seconds, then wake the samus by pressing any key.
13) Repeat step 9, but verify that the output is now 1.
14) Disable the AP. Verify that the samus is fully disconnected by the
WiFi icon state (a cross over empty WiFi bars).
15) Run
grep "Wakeup reason: SSID" /var/log/net.log | wc -l
and verify that the output is 0.
16) Run 'powerd_dbus_suspend' to suspend the system.
17) Wait 10 seconds, then re-enable the AP.
18) Wait, 80 seconds, then wake the samus by pressing any key.
19) Repeat step 15, but verify that the output is now 1.
20) Make sure that the samus is connected to the AP.
21) Run
grep "Wakeup reason: Disconnect" /var/log/net.log | wc -l
and verify that the output is 0.
22) Run 'powerd_dbus_suspend' to suspend the system.
23) Wait 10 seconds, then disable the AP.
24) Wait 15 seconds, then wake the samus by pressing any key.
25) Repeat step 21, but verify that the output is now 1.

Change-Id: I6da02e683ceaf51f5cccf3c1e87a419b51e8449b
Reviewed-on: https://chromium-review.googlesource.com/240681
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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.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_unittest.cc