565 Commits

Author SHA1 Message Date
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
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
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
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
Lorenzo Colitti
8995d85b94 Don't loop forever on 0-length options.
A malformed RA could cause the Ra constructor in ApfFilter to
enter an infinite loop while holding the class lock. This blocks
IpManager until reboot and drains the battery.

Bug: 29586253
Change-Id: Idaa46b3bc50371db076630881883807c2fa21674
2016-06-23 15:43:34 +09:00
Chris Wren
888b7a8faf assume a generous prior in the rate estimator
currently with one data point the estimator is biased high. If we don't
have any data we want to be biased low to allow the first interaction
to be an isolated burst.

Also add metrics for enqueue rate to make it easier to debug this
code in the future (currently we only have metrics after the
rate limiter).

Bug: 29379789
Change-Id: I7b1d379290a55f120d039fd29d1bc0abbc6d4932
2016-06-17 15:50:30 -04:00
Gustav Sennton
e25c8532b6 Merge "Support using uninstalled WebView packages as WebView implementation." into nyc-dev 2016-06-16 17:40:10 +00:00
Gustav Sennton
0df2c5566a Support using uninstalled WebView packages as WebView implementation.
A package can be uninstalled for the system user but still be installed
on the device. Currently, we do not use such a package as WebView
implementation which means we fall back to using the fallback WebView
package.
However, if the fallback package is not valid (because it needs to be
updated first) loading WebView will fail.

With this change we fetch allow the fetching of information from
packages that are uninstalled for the system user so that we can still
load WebView when the only valid WebView provider is uninstalled for the
system user.

Also listen to package additions/changes/removals for all users -
otherwise we won't notice when a package becomes replaced if it was
already uninstalled for the system user.

Bug: 29321185
Change-Id: Ia23c4493844877aea1b4eab7e666fd37540c4f97
2016-06-16 15:45:45 +01:00
Kevin Gabayan
68dd6233bd Compute AnyMotionDetector angle using atan2. Bug: 29232136 am: db843c913f
am: e46d4fd7ad

Change-Id: I666fc7432cf6140c938423ec4370ca7727996bd6
2016-06-15 20:49:49 +00:00
Kevin Gabayan
db843c913f Compute AnyMotionDetector angle using atan2.
Bug: 29232136

Change-Id: Ie57d0228eb42246c4ac1d7a01e2782a621b7e78f
(cherry picked from commit b070577d35436ca0f5463e6ed19a28ae431cfbfb)
2016-06-11 00:43:11 +00:00
Makoto Onuki
c29f62c738 Push DO/PO package names from DPMS to PM
Bug 29126573

Change-Id: I95ea1559f6acf5d2f0e1b0953568cdfc938e83b9
2016-06-08 11:52:13 -07:00
Paul Jensen
f8a01e8431 Don't drop IPv4 broadcast packets when WiFi multicast lock is held
IPv4 broadcast packets can be very common (e.g. every 2s) so they
need to be dropped in the general case.  They also may be critical
for certain discovery protocols, so allow them through with APF
when the WiFi multicast lock is held.

Bug: 26238573
Change-Id: I03e09a2b9c779da5da775e78b95e9e0339720eaf
2016-05-27 09:18:56 -04:00
Tony Mak
ed353f1738 Merge "Fix first notification of each app is not shown" into nyc-dev 2016-05-24 19:46:12 +00:00
Tony Mak
fd30332708 Fix first notification of each app is not shown
When app tries to post its first notification,
value of now is equal to that of mLastEventTime.
And hence getRate return a very large number.

Bug: 28902358

Change-Id: If5b5b3c46e2bb80a9b40988ba7f7d777e40cc8e7
2016-05-24 18:57:50 +01:00
Lorenzo Colitti
d954c6368f Merge "Support IPv6 multicast filtering in APF." into nyc-dev 2016-05-24 03:14:38 +00:00
Lorenzo Colitti
11e13e2175 Support IPv6 multicast filtering in APF.
For now this just drops all non-ICMPv6 packets to ff00::/8 when
mMulticastFilter is true. Multicast ICMPv6 is already mostly
dealt with by other filters - the L2 multicast filter, the RA
filter, the multicast NA filter, and ND offload.

Bug: 28393601
Change-Id: Ia7b0d4f00fac6710093befe6a726b46677a5f20b
2016-05-24 00:02:07 +09:00
TreeHugger Robot
585ff8bd12 Merge "rate limit notification enqueues" into nyc-dev 2016-05-20 16:04:50 +00:00
Chris Wren
c8673a88fe rate limit notification enqueues
This is distinct from and in addition to the limit on the number of
distinct notifications. This includes many updates to a single
notification.

Bug: 28693065
Change-Id: I5ec0911716cace91d3ad85435a5c6123b290b3a2
2016-05-20 10:40:26 -04:00
Robin Lee
d171df660e Merge "Lock down networking when waiting for always-on" into nyc-dev 2016-05-18 23:37:24 +00:00
Robin Lee
17e6183b85 Lock down networking when waiting for always-on
Fix: 26694104
Fix: 27042309
Fix: 28335277
Change-Id: I47a4c9d2b98235195b1356af3dabf7235870e4fa
2016-05-19 00:26:53 +01:00
TreeHugger Robot
4920698e17 Merge "Make some of the UID-based VPN code reusable" into nyc-dev 2016-05-17 17:30:01 +00:00
Robin Lee
4d03abcd49 Make some of the UID-based VPN code reusable
By changing some member refs into arguments and having one of the
functions create the UID range instead of adding to mVpnUsers.

This will be useful for other layers of UID filtering like having
UIDs explicitly blocked from the VPN.

Deleted one broken line of code that cleared the status intent when
a restricted profile is removed. Other than that, this commit shouldn't
change any behaviour. If it does, that's a bug.

Bug: 26694104
Change-Id: Ieb656835d3282a8ba63cc3f12a80bfae166bcf44
2016-05-13 16:03:11 +00:00
Paul Jensen
b742495cf5 Merge "ApfFilter unit test" into nyc-dev 2016-05-13 14:33:25 +00:00
Makoto Onuki
538c440c33 Remove ShortcutManager
Bug 28704708

Change-Id: If7b739adeec38d81d554fc1cf34c81194f5d67b9
2016-05-11 14:25:55 -07:00
Antonio Cansado
6965c1869a Addressing API council comments on NetworkStatsManager.
Callbacks
 - DataUsageCallback renamed to UsageCallback
 - DataUsagePolicy removed; passing in params directly to register method
 - making it an abstract class
 - passing in (networkType, subscriberId) that reached its threshold
 - renaming onLimitReached to onThresholdReached to match existing naming
 - only monitor single network,subscriberId
 - no monitoring of specific uids; using device or user wide instead

Tags
 - only owner uid can read its tags
 - exposing only TAG_NONE to match service side

BUG: 27530098

Change-Id: I2b2664da71806868a1e937d2bf4d1f234637509b
2016-05-10 13:24:16 -07:00
Paul Jensen
9132f34976 ApfFilter unit test
Bug: 26238573

Change-Id: I5171038228782bd54e91f5bcc663cc529d2c1150
2016-05-10 11:54:42 -04:00
Makoto Onuki
4d36b3a8c5 ShortcutManager: finishing touches
- Change back the throttling quota to 10 calls / day
- Foreground apps are no longer throttled, and when an app comes to
foreground the call counter will be reset.
- When the system locale changes, reset throttling for all packages
for all users.
  See LocalService.onSystemLocaleChangedNoLock() for how it's performed.
  Because the reset must happen before any other apps have a chance to
  publish shortcuts, the logic is not straightforward.

- Added an internal API to reset the throttling upon inline-reply
from a notification.

- Stop supporting icons from "content:" URIs
- Improved javadoc on several APIs.

Also internal refactor needed to this:
- ShortcutUser.getAllPackages()/getAllLaunchers() are no longer
accessible to outer code to prevent accidentally adding/removing the
content.  Outer code should use forAllPackages() / forAllLaunchers().

Bug 27923857

Change-Id: I002511193d1d33718163bb1dabe77610bde58198
2016-05-02 12:02:19 -07:00
Makoto Onuki
9ac59d0438 ShortcutManager: When app's data is cleared, remove all shortcuts,
as if it's uninstalled.

Fixes 28196831

Change-Id: I1a410372f9e344a10567b00057fa0770eac9fd76
2016-04-28 10:52:02 -07:00
Makoto Onuki
711ffe620e Merge "When app is updated, save the new version code, and update shortcuts with resource based icons." into nyc-dev 2016-04-26 00:07:59 +00:00
Paul Jensen
3f45105353 Merge "Cap number of NetworkRequests a UID can make to 100" into nyc-dev 2016-04-21 13:47:13 +00:00
Fyodor Kupolov
390802b6d3 Test coverage for new FBE functionality
Added testRemovedAccountSync, which removes account when the user is locked,
and verifies that syncDeCeAccountsLocked works as expected.

Added testPreNDatabaseMigration to test that pre-N database with existing
data is properly upgraded and migrated.

Bug: 26279712
Change-Id: I3846c626f616b1c4830965c9f0cb27fa32ce6f54
2016-04-20 10:47:58 -07:00
Paul Jensen
4e1d3fdf7a Cap number of NetworkRequests a UID can make to 100
This prevents DoSing ConnectivityService with too many requests.

Fixes: 27253080
Change-Id: Id0480d220b2f01b9ef1146bef8ead2fc8287e28d
2016-04-20 10:52:47 -04:00
Robin Lee
79c4dca2a8 Merge "Unit test for UidRange.java and UidRange.cpp" into nyc-dev 2016-04-19 19:25:41 +00:00
Robin Lee
cfe2669028 Unit test for UidRange.java and UidRange.cpp
Verifies that:
 - UidRange only accepts non-negative UIDs
 - UidRange only accepts start UID <= stop UID
 - Native implementation is in sync with java implementation (via JNI)

Change-Id: I8b412781efe9cfda6d5e666e37fe0d8f5e2b6ecc
2016-04-19 00:44:12 +01:00
Makoto Onuki
be73a8068f ShortcutManager: Categories should be Set, not List.
Bug 27923857

Change-Id: Ife859da8e66478174f6c4463316886a23e5aa4e0
2016-04-15 17:15:29 -07:00
Makoto Onuki
39686e8cde When app is updated, save the new version code, and update shortcuts
with resource based icons.

Bug 28152054

Change-Id: I14f537c08b1a0ba48dd508b0c42fc1d3ed4f5eb0
2016-04-15 12:33:15 -07:00
Makoto Onuki
0033b2a190 Remove all icon bitmaps when a publisher is uninstalled.
- Also show the directory sizes on dumpsys.

Bug 28196831

Change-Id: I3202fcd3151da3b26b436732e8103caf93aba525
2016-04-14 17:42:32 -07:00
Gustav Sennton
95f7e8e06d Fix the behaviour for explicitly switching WebView provider
Before this CL when we tried to change WebView provider through the Dev
setting and failed we would then have the setting point to the provider
used before the change. With this CL we instead let the setting point to
the intended target but also switch to the package which the
WebViewUpdateService see as most fit (rather than just reverting back to
the original choice).

Add unit tests to verify we kill processes depending on WebView
packages when switching WebView provider.

Add unit tests to ensure we can recover from trying to change provider
when there are no providers available.

Bug: 27673076
Bug: 27635535
Change-Id: Ie7bb6afdf8acf4344cfb363947929c0b492775fb
2016-04-14 16:50:32 +01:00
Gustav Sennton
45e2966da9 Merge "Update persistent WebView packages setting only when user changes it." into nyc-dev 2016-04-14 10:58:42 +00:00
Gustav Sennton
a9159040c8 Update persistent WebView packages setting only when user changes it.
To ensure that we don't permanently change WebView implementation if the
current package is temporarily uninstalled (e.g. when being replaced) we
don't update our persistent setting unless the user explicitly changes
WebView implementation (and on boot!).

Unfortunately this will means that the Dev Setting for changing WebView
implementation will work in a slightly less intuitive way. The
persistent setting is now persistent across uninstalls and installs.
I.e. the Dev Setting shows the current WebView implementation though
that could differ to the value chosen by the user since the package
chosen by the user could be uninstalled or disabled. In this case
installing/enabling that package would again make the Dev Setting point
to it.
However, as a compromise, we do change the setting at boot so that if
the currently chosen package is not valid we will change the setting so
that it points to the package we currently use instead.

Also ensure we only use WebView packages that are available-by-default
if no WebView packages are enabled.

Add unit test to ensure that if a user-chosen provider is uninstalled we
switch back to using that provider when it is installed again.
Add unit test to ensure we switch user-chosen provider at boot if the
chosen one is uninstalled.

Bug: 27673076
Change-Id: Icd27ae302798ebf695b9ef4bd4d5fd47fe4be02c
2016-04-13 16:30:03 +01:00
Paul Jensen
3e6a6fc60e Merge "If Internet probe is redirected, pass redirect destination to NetworkAgent." into nyc-dev 2016-04-13 01:33:37 +00:00
Makoto Onuki
1d616f0d88 Merge "ShortcutManager: Address API review feedback." into nyc-dev 2016-04-12 22:34:17 +00:00
Makoto Onuki
b6d3523dfb ShortcutManager: Address API review feedback.
- "delete" -> "remove"
- add/deleteDynamicShortcut() now takes a list.
- Throttling default settings is now 2 calls / hour.

- Add categories to ShortcutInfo.
- getIconResourceId() is now public

Bug 27923857
Bug 27548047

Change-Id: I8457b30e4b2f7c63ab2988648b37178fd16ea45b
2016-04-12 10:35:20 -07:00
Ricky Wai
321cfa3791 Merge "Add tests for profile keys in LockSettingsStorage" into nyc-dev 2016-04-12 16:42:56 +00:00