767 Commits

Author SHA1 Message Date
Makoto Onuki
fd24353d75 Get account features before taking lock (cherry-pick from master)
Test: cts-tradefed run cts --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.AccountCheckHostSideTest
* without having Id49f2bd5dfa80ecf35b3a23c789100ade38c2656 *

Test: adb shell am instrument -e class com.android.server.devicepolicy.DevicePolicyManagerTest -w com.android.frameworks.servicestests

Bug: 33481725
Change-Id: Ie2fe9aea87d1a7167581f4cd74ae063ef24a4567
Merged-in: I1e4dd9701a76ca366f86fdaf2fc6c282e9dbe5c1
2017-01-04 09:04:09 -08:00
Lorenzo Colitti
2f157c421a Don't loop forever on zero-length ICMPv6 ND options.
Bug: 33828433
Change-Id: Ie1905167126c8c8f3896eaa5e36cd006ca354e99
2016-12-23 13:54:50 +09:00
Daniel Nishi
cf76a16e66 Fix a bug where the package stats query timeout may crash.
This adds a null-check to verify that we got real data before
trying to use it and increases the timeout time to reduce the
likelihood of timing out.

Test: FrameworkServicesTests
Bug: 33836034
Change-Id: Ia1ad4aba05c5c4fb8688fc9fc94df344f736e396
2016-12-22 11:32:33 -08:00
Allen Hair
77a51d1274 Enable multi-dex for coverage builds to fix breakage
Test: m PRODUCT-bullhead-userdebug showcommands dist EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true SKIP_BOOT_JARS_CHECK=true WITH_DEXPREOPT=false tests
Change-Id: I6a324cbd0dc078ad2903345a069385d9f0d179ff
(cherry picked from commit aeaee4c5fe9a71949ddd701f2590559819bfe072)
2016-12-21 17:22:33 +00:00
TreeHugger Robot
639f95dd13 Merge changes from topic 'diskstats-mr2' into nyc-mr2-dev
* changes:
  Augment diskstats dumpsys to have categorization and apps.
  Add a file collector to the platform.
2016-12-21 02:14:54 +00:00
Daniel Nishi
090b2d9d6c Augment diskstats dumpsys to have categorization and apps.
This adds a new service which opportunistically saves the
file system categorization information and the app sizes. This
information is fetched during a diskstats dumpsys call from a file
stored on the disk. This allows us to keep the dumpsys running quickly
while adding information which is costly to calculate.

Bug: 32207207
Test: System server instrumentation tests
Change-Id: Id59e84b9ad38a9debf3e46e5133ef06f7353829d
2016-12-20 13:32:51 -08:00
Daniel Nishi
c7d9de59bf Add an app size collector.
The app collector gets a list of app sizes for packages on a given
storage volume. This information will be exposed as part of an
expansion of the diskstats dumpsys.

When the collector runs, it sets up a handler on a BackgroundThread
which asks the PackageManager for the package sizes for all apps and
all users. The call for the information is blocked using a
CompletableFuture until the call times out or until we've received
all of the package stats. After the stats are all obtained, the
future completes.

Bug: 32207207
Test: System server instrumentation tests
Change-Id: I3a27dc4410effb12ae33894b561c02a60322f7b0
2016-12-20 13:28:14 -08:00
Daniel Nishi
be770dce08 Add a file collector to the platform.
The file collector takes in a file path and recursively
classifies and provides the amount of storage provided by
each classification. This information can be surfaced in
Settings or to fulfill storage telemetry calculations.

Bug: 32207207
Test: System server instrumentation tests
Change-Id: Iff03260859cd4bbd11e7d60b1825115aad540d48
2016-12-20 13:24:14 -08:00
Hugo Benichi
a865790a5b DO NOT MERGE Stricter NetworkNotificationManagerTest
This patch changes NetworkNotificationManagerTest to populate extraInfo
of NetworkInfo in order to catch regressions in malformed format Strings
of log statements in NetworkNotificationManager.

Test: verified that the test fails when reintroducing the format String
bug.
Bug: 33737715

Change-Id: If14063554b8246d9d80cd222cb41c30dee121c5a
2016-12-20 05:02:28 +00:00
Hugo Benichi
85f3996d72 Merge changes I1450c126,I8926a922,I54403377,Idf216797 into nyc-mr2-dev
* changes:
  DO NOT MERGE IP Connectivity metrics: add connect() statistics
  DO NOT MERGE Fix IP connectivity metrics tests
  DO NOT MERGE IP connectivity metrics: introduce ConnectStatistics and DNS statistics
  DO NOT MERGE IP connectivity metrics: add transport field.
2016-12-19 08:31:17 +00:00
Hugo Benichi
2299a1c401 DO NOT MERGE IP Connectivity metrics: add connect() statistics
This patch adds a ConnectStats class to aggregate connect() statistics
gathered in NetdEventListenerService. ConnectStats is uploaded once a
day by IpConnectivityMetrics.

Test: $ runtest frameworks-net + new unit test
Bug: 32198976

(cherry picked from commit 4f71a15973f7048076ed10f63d708f020e1a21e0)

Change-Id: I1450c126b90b628d9f1c73ddf054b4742f5e84c5
2016-12-15 22:56:36 +09:00
Hugo Benichi
93c0de0a35 DO NOT MERGE Fix IP connectivity metrics tests
So that test assumptions match previous changes in ipconnectivity.proto.

This patch also tags metrics tests with @SmallTest.

Test: $ runtest frameworks-net
Bug: 32561414
Bug: 32198976

(cherry picked from commit 80df43ea8a4286f2b7e0678be35dbca3f16f3766)

Change-Id: I8926a92248ac2d46fc78749afc40bc5f0de10878
2016-12-15 21:31:25 +09:00
Erik Kline
473355f96b Have IpManager track L2-L4 signaling traffic required for IP connectivity.
Test: as follows
    - built and flashed
    - observed logcat
    - observed "dumpsys wifi ipmanager"
    - runtest BlockingSocketReaderTest passes
    - runtest ConnectivityPacketSummaryTest passes
Bug: 21859053
Bug: 26101306
Bug: 31742572
Bug: 31707128
Bug: 33531488

Change-Id: Ibecaf809dcc1813924b25749e8ba8eb2d4bdf114
2016-12-15 17:16:48 +09:00
Michal Karpinski
4c47adef60 DO NOT MERGE [DPM] Management and retrieval of network logs
This CL follows up on ag/1530343 and adds:
1) Various network events.
2) Retrieval method in DPM and APIs in DeviceAdminReceiver.
3) Extension of NetworkLogger and it's NetworkLoggingHandler.

Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/NetworkEventTest.java
Bug: 29748723
Change-Id: I42a1a477e7c75c109a3982f809c22732b814e8b2
2016-12-13 17:19:22 +00:00
Michal Karpinski
c3abd34cfe DO NOT MERGE [DPM] DO can start network logging and listen for events
This CL adds:
1) Setter and getter in DPM to manipulate logging switch (retrieval
method to come in a subsequent CL(s)).
2) A way for DPM to register to listen for events.
3) Skeleton of NetworkLogger class (more to come in subsequent CL(s)).

Bug: 29748723
Change-Id: I5c04662ccc6febd2ba294b0eaca1ed1da9c16e47
2016-12-13 17:15:38 +00:00
Hugo Benichi
8b43f6eb02 Merge "DO NOT MERGE IpConnectivityMetrics: rate limit ApfProgramEvents" into nyc-mr2-dev 2016-12-13 03:55:32 +00:00
Hugo Benichi
6674f7a3b4 Merge "DO NOT MERGE IpConnectivityMetrics reads buffer size in settings" into nyc-mr2-dev 2016-12-13 03:54:24 +00:00
Hugo Benichi
97d10ffcad DO NOT MERGE IpConnectivityMetrics: rate limit ApfProgramEvents
This patch uses the previously introduced TokenBucket to rate limit
ApfProgramEvents, still allowing for burst of ApfProgramEvents when a
new interface is set up (due to ipv4 provisioning, multicast lock, ipv6 RAs
triggering new APF program events in short amounts of time).

Test: new test in IpConnectivityMetricsTest
Bug: 1550402

(cherry picked from commit e1c173d2240a8eedf7685c9371087dc047a6931f)

Change-Id: Ibe41e9a76db36ea502697a5f19fc0d91c40a3087
2016-12-13 10:20:03 +09:00
Hugo Benichi
ff0b58627f DO NOT MERGE IpConnectivityMetrics reads buffer size in settings
Test: IpConnectivityMetricsTest passes. Also manually changed the new
setting and verified the buffer size is as expected after flushing the
buffer.
Bug: 32198637

(cherry pick from commit 05686dbb6b965eb1a54591d2ed2334337886c6ee)

Change-Id: Ie7ca1638533479601c5983bb6e54705003561b6c
2016-12-13 10:20:03 +09:00
Hugo Benichi
31cf55bdfe DO NOT MERGE IpConnectivity metrics: add version number
This patch adds a version field to ipconnectivity.proto and populates it
to 2, which is the logical version number for NYC-MR2.

Test: IpConnectivity{EventBuilder,Metrics}Test pass
Bug: 32127906

(cherry picked from commit d680d4c856f54bea0c60dea74ba4204822391e49)

Change-Id: I5f37633afd9ec82f5402c5b6670fe2febae82a14
2016-12-13 10:19:13 +09:00
Hugo Benichi
0cc49bb5bc DO NOT MERGE APF: also drop any ICMPv6 RSs
Test: new unit test + $ runtest franeworks-net
Bug: 32833400

(cherry picked from commit f98182ef5e80ede5de7f2c2a5f40fc92a46c9704)

Change-Id: I4c46304b9dc8105123fc02a29f99dbc835248eb0
2016-12-09 16:08:52 +09:00
Michal Karpinski
b97196b1de Merge changes from topic 'netd-benchmark-and-logging-nyc-mr2-dev' into nyc-mr2-dev
* changes:
  DO NOT MERGE Add connect event reporting
  DO NOT MERGE Extending DNS event reporting
2016-12-06 10:16:37 +00:00
Christine Franks
cc2801296d TwilightService: Ignore (0,0) coordinate location updates
Location providers may erroneously return (0.0, 0.0) when they
fail to determine the device's location. These location updates
can be safely ignored since the chance of a user actually being
at these coordinates is quite low.

Bug: 31009261
Test: added TwilightServiceTest; both tests pass

Change-Id: Ie9d7d10f81ade9b0be10f98ed74978539efaa658
2016-12-05 11:19:42 -08:00
Michal Karpinski
70444d3ad5 DO NOT MERGE Extending DNS event reporting
This adds hostname, array of addresses, total count of IP addresses
and uid to the existing pipeline.
Currently ignores the new data it receives, further work will be
done in the subsequent CLs.

Test: for now just the benchmarking, in the future unit and CTS

Bug: 29748723

(cherry picked from commit 14c9d2d0df7fab2b0470c3c404f600d87d4f0f93)

Change-Id: I3941b8d6fc1dd578e2af6ed4d3c3d0a722c39918
2016-12-02 17:21:28 +00:00
Michal Karpinski
3db0a14ab0 Merge "DO NOT MERGE Rename the DnsEventListenerService to NetdEventListenerService" into nyc-mr2-dev 2016-12-02 09:26:31 +00:00
Michal Karpinski
7f9014bb9d DO NOT MERGE Rename the DnsEventListenerService to NetdEventListenerService
The service will be extended to include listening for connect events as well.

Test: this is just a renaming change

Bug: 29748723
Change-Id: I073187e354fc987222ec0108d7f0d3a422397d5e
2016-11-24 17:05:02 +00:00
Makoto Onuki
fac592f64c Fix issue with apps restored to lower versions.
When restoring to a new device, if a restored app is not compatible
with the old version (e.g. lower version or different signature),
then we won't restore shortcuts, which is working as expected.

However when it happens, the shortcut manager forgot to "un-shadow"
the package information, causing the app to not have shortcuts at all.

Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest1 -w com.android.frameworks.servicestests

Bug 32999759

Change-Id: I89832360114de0ce1c57d763bcaccab4fdb87b6d
2016-11-21 13:49:31 -08:00
Calvin On
4bc78eba6f Add option to skip and avoid captive portals.
Test: ConnectivityServiceTest updated with test cases.
Test: Manually tested against att-wifi in B42.
Bug: 30222699
Change-Id: Ibe63942da04748ab0406e24e0f44be31d47710a0
(cherry picked from commit be96da11ccb5dd500f920c3ba90d350857293b3d)
2016-10-20 18:50:46 +00:00
Michal Karpinski
6dbf67fc48 Don't expose default strong auth timeout as constant
The admin can instead use the value of 0 to reset to default.

Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java

Bug: 31430135
Change-Id: I0d6b29ca4eca65d7ca72a8975a0c28c9050a946c
(cherry picked from commit 943aabd11cce3ab453762d3912395363720e1f5d)
2016-10-12 09:34:12 +00:00
Hugo Benichi
ea2f7a4f05 Merge "Reject DHCP packets with no magic cookie" into nyc-mr1-dev 2016-10-07 02:22:35 +00:00
TreeHugger Robot
69544fd74d Merge "Catch runtime exceptions when parsing DHCP packets" into nyc-mr1-dev 2016-10-06 17:10:45 +00:00
Hugo Benichi
006e061301 Reject DHCP packets with no magic cookie
This patch adds an explicit check in the DHCP packet parser for
rejecting packets without a magic cookie, instead of relying on the
top-level try-catch-all in the parser.

This allows to add to DHCP error metrics this specific error.

It also allows to add two poor man's fuzzing tests that tries to find
additional gaps in the DHCP packet parser by
 - trying to parse all subslices of a valid offer packet.
 - trying to parse random byte arrays.

Test: covered by previously introduced malformed DHCP packet unit tests
      + additional fuzzing tests.
Bug: 31850211
Change-Id: If53c9ba9df78d7604ec018c9d67c237ae59c4833
2016-10-06 21:22:29 +09:00
Hugo Benichi
e0ea7fecd6 Catch runtime exceptions when parsing DHCP packets
This patch adds a try catch all to DHCP packet parsing so that
DhcpClient does not choke on malformed packets, brinding down with it
the whole framework.

Test: added new unit tests catching the issue fixed in this patch.
Bug: 31850211
Change-Id: I3c50a149fed6b2cbc4f40bb4f0e5bb2b56859b44
2016-10-05 21:58:26 +09:00
Erik Kline
23cdacbec6 Refactor "avoid bad wifi" logic into a utility class
am: 065ab6ee40

Change-Id: I4a6ad3791ac551b0d64b37dd4e2afef1e8e8ee10
2016-10-04 07:47:52 +00:00
Erik Kline
065ab6ee40 Refactor "avoid bad wifi" logic into a utility class
Additionally, add this utility class to IpManager for compatibility
verification.  A follow-on CL will make use of IpManager's local
AvoidBadWifiTracker.

Bug: 31827713
Change-Id: If8c56c3f8076d6a5157ea180e361bbdadc2bc1dd
2016-10-04 15:07:42 +09:00
Hugo Benichi
d953bf853d Captive portal detection uses 3rd fallback probe
This patch adds the possitibility to send a 3rd fallback validation
probe in sendParallelHttpProbes when neither the 1st http probe nor the
https probe came back with a conclusive answer.

This 3rd probe is only used for trying again captive portal detection
and does not return success, so that network validation always fails if
the https probe fails.

In addition, the url reveals a captive portal is now sent to the
CaptivePortalLoginActivity so that all three probes can use different
urls.

Bug: 29367974

Change-Id: I7385fde1aa1316d94aac350af0e956cb193aa4ee
2016-09-28 23:12:31 +09:00
Makoto Onuki
18fb24c5d3 Merge "Fix DPM unit tests, also fix a log message." into nyc-mr1-dev 2016-09-23 15:34:40 +00:00
Hugo Benichi
00a42d4c88 IpConnectivityLog uses new metrics service
This patch connects existing IpConnectivityLog to the new
IpConnectivityMetrics service:
  - IpConnectivityLog is now an independent class that pushes events
    directly to the new IpConnectivityMetrics service.
  - DnsEventListenerService is moved from MetricsLoggerService to
    IpConnectivityMetrics.
  - this patch also features end to end tests from IpConnectivityLog to
    IpConnectivityMetrics dumpsys output.

Bug: 31254800
Change-Id: I4fe4a209eedde2814d5f13c574a1a0d854bd05c9
2016-09-22 23:08:37 +09:00
Hugo Benichi
50a84c6210 Add ipconnectivity.proto to services jar
This patch moves ipconnectivity.proto and companion serialization
classes from /vendor/google/app/ConnectivityMetrics into the framework
services jar.

This will allow to implement a dumpsys interface for IpConnectivity
metrics events defined in android.net.metrics that output metrics as
a serialized proto.

Bug: 31254800
Change-Id: Ia4449103fd7222c9d899352fea2dce47a790a49c
2016-09-22 22:21:41 +09:00
Hugo Benichi
b1af5e51c5 ConnectivityMetricsLoggerTest
This patch transforms the IpConnectivityLogTest to test instead the base
class ConnectivityMetricsLogger.

The current test will not be relevant anymore after b/31254800 is
resolved.

Bug: 31254800
Change-Id: I8dc3374450e5f1f87ab1e6f372ad2d2beb25dc48
2016-09-22 22:21:41 +09:00
Lorenzo Colitti
aab02df195 Support "don't ask again" in the avoid bad wifi dialog.
am: 165c51c0eb

Change-Id: Ic6a1917a83e2d847bd673790e2c36f7316ca7acd
2016-09-20 17:14:50 +00:00
Lorenzo Colitti
165c51c0eb Support "don't ask again" in the avoid bad wifi dialog.
This contains the following changes:

1. Make NETWORK_AVOID_BAD_WIFI a tristate: 0 means never avoid
   bad wifi, unset means prompt the user, 1 means always avoid.
2. Look at NETWORK_AVOID_BAD_WIFI only if the carrier restricts
   avoiding bad wifi (previously, we relied on the setting being
   null and defaulting to the value of the config variable).
3. Add an avoidUnvalidated bit to NetworkAgentInfo to track
   whether the user has requested switching away from this
   unvalidated network even though avoiding bad wifi is generally
   disabled. This is set to true when the user selects "switch"
   in the dialog without setting the "Don't ask again" checkbox.
4. Add a hidden setAvoidUnvalidated API to ConnectivityManager to
   set the avoidUnvalidated bit.
5. Additional unit test coverage.

Bug: 31075769
Change-Id: I1be60c3016c8095df3c4752330149ce638bd0ce1
2016-09-20 16:03:53 +09:00
Makoto Onuki
6ad5f92512 Fix DPM unit tests, also fix a log message.
Bug 31446501

Change-Id: I37debbe2f4e983fb8bad026f8dd9bd91b7448dce
2016-09-19 14:23:02 -07:00
Makoto Onuki
845096ffa3 Merge "Don't update publisher version code without scanning manifest" into nyc-mr1-dev 2016-09-16 18:50:27 +00:00
Lorenzo Colitti
40b707ed39 Unit tests for avoid bad wifi networks setting.
am: 73b20938c7

Change-Id: I6491f1a93f93f222e23ef6e5e437631556637e44
2016-09-15 16:05:45 +00:00
Lorenzo Colitti
73b20938c7 Unit tests for avoid bad wifi networks setting.
Bug: 31075769
Change-Id: I21ba20df59ddce5731ef1ebe8846b3f00578a674
2016-09-15 23:45:07 +09:00
TreeHugger Robot
4efd735a76 Merge "Add test coverage for background networks." into nyc-mr1-dev 2016-09-14 03:17:47 +00:00
Makoto Onuki
c8c3329dd9 Don't update publisher version code without scanning manifest
- It was (theoretically) possible for shortcut manager to update
the version code for a publisher package without rescanning manifest
shortcuts, if backup happens right after unlocking a user before
SM searches for updated packages.  If it happens, then SM will not
scan the manifest for this package until it's updated next time.

So don't refresh the version code during backup, which we only
have to do for launchers but not publishers.

- Also fix the owner-user-id for launchers.  (Luckily it's not causing
any issues.)

Bug 31402152

Change-Id: I5d898eb3882b74edaca8b2d5f960849370ffc23b
2016-09-13 11:23:39 -07:00
Lorenzo Colitti
e14d49ad59 Add test coverage for background networks.
Bug: 23113288
Change-Id: Idad62f5f025825f99007ccf7b20f530dc3cf6daa
2016-09-13 12:02:13 +09:00
Hugo Benichi
7d21eaedad ApfFilter: take into account IPv4 subnet prefix
When IPv4 is provisioned on an interface with Apf capabilities,
ApfFilter will only keep track of the raw ipv4 address, with no
information about the subnet or prefix length.

This patch adds the missing prefix length information to ApfFilter. This
allows to calculate the subnet broadcast ipv4 address for more
precise ipv4 broadcast filtering when the multicast lock is not held.

Bug: 30231088

Change-Id: Iebaec040703647c4ced30bb585be173e97a1fae5
2016-09-13 10:54:47 +09:00