252137 Commits

Author SHA1 Message Date
Etan Cohen
fc3c0a0582 [NAN] Fix bad merge use rethrowFromSystemServer
Added 'throw' to the 'e.rethrowXXX()'. Not needed but seems
to be the accepted style.

Change-Id: I75e42d68ee6092699a55e26ee05151373139606d
(cherry picked from commit cb34ec8f3a8dd40f7c49181b008de7314735ca66)
2016-08-29 11:26:53 -07:00
Mitchell Wills
07e317c3cd Add Log.wtf when transitionTo is used improperly
Using transitionTo in exit/enter (except in the terminal state) is
documented as undefined behavior and may cause unexpected results.
The current implementation appears to finish the current transition and
then transition to the new target state.

TEST=flash and play with the phone, no sign of immediate WTFs

Change-Id: I38a34b85c43d53c51514339587fc1269a069a454
(cherry picked from commit 8d3ed21583a8d83047cee1735cf669e131809e73)
2016-08-29 11:26:53 -07:00
Mitchell Wills
18af49395c Ensure BSSIDs are correctly aged out in settings view
When verbose logging is on, recent BSSIDs are displayed under the
network. This ensures that the BSSIDs are aged out after a period of
time instead of based on a fixed size LRU cache. This prevents BSSIDs
that are no longer present from appearing in the results.

FIXED=30711015
TEST=setup two APs, observe both BSSIDs in settings, turn off one,
     observe it disappearing after a short period of time.

Change-Id: Id2b2ccd0899eae8d4e2e1c2b3ae9409136a8c948
(cherry picked from commit b744d6e865e4141cd19cdf279f75f30c3d6590af)
2016-08-29 11:26:52 -07:00
Etan Cohen
4503dc6fba [NAN] Provide calling package name to service
Useful for permission checks.

Bug: 30000323
Change-Id: I8c7f06cff346437aa24ca5da9822cbd7b20c59c4
(cherry picked from commit 7531a28e2611039a8120305c14a96b8c61fff563)
2016-08-29 11:26:52 -07:00
Svetoslav Ganov
40f8b92518 Add WiFi toggle prompts - framework
If permission review is enabled toggling WiFi on or off
results in a user prompt to collect a consent. This applies
only to legacy apps, i.e. ones that don't support runtime
permissions as they target SDK 22.

bug:28715749

Change-Id: I020601e208c0736005bcabc7b7b77b96eee45b03
(cherry picked from commit d3663c04a721e0848dd3e9179c84ba585d91839d)
2016-08-29 11:26:51 -07:00
Mitchell Wills
009ae99582 Reenable the unit tests for StateMachine
In order to make the tests run a few methods must be made public so that
they can be called from a class loaded by a different class loader.

Fixed: 28217358
Change-Id: I98ce1e952a78528ae6ebd3a0e843c9ddfe937337
(cherry picked from commit 36afe5b5cc000620d77150437ba21503c44c87eb)
2016-08-29 11:26:51 -07:00
Christopher Wiley
5de073a6b0 Remove WiFi related methods from NetworkManagementService
These are no longer necessary, since WiFi manages its own details.

Bug: 30041228
Change-Id: Ia3824da43367ae74d3f3a204318cfe5470d74957
Test: Compiles
(cherry picked from commit 212b95f587f4af637fb2429f29f7d0add1bd251f)
2016-08-29 11:26:50 -07:00
Mitchell Wills
079b2f342c Don't pull in external/junit through mockito
android-support-test provides a different version of junit

FIXED=30481239

Change-Id: I6d8f52d5f82b4c9905da8cc4a6ca79216eba9e26
(cherry picked from commit d3868cfc63cd814e43367586f5706f39ec1cd5a9)
2016-08-29 11:26:50 -07:00
Roshan Pius
47fb68bd24 WifiConfiguration: Expose NetworkSelectionStatus strings
Make the status/disable reason string arrays public to be used in
XmlUtil for restoring of data.

BUG: 30448209
Change-Id: If8201df9397edcc4251e5b6aa4d613212fb576ad
TEST: Unit tests
(cherry picked from commit 23173a2efa45e5159a9b958e31cf345f8f0c2347)
2016-08-29 11:26:49 -07:00
Svetoslav Ganov
6bc2a92a59 Add Bluetooth toggle prompts - framework
If permission review is enabled toggling bluetoth on or off
results in a user prompt to collect consent. This applies
only to legacy apps, i.e. ones that don't support runtime
permissions as they target SDK 22.

Also added a configuration resource which controls whether
permission review mode is enabled. By default it is not and
an OEM can change this via an overlay. For now we also keep
the old mechanism to toggle review mode via a build property
which is still used and will be removed when clients have
transitioned.

bug:28715749

Partial cherry-pick of core/res/res/values/{config,symbols}.xml only
Change-Id: I94c5828ad6c8aa6b363622a26ff9da4fc2e2fac7
(cherry picked from commit ac69be543f89ea6e9a27204492e0a170d9b3450e)
2016-08-29 11:26:49 -07:00
Etan Cohen
0e70bdd7a5 [NAN] Add LV utilities (TLV with T size of 0).
NAN uses LV (not TLV). Expose an LV variant of TLV to make API
cleaner.

Bug: 30096512
Change-Id: I74b4c514d50f1df5750b521bd68a5e2d832d92c3
(cherry picked from commit 009b1fcb85ab8f8eb4ab5f3e125127b449df77cb)
2016-08-29 11:26:48 -07:00
Etan Cohen
2b1e7eabfc [NAN] Fix TlvElement member names - reflect public access.
Bug: 30096512
Change-Id: Ic2ab61e891bead6f6e8f13d9ac311ead8fecba5b
(cherry picked from commit e40b4d344e7e4529016fefe9f06f478504949706)
2016-08-29 11:26:48 -07:00
Christopher Wiley
090e9de648 TetherUtil: Use ConnectivityManager for tethering
In the past, enabling the SoftAP would cause tethering to happen because
of some unfortunate side effects.  This is no longer the case, and
using WifiManager for this purpose is not a good idea.

Bug: 30147602
Test: Can toggle tethering on/off via all of settings, quick settings,
      and quick quick settings.

Change-Id: Iebbfc6c48b3e8e3fa52d235594ded3502f5801a3
(cherry picked from commit 26bd4efcaaad4a866310d6421909645e81167d1f)
2016-08-29 11:26:47 -07:00
Etan Cohen
c579d20618 [NAN] TLV utilities iterator - throw correct exception
Make sure that iterator.next() validates that next element exists -
otherwise throw the exception specified by the interface.

Bug: 30096512
Change-Id: I327da433e3f1181e272c81ee503cbe8aab323f7e
(cherry picked from commit 3e5ac12302a78216e706be239dceb5175646bea0)
2016-08-29 11:26:47 -07:00
Etan Cohen
ee58a68285 [NAN] Modify arguments from "array, length" to "array"
Arrays carry their own lengths. There's no need to provide mechanism
to 'shave' the array - could be done explicitly by caller if needed.

Bug: 29617160
Change-Id: Ib135aa04145f400163cd1a8908dfca4590b4480d
(cherry picked from commit 0a5b7efcb20d2a57c990f11469580edb41a976d6)
2016-08-29 11:26:47 -07:00
Etan Cohen
44cb6ef1de [NAN] NAN System Api: RTT
Modify visibility of startRanging [NAN RTT] to SystemApi. Matches the
visibliity of the RttManager API.

Change-Id: Ia92de9885d0b38dfce74484f437bd122dd53cbf6
(cherry picked from commit ab9ef45971fc41bc078ad1362845309ef02f62f9)
2016-08-29 11:26:46 -07:00
Christopher Wiley
05f86d1eec Properly disable WiFi tethering
When Tethering.stopTethering(<wifi>) is called, we set
mWifiTetheringRequested to false and request the AP be torn down.
Previously, we would discard WIFI_AP_STATE_CHANGED_ACTION Intents,
because mWifiTetheringRequested was set to false.  This would in
turn cause us to leave tethering enabled, because we only tear down
tethering upon noticing that the interface is going down
(as signalled by WifiManager via this Intent).

In the past, this was covered up because we would tear down tethering
when the interface was taken down.  Now that we rely on SoftApManager
to notify us of AP state, we need to pay very close attention to what
is being said about the state.

Bug: 30124308
Test: Can toggle tethering on and off reliably on shamu, bullhead,
      angler with no SIM.

Change-Id: If46a8ee11cf4c07c5cc336523f5e5f00273500ec
(cherry picked from commit e52b24a0c52c6e29ea99760c920724f4143ac605)
2016-08-29 11:26:46 -07:00
Etan Cohen
2d3face59a [NAN] Provide inteface MAC address to app.
Expose NAN discovery interface MAC address to app. Required
to enable OOB discovery with other NAN functionality
(e.g. data-path).

Bug: 30000035
Change-Id: Id3c336a61a36522d7011557c805bc3c5307747a1
(cherry picked from commit d097f8a4e520378b9e15f294e773b033ea920268)
2016-08-29 11:26:45 -07:00
Etan Cohen
6060d85878 [NAN] Add (T)LV validation testing
Test for validity of a (T)LV. Used in construction of publish and
subscribe configuration (both Tx and Rx filters).

Bug: 30007730
Change-Id: Ibf2179121d45c582bb054c06ec2a765ed0927040
(cherry picked from commit c13b9f6b7d132e06e09b8604b095bdf59ec42307)
2016-08-29 11:26:45 -07:00
Erik Kline
f834ddaf28 Add IPv6 tethering coordinator
Add an IPv6TetheringCoordinator to TetheringMaster StateMachine, which
receives and processes NetworkState updates and passes the necessary IPv6
information to the revelant TetherInterfaceStateMachine.

Add an IPv6TetheringInterfaceServices to TetherInterfaceStateMachine, which
is responsible for adding local network routes and managing an IPv6
RouterAdvertisementDaemon.

Partial cherry-pick of only interfaceType method
Bug: 9580643
Change-Id: I3eaae460b80752e2115359d7bde873a1e9ea515a
(cherry picked from commit 1eb8c69bed1615e9502e94b1a676773ed28abfd9)
2016-08-29 11:26:44 -07:00
Christopher Wiley
9c820cdebf Stop listening for WiFi interface status changes
Bug: 29931437
Test: Can toggle tethering on and off repeated on shamu and an
      upcoming device, both devices without a SIM.
Test: Can toggle tethering on and off repeated on an
      upcoming device with a T-Mobile SIM.

Change-Id: I4986b1a5f6ae9b45010bd30639806f7ed63a605c
(cherry picked from commit d30aaeb2148edbc0c7a97699a41c450c0591b983)
2016-08-29 11:26:44 -07:00
Etan Cohen
01db037f45 [NAN] Add validity checks for service name
Add checks that the service name is valid per spec (see bug for
details). Stores internally as a byte[] for further propagation.

Bug: 30000106
Change-Id: Iab413aba6755c97bfca0332d6eaa21f636e47f3f
(cherry picked from commit adfbfb3a939f5662cb62cdd6b5d7cce5494a159e)
2016-08-29 11:26:43 -07:00
Etan Cohen
a77565d3fc [NAN] Fix assumption about Strings containing single-byte characters.
Code assumed that each character was represented by a single byte.

Change-Id: I92ea63f7273379ed1035f10c207d41e3e352bf38
(cherry picked from commit 9a6161c61cb99460afa2c575f39c046391fa1c97)
2016-08-29 11:26:43 -07:00
Etan Cohen
85b1a5b786 [NAN] NAN data-path API: network specifier
Adds network specifier API. These are used in creating a connectivity
request through ConnectivityManager. The network specifier provides
mechanism to pass information to the network factory.

Bug: 26564277
Change-Id: Ib5b88685e033a2957644f2e9cff39a70712ac7b5
(cherry picked from commit 15849dc463278b44b191cd39aa7d31b0de9ee825)
2016-08-29 11:26:42 -07:00
Rebecca Silberstein
934535bfe5 DO NOT MERGE StateMachine: remove final from SendMessage
Removed final from public sendMessage and sendMessageDelayed commands to
unblock unittest development.  This allows tests to verify calls to
sendMessage and sendMessageDelayed.

Also fixed one checkstyle error with import order.

BUG: 28593024
Change-Id: I26e02c3d75049d385ded7891c4fc9967273c27be
TEST: builds
TEST: runtest frameworks-wifi
(cherry picked from commit 0dbeb9e01a7041cbee61b8db7eb8d7562c2a3e6c)
2016-08-29 11:26:42 -07:00
mukesh agrawal
4e5e2d1e11 wifi: allow config of default+verbose ring buffers
Add the ability to set the size of ring buffers for
both logging modes (default and verbose).

BUG=29225988
TEST=manual

Manual test: add some logging statements to WifiLogger,
verify that the default ring buffer size is 32KB,
and that the verbose ring buffer size is 1024KB.

Change-Id: I4b7bc0da41ba66d15f8e2b6f3c3d6d615691d507
(cherry picked from commit 6ae111026c558daceb0c879368ca2fb385079769)
(cherry picked from commit 6c7a90669ba72c55d5fc03a7b3ed4afadc575290)
2016-08-29 11:26:41 -07:00
Mitchell Wills
0a9fb8093b Don't save the anonymous identity for EAP-SIM/AKA/AKA-Prime
wpa_supplicant can update this value when authenticating so if the
framework writes it back the new value can be overwritten.

TEST: Patch was validated by original reporter
      Enterprise tests pass (b/29608435)

Change-Id: If359b4ca625371fbdb68177c7cdb6498c3a519a1
Fixes: 28161335

(cherry picked from commit a464a9fce8d160d2bbac3aeea3b23ecc7bb179a0)
2016-08-29 11:26:10 -07:00
Yi Kong
f897e1c3b6 Merge "Track getxattr API change"
am: c4c4a1e76e

Change-Id: I66059536d5dfb0999743656f095d557ddf25ff70
2016-08-29 08:05:05 +00:00
Treehugger Robot
c4c4a1e76e Merge "Track getxattr API change" 2016-08-29 07:57:30 +00:00
Yi Kong
c44a6e08e2 Track getxattr API change
Bug: 30992227
Change-Id: I788b3e51a536c7df7896f622038fe762f9848a2a
2016-08-27 12:16:44 +01:00
Chih-Hung Hsieh
e33f3472f3 Merge "Fix misc-macro-parentheses warnings in hwui/tests."
am: e2732e5e38

Change-Id: If801b6f30a280ed8382c37765e2623eb3520ebcc
2016-08-26 23:53:25 +00:00
Treehugger Robot
e2732e5e38 Merge "Fix misc-macro-parentheses warnings in hwui/tests." 2016-08-26 23:45:07 +00:00
Chih-Hung Hsieh
474081eee1 Fix misc-macro-parentheses warnings in hwui/tests.
* Add parentheses around macro parameters.
Bug: 28705665

Test: build with WITH_TIDY=1
Change-Id: I04f6dd1a180ed1191bf68b685facf6fb9020b4b0
2016-08-26 15:19:47 -07:00
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