252102 Commits

Author SHA1 Message Date
Colin Cross
8c8bb25089 Merge "Replace libziparchive-host with libziparchive"
am: 611e205bbe

Change-Id: I077a18bc3e6de20e0d4d6d6213de829ea47ffe43
2016-08-26 20:25:13 +00:00
Mitchell Wills
db81862be8 Add a WifiScanner API to listener for ongoing scans
Bug: 29412469
Change-Id: Id884851a12f95c89f928b81f5b5baa1f9f80fafe
(cherry picked from commit 0a726ac690cf5418257cd7dcb176c71158687561)
2016-08-26 13:22:51 -07:00
daisuke niwa
cf91215d00 Fix invitation request from persistent GC
When the device received the second invitation request
from GC of the same PersistentGroup, the wifi framework
processes "sa" as mOwner of WifiP2pGroup. At this point,
if an invited group is persistent group, WifiP2pGroup can't
know whether "sa" is GC or GO yet. So the framework shouldn't
process mOwner in the constructor.

Bug: 28715251
Change-Id: Ie7065da0d6c978c3747ecbd6f728de87d9567009
(cherry picked from commit af1eafd7b14f4cafd150d01d1d9d87470a4f3777)
2016-08-26 13:22:51 -07:00
Roshan Pius
28be4fc091 SettingsBackupAgent: Remove redundant size parameter
Remove the redundant size parameter in wifi backup/restore.

BUG: 28967335
Change-Id: I8ae9b2bf3bc8eb2dd1fd6dd87fe7b1dcf0712382
(cherry picked from commit 5db739c67fb6c897da91ccdda5700ff660eea15d)
2016-08-26 13:22:50 -07:00
Roshan Pius
311a72164b WifiConfiguration: Make NetworkSelectionStatus public
Expose a public constructor for |NetworkSelectionStatus| class and add a
setter in WifiConfiguration to set the |NetworkSelectionStatus| object.
Needed for config store persistence of this object.

BUG: 29273147
Change-Id: I9d9036928137760c4832567dd2b9d0fabc874940
TEST: Unit tests
(cherry picked from commit 6a89ee2d908add0d418995420b2d5eaebd90882f)
2016-08-26 13:22:49 -07:00
Roshan Pius
1bf869887d Use WifiManager for wifi backup/restore
Use the newly exposed WifiManager API's for backing up/restoring wifi
related data. Remove all other wifi related logic from
SettingsBackupAgent.

There are 3 API's exposed by WifiManager for backup/restore:
1. retrieveBackupData - Data to be backed up in new format.
2. restoreBackupData - Restore from the new backup data format.
3. restoreOldBackupData - Restore from the old backup data format.

BUG: 29075035
BUG: 28967335
Change-Id: I2dc379bc36af0a0824ed51fbe9aaebfd0a0114b0
(cherry picked from commit 7a2491fa3b42dd22c829eea3690239545f16f124)
2016-08-26 13:22:48 -07:00
Christopher Wiley
e90e0a74ad Fix race conditions between Tethering and TetherInterfaceStateMachine
Previously, Tethering would answer requests for current tethering state
by calling methods on instances of TetherInterfaceStateMachine to build
up that state. This is incorrect, since state queries can come in on an
arbitrary thread, independent of updates to the state machines
instances.

Fix this by:
  - Altering TetherInterfaceStateMachine to push consistent state
    snapshots to Tethering via notifyInterfaceStateChange()
  - Storing the last state snapshot in Tethering.mTetherStates
  - Removing public methods to query TetherInterfaceStateMachine state.
  - Consistently synchronizing access to Tethering.mTetherStates

Bug: 29009601
Test: WiFi Tethering continues to work, unittests continue to pass

Change-Id: Ied334f5e8739bc3aff1b08a1079095b9cc2a7958
(cherry picked from commit de4819dc82b734036b22416228327d2712e01884)
2016-08-26 13:22:47 -07:00
Roshan Pius
f9f88b8b20 WifiManager: Add new API to restore old backup data
Add a new API to restore the old backups containing the raw data from
wpa_supplicant.conf & ipconfig.txt files.
This helps clean up all the existing wifi configuration parsing
logic from SettingsBackupAgent.

BUG: 29075035
Change-Id: I8c7b93ef7c9e2decc8e4f9e5d7038939cf0ef196
(cherry picked from commit 08131593a864c23b8465d7ce05bf6c04564f7ba1)
2016-08-26 13:22:47 -07:00
Christopher Wiley
cd0cfbbc61 Tethering: Own WiFi tethering state and lifetime
- Add logic to Tethering to track whether the user has requested
  tethering via WiFi.
- Subscribe to intents regarding soft AP state to enable and
  disable tethering when the AP comes up or goes down.
- Refactor IP configuration logic to do configuration for WiFi
  as well as USB.

Bug: 29054780
Test: WiFi tethering continues to work on angler
      Tethering related unittests continue to pass.

Change-Id: I6eff2573ca3fd11fabcf138c468ba517ff2daf65
(cherry picked from commit f1315c3cd6d77e812ae32fe038b4e8bf2e70d5bf)
2016-08-26 13:22:46 -07:00
Roshan Pius
b6665deef2 IpConfigStore: Changes for parsing old wifi backup
Some changes in IpConfigStore to parse old backup data. The old backup
data contained a raw byte dump of the ipconfig.txt. So, make changes in
IpConfigStore to parse the inputstream from backup data into
IpConfiguration objects.

Changes in the CL:
1. Make the |readIpAndProxyConfigurations| method static so that
it can be used as a utility for parsing the backup data.
2. Create a new version of |readIpAndProxyConfigurations| method to
accept an input stream parameter.
3. Make |writeConfig| method static so that it can be used for
unit-testing the backup migration logic.

BUG: 29075035
Change-Id: Ic074952d9f9ef143089a371e6c527470cb1c229c
(cherry picked from commit 06fe328c4fc8ea701932ef8c49012c177fcd058b)
2016-08-26 13:22:45 -07:00
Roshan Pius
ffe0abf103 WifiManager: Add new API's for backup/restore
Expose new API's to retrieve data to be backed up for Wifi
configurations and to restore configurations from the data.
BackupSettingsAgent will invoke these API's to backup/restore wifi
settings.

BUG: 28967335
Change-Id: I64e2f37a29d538d976bcc53dd2165653073b5862
(cherry picked from commit 7bc0adbcedb758ea8e829a7a6c4df39dc5f4db49)
2016-08-26 13:22:44 -07:00
Roshan Pius
820f592220 XmlUtils: Add missing readThisByteArrayXml method
Add the missing XML to byte array conversion method.

While there,
1. Fix writeByteArrayXml method to store the hex chars of the value.
2. Cleanup couple of error strings in |readThisIntArrayXml| method.

BUG: 29039296
Change-Id: I6386f7df7c5c8b7bc3bc5a268196da617209cea9
TEST: Compiles & manual testing.
(cherry picked from commit 651209b597734d34768fbb69ebf982b483167fd5)
2016-08-26 13:22:43 -07:00
Christopher Wiley
46c5e17aa8 Use an ArrayMap instead of HashMap to track tether interfaces
Since the number of tetherable interfaces should be small (e.g. <10),
the computational cost of a looking up objects in an ArrayMap is negligible,
and the memory required is less than a HashMap.

While here, remove some unused imports.

Change-Id: I3fb7091cfb93697d2fc6388b843d60f7e8e7e1a6
Test: Compiles.
(cherry picked from commit 36f6f4e394750e4989d78f38a31ab8f2f66c07f7)
2016-08-26 13:22:42 -07:00
Christopher Wiley
f972edcae7 Consolidate cleanup logic in TetherInterfaceSM.TetheredState
This pushes all TetheredState cleanup logic into a single place.
All new unittests fail without the changes to TetherInterfaceSM.

Bug: 28915272
Test: Compiles, unittests pass, WiFi tethering continues to work.

Change-Id: Ia7bf210e00e9a54f2797baebc2e5333ce314c947
(cherry picked from commit f54c5a932a9ac4a491ce775b21ff8288e40b5bad)
2016-08-26 13:22:42 -07:00
Christopher Wiley
9bc0df2482 Annotate TetherInterfaceStateMachineTest for APCT
APCT needs a little additional magic to pick up JUnit4 tests.

Bug: 28958508
Test: Tests continue to pass

Change-Id: Ia45d91bb3b06e60e3a46ffe738d4468356e066b3
(cherry picked from commit d905add4747d6060355c44dac1dce0eccd8014fb)
2016-08-26 13:22:41 -07:00
Christopher Wiley
afc46a7cbf Rely on Tethering mutex for TetherInterfaceSM
Stop passing Tethering's mutex into TetherInterfaceSM, and instead
simply rely on Tethering to acquire its own mutex when accessing
instances of TetherInterfaceSM.

While here, remove some boolean fields (previously guarded by the mutex)
which duplicate state information.

Change-Id: Ie6b2128970981786a5d64fbf700c9f3d0a6721fb
Test: Compiles, unittests pass, WiFi tethering continues to work.
Bug: 28910007
(cherry picked from commit 4bc8d6b1ac0cb7d4192c829a44d988516f0adbdb)
2016-08-26 13:22:40 -07:00
Mitchell Wills
4622c2d8b6 Rename TetherInterfaceSM to TetherInterfaceStateMachine
Change-Id: I324690b20f37cef6d58872e21b126a87d16f7ec8
(cherry picked from commit c5baad02503d17a812ee1b44cc817c7e18935ff1)
2016-08-26 13:22:39 -07:00
Etan Cohen
7f41e09b08 [NAN] Add retry count for transmitting L2 NAN messages
Bug: 28690414
Change-Id: I0a253f6d7e0d15f4bb50cae685c5e2496682cd67
(cherry picked from commit 93d3c79b54cbc913ff013102a408c6d330d6e73a)
2016-08-26 13:22:38 -07:00
Christopher Wiley
179ea1b19c Remove dead code from TetherInterfaceSM
Because no code outside of unittests ever issued these commands
to TetherInterfaceSM, we never executed any of the removed codepaths.

Change-Id: Id54f6e4eaeff8b3486cd78ddcc8c2a31011e6436
Test: Compiles.  Unittests continue to pass.
Bug: 28798823
(cherry picked from commit 2ea4166c74e70d3796b06c91f37eb03eecdf4773)
2016-08-26 13:22:38 -07:00
Christopher Wiley
0f6605721e Remove transient StartingState from TetherInterfaceSM
This state immediately switched into the TetheredState.
We can safely remove it at only the expense of a misleading state
broadcast.

Bug: 28798823
Test: runtest frameworks-services -c
    com.android.server.connectivity.tethering.TetherInterfaceSMTest

Change-Id: I295d830dbdb11717d6e05161d97787ffe871beb3
(cherry picked from commit 79e7fde00d74c2b6d329f7341029ea6b04ac2d97)
2016-08-26 13:22:37 -07:00
Christopher Wiley
279eca3de6 Expand test coverage of TetherInterfaceSM
Add tests for most normal case operations:
  - State machine startup.
  - Entering a tethered state (as USB interface and not)
  - Handling the first notification of an upstream interface
  - Handle changes in upstream interface
  - Handle unrequested teardown correctly

Bug: 28833951
Test: These tests pass

Change-Id: I2c0c9141bab9eaa92faec8de10fa653fb6236a74
(cherry picked from commit 1b3830a2afab565a38572ac5c3238a171b2d56d4)
2016-08-26 13:22:36 -07:00
Christopher Wiley
08725a8c40 Add demonstration unittest for TetherInterfaceSM
Prove that the concept works by writing a trivial test.

Bug: 28833951
Test: `runtest frameworks-services -c
  com.android.server.connectivity.tethering.TetherInterfaceSMTest`

Change-Id: I51911cef7f0d5165221845070befd085497c21a6
(cherry picked from commit 1cc6ffd2b32846996520fdf43125da3ec2bbdf49)
2016-08-26 13:22:35 -07:00
Christopher Wiley
48c7d46506 Extract TetherInterfaceSM to its own class.
Attempt to keep all existing logic in place, except:

 + Marked a constructor as public, rather than default visible.
 + Added TAG, DBG, VDBG, and decoder ringer statics.
 + Moved static constants related to USB IPs into TetherInterfaceSM.

Bug: 28833951
Test: WiFi Tethering works on angler.

Change-Id: Id961220a9045832354cfe7381e5e9c0d8f54bf90
(cherry picked from commit e3f93b02bdfde6fffd2bcbb2e1dc0785ce9f8d5a)
2016-08-26 13:22:34 -07:00
Christopher Wiley
0cbdaccf71 Make Tethering.TetherInterfaceSM more self contained
Remove references from the class into the containing class:
  - Move functionality to bring up a USB interface into the class itself.
  - Extract an interface to wrap methods where TetherInterfaceSM was
    calling into other private classes of Tethering
  - Inject necessary dependendencies into TetherInterfaceSM instances.

Bug: 28833951
Test: Compiles.

Change-Id: Ic96947417cf8734072d027b0f1cba8a1a1be7a74
(cherry picked from commit 9a509ca728fbe264e1a5a6ccd5b39ffc0b5eceb4)
2016-08-26 13:22:34 -07:00
Rebecca Silberstein
55e92882fd WifiManager: add WIFI_MODE_NO_LOCKS_HELD
Add a WifiLock mode representing that no locks are held (@hide).

Bug: 28669096
Change-Id: I774d5ff226e7c639812f9735555c8ea1ed6444af
Test: compiles and runtest frameworks-wifi
(cherry picked from commit df547e04c332e51fff159efe8bf612053a80cf75)
2016-08-26 13:22:33 -07:00
Christopher Wiley
346cceec25 Create frameworks-base-testutils lib
This permits sharing of test components used in connectivity tests.
Rename the MockLooper to TestLooper, reflecting that it is not a
true mock, but a manually controlled Looper for use in tests.

Bug: 28848133
Test: Tests consuming this library pass.

Change-Id: I57e11f9544c7bffdb02739ab2a921512b1b11874
(cherry picked from commit 07630f6bd3dbc91e2622cedfd1a21822b5f1f4b5)
2016-08-26 13:22:32 -07:00
Christopher Wiley
d2c287326f Clean up class members in Tethering.TetherInterfaceSM
Mark final fields as such.
Group mutex protected fields together with the mutex that protects them.
Always access mutex protected fields under the mutex.

Bug: 28798823
Change-Id: I96cdd5e063babb73e9f124107c5576c47801f34b
Test: Compiles, Wifi tethering continues to work on angler.
(cherry picked from commit 7b30e548a58ac96a23033db43c7aac79c86e938c)
2016-08-26 13:22:31 -07:00
Christopher Wiley
26072ea082 Move android.net.util.IpUtilsTest into a util/ directory
This makes the file structure match the package declaration.

Bug: None
Change-Id: Id6999e1857322f6dfd4caf805002398f08c378d6
Test: Eclipse stops complaining.
(cherry picked from commit 5b9903189c8a185efc8a2a64af34b7cde6f3bfe1)
2016-08-26 13:22:30 -07:00
Christopher Wiley
938f5e8dd3 Fix trivial warnings in Tethering.java
Add some missing @Override annotations.
Use template arguments to avoid explicit casting.
Ignore unclosed IndentingPrintWriter in dump().

Bug: 28798823
Test: Compiles.

Change-Id: I2cb6eb384ca23057c8059f4842b1c0d8248d03f8
(cherry picked from commit 6d475970a200f162ba6845d25bb2a777bcaa611c)
2016-08-26 13:22:30 -07:00
Christopher Wiley
b10249d64d Fix some trivial warnings in WifiP2pDevice.java
Add some missing @Override annotations, and mark some constants
as unused.

Bug: 28799169
Change-Id: I1ddef87ecb089b62e299544ae94a21d10ef42d98
Test: Compiles.
(cherry picked from commit b41e74f41ea78a30b03f3a37a0f4afb0aa1e05b5)
2016-08-26 13:22:29 -07:00
Etan Cohen
447b032334 [NAN] Add support for NAN RTT.
Provide API for NAN RTT through WifiNanManager. While NAN RTT could be executed
directly through RttManager the peer information is hidden by WifiNanManager (no
MAC address is exposed). Using WifiNanManager keeps the information hidden.

Bug: 26564277
Change-Id: I8deeb3f9e360dc05f2ea175d115f287590d50322
(cherry picked from commit fb8021c8371357dbb2b73135c89de57ef27e0131)
2016-08-26 13:22:08 -07:00
Etan Cohen
271c03738c [NAN] Remove OnNanDown notification from API
Duplicates the WIFI_NAN_STATE_CHANGED_ACTION broadcast. Remove
all state information from manager.

Bug: 28622807
Change-Id: I00632b216edb2dd74412861c4b46f01adec5a271
(cherry picked from commit cbf37593325f48168aa1aa49b12d30fe43345cc1)
2016-08-26 13:21:10 -07:00
Christopher Wiley
31a513b461 Remove unused method from NetworkManagementService
Bug: 28598325
Test: Builds

Change-Id: I6a226b3410cda4e12a9225741ec81cd12b48892f
(cherry picked from commit 2103e78e0cdc5938de479cd857325c537a9fc185)
2016-08-26 13:20:40 -07:00
Roshan Pius
72baa1de4d WifiConfiguration: Add new selection disable reasons
1. Add a new "permanently" disabled network selection status for disabling
networks after a user switch.
2. Add a new "temporarily" disabled network selection status for disabling
networks when WPS is enabled.

BUG: 28219928
Change-Id: I4ab7333ebaa830dadf73f317fd6bb81a02054235
(cherry picked from commit a6fac3eb6b29c7d370b56889cb53f6bebeeee04f)
2016-08-26 13:20:39 -07:00
Etan Cohen
5e680daad8 [NAN] Add type and nullability annotations. Update hide annotation.
Additional annotations on (what are planned to be) public APIs.
Fixed exposed API: @hide to a few new methods.

Bug: 27122760
Change-Id: Iea91de1b1c3c32a93378b5d90c1e88d994a10526
(cherry picked from commit d775a164c37294ee97f902792aa75da41d3ccf82)
2016-08-26 13:20:38 -07:00
Etan Cohen
5f47bf2199 [NAN] Add master switch to enable/disable usage of NAN APIs.
Add master switch to enable/disable usage of NAN. Tie into Wi-Fi
state machine (to enable/disable based on Wi-Fi enable/disable).
Dispatch broadcasts when NAN status changes.

Bug: 27698011
Change-Id: Iea36388443ff8d0dc26a280220022c6bdba6a0c8
(cherry picked from commit d3137af10291ff888125de747d9ee05f73f3fd8e)
2016-08-26 13:20:37 -07:00
Etan Cohen
51181fb85d [NAN] Re-factor connect/config flow
Simplify flow: configure and connect in a single call.
Prevent info leak: no longer provide configuration back to caller.
Update error status codes

Bug: 27617910
Bug: 27553226
Bug: 27579450
Bug: 27674927
Change-Id: Id7aba816a074dbbe0cb188cfe498c97dccbdcb27
(cherry picked from commit 52b3a24a029e3c5d9436a09b4175f6c49e02d92e)
2016-08-26 13:20:17 -07:00
Etan Cohen
231859c2aa [NAN] Refactor session lifecycle to clarify API & eliminate race conditions
(cherry-pick of 2a73c7fb2a4aba4dd75341414f1583e5fb1f4613)

Bug: 27257965
Change-Id: I4d7eaa6fa1f089bed2e9185f59a37f59b530975d
(cherry picked from commit 88a60495458903bee3adaf8396b5f6d71a2c0b1e)
2016-08-26 13:18:58 -07:00
Etan Cohen
564355afd6 [NAN] Removed NAN event registration - dispatch all callbacks.
All events dispatched by default - there's no reason to ignore events.
The specific identity changed events for which there are use-cases to
get or ignore is controlled through a new configuration.

(cherry-pick of a5ed693788ea64408ccf18850ee38905218ec4f4)

Bug: 27607613
Change-Id: I289a36157b55270c58311a016ef79f8746e0e0a0
(cherry picked from commit 574b3fb810f462bdcfced379b6223de9a9d15375)
2016-08-26 13:18:58 -07:00
Etan Cohen
26d5be2e5d [NAN] Consolidate publish/subscribe callback sets into single set
Merge onPublishFail & onSubscribeFail into onSessionConfigFail.
Merge onPublishTerminated & onSubscribeTerminated into onSessionTerminated.
A session is either publish or subscribe (never the two) so redundant.

(cherry-pick of 8414f5cf2bd86dcbaea1976590e838e41af554b3)

Bug: 27610709
Change-Id: I0282d17db88754428da25ee5f064b9a4805f9736
(cherry picked from commit 776ba56e53f8aab37b8a5a718fbf3bf84de65001)
2016-08-26 13:18:57 -07:00
Etan Cohen
065c07e991 [NAN] Replace session callback configuration control
Controlling session callback invocation:
- Remove event registration
- Add configurations to the subset (actually just termination) which
  can be configured through the HAL

(cherry-pick of e393f57d0de5a27d1cfd04a8c83a61559430539c)

Bug: 27607613
Change-Id: I608314cc2a9b077b4d5a2d2d0d315d55c6a7724b
(cherry picked from commit f6062eef209ae79a8a353125287aecdaa027fbea)
2016-08-26 13:18:57 -07:00
Etan Cohen
51fb9c67e4 [NAN] Expose match style configuration as public API.
Match style allows apps to configure getting a single notification
or continuous notifications (for all matches).

(cherry-pick of 8ef74534169bd3f3296e2ee42c0fda95c8518383)

Bug: 27568256
Change-Id: I9b7bd2e4e58af5c73188267d11c1288a93cf64ed
(cherry picked from commit 12213fb12d6c9af72a6244644a8253159cc62825)
2016-08-26 13:18:56 -07:00
Etan Cohen
52065684df [NAN] API cleanup - rename FLAGS.
Per API guidelines - non-overlapping constants can be (should be)
named with "FLAG".

(cherry-pick of ad3693d59b990f4994f96f6d3ca98cdbfe26723c,
 Change-Id: If8b2c0f9b2818215a64b5635e76731c8fdfd3b8d)

Bug: 27122760
Change-Id: I973d24f4f318471286087e6ae13b77cb119f01e7
(cherry picked from commit e698fab45cd0544ba63a89a03ff8f32de49e8f1c)
2016-08-26 13:18:56 -07:00
Colin Cross
611e205bbe Merge "Replace libziparchive-host with libziparchive" 2016-08-26 20:18:55 +00:00
Etan Cohen
00abb43588 [NAN] Renamed listeners to callback per API guidelines
The interfaces had multiple functions and are hence callback
and not a listener.

Note: purely a rename operation.

(cherry-pick of 0d0f0c7faf530a0fa5595dd539c3f56afeb6603a,
 Change-Id: Ib12711f56a64052455843859125d72268c465fc0)

Bug: 27122760
Change-Id: Ie1905a5d907e5b09d449af52814b1aacb6426477
(cherry picked from commit 4e1af1b80735f5d61f089432a63a23937c994546)
2016-08-26 13:18:55 -07:00
Etan Cohen
b29bbcc54c [NAN]: API update - consolidate Puslish|Subscribe Data+Subscribe -> Config
Simplify configuration and consolidate structures whose difference
wasn't very clear.

(cherry-pick of e4c50de75273efaec4e9e8db6174e0bfc07d3105,
 Change-Id: I0651cade71eb146d9ea9219baf6d2253588db3de)

Bug: 27122760
Change-Id: I6320bd4c960e4473b4bf3c28e54a7ba492fa2cf9
(cherry picked from commit 581a4f7b31e3ccefce6c022582fd99ba0313b73c)
2016-08-26 13:18:54 -07:00
Etan Cohen
982a045a8b NAN: Support multiple instantiation per UID - introduce a client ID.
Add the concept of a client ID which is used to identify a specific
(one of several) clients in all API calls.

(cherry-pick of aa36f07194b29adee881e684b63f8bbdee6097bc,
 Change-Id: I43f13d51bee8b57c6d0ba1174168288b8d6c21c5)

Bug: 26962024
Change-Id: I0e0ddf37ea9800ae97115d6af384b54b49a40d74
(cherry picked from commit 5155990c09e7212709c8e154f05960f633f21a49)
2016-08-26 13:18:54 -07:00
Colin Cross
9a1a3bcb16 Replace libziparchive-host with libziparchive
libziparchive-host is no longer necessary, and mixing libziparchive-host
and libziparchive can cause ODR violations.

Change-Id: I623c0c5579e28f26a6e1db7bd953f33ed1ca68cd
2016-08-26 11:15:17 -07:00
Neil Fuller
eefc000601 Merge "Track java.lang.reflect.Executable API changes"
am: 43ec5716aa

Change-Id: Id5159236a47ab25ae1cf6b63b7f0fb8f6325a36e
2016-08-26 15:09:33 +00:00
Treehugger Robot
43ec5716aa Merge "Track java.lang.reflect.Executable API changes" 2016-08-26 15:03:22 +00:00