Commit Graph

807 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
5409851f43 Merge "Disable comparison in user release builds" into tm-dev 2022-06-21 08:58:23 +00:00
Junyu Lai
a5e1428fbc Disable comparison in user release builds
This CL disable the comparison mechanism introduced
in previous beta releases to stop receiving log.wtf signals
from beta users.

This CL only affects logging on user release builds.

Ignore-AOSP-First: Parent CLs are not in aosp yet
Test: 1. NetworkStatsServiceTest
      2. manual test with script
Bug: 233752318
Change-Id: I7047106b1019c29460d6633b148f501ffa62f139
2022-06-21 08:57:06 +00:00
James Mattis
99f342e229 Send callback if ip provisioning is interrupted
A callback is expected to be sent on either success or failure when the
EthernetManager#updateConfiguration API is called.

Currently, if this API is called for an active interface and marked
restricted, after the IP provisioning process is started in
EthernetNetworkFactory, the interface will then processe all the
onNetworkUneeded requests for the newly restricted network. Assuming no
apps have requests for this particular network or restricted networks,
the network will be stopped once the outstanding network request count
reaches zero.

If provisioning hasn't completed yet for the original
updateConfiguration call, the original callback will be cleared out on
stop and will never notify the original caller of
EthernetManager#updateConfiguration whose call was aborted.

Bug: 235907515
Test: eth unit and cts tests
Change-Id: I91359272c07e090039049370ba9f438546fce3ad
(cherry picked from commit 265eba982d)
Merged-In: I91359272c07e090039049370ba9f438546fce3ad
2022-06-17 23:30:52 +00:00
Aaron Huang
befadfe3d1 Disable NetworkStatsRecorder Test
Disable test since it won't pass until prebuilt module updated.

Ignore-AOSP-First: urgent fix and will cherry-pick immediately after.
Bug: 233828210
Bug: 234099453
Test: FrameworksNetTests
(merged-in tag is pointed to an unrelated CL that only exists on
aosp and its downstreams, to make this CL doesn't get merged in aosp downstreams)

Change-Id: I81b43e6a1410e7cf241487ef213acf0cbcfd019d
Merged-In: I47fb59334d00ae7fee91c5694548b3cf89b09b2d
2022-06-17 15:34:48 +08:00
Aaron Huang
692baa7d71 Add wipeOnError flag to NetworkStatsRecorder
If reading data happens exception while doing data migration,
the file will be deleted by legacy recorders. This would cause
legacy persistent data being lost and cannot be retrieved by
any method. To avoid the files being deleted, add a wipeOnError
flag to recorder which indicates this recorder will wipe on
error or not . If the flag is set to true then deletes all files
when it throws, otherwise keeps all files.

Ignore-AOSP-First: urgent fix and will cherry-pick immediately after.
Bug: 233828210
Test: FrameworksNetTests:NetworkStatsRecorderTest
Change-Id: Id7a3d8bebf8a00d814f9e84bf4c10d927e6ff749
2022-06-17 15:23:24 +08:00
Patrick Rohr
ab3e14471b Merge "Revert "Temporarily ignore ethernet tests until prebuilts are updated"" into tm-dev 2022-06-16 19:22:10 +00:00
TreeHugger Robot
3481337b6b Merge "Revert "Temporarily disable testUidStatsForTransport"" into tm-dev 2022-06-16 07:43:45 +00:00
TreeHugger Robot
705d85bf3f Merge "Revert "Temporarily disable NsdService unit tests"" into tm-dev 2022-06-16 07:43:03 +00:00
Patrick Rohr
3a7645fc75 Revert "Temporarily ignore ethernet tests until prebuilts are updated"
This reverts commit 14f45a3e98.

Reason for revert: Reenabling tests after prebuilts are updated.

Bug: 233824546
Change-Id: I6883ea55dd390e7fe102b735e0b757e838d9eff6
Merged-In: I8e806b3b884f2e0b6c1a1d2fffdb9a99c5dd60e8
2022-06-15 18:55:48 +00:00
Junyu Lai
f955184698 Disable fallback when comparison result is different
Follow-up from ag/18452103, where we add fallback code that runs
with the importer to make sure they are identical.
When the result is different, we'll take the result from fallback
code to minimize the rollout risk. However, since the OEMs might
change the importer implementation. The fallback code would no
longer valid and that makes OEM modified code not working. Hence
the fallback code must be disabled before release.

This change keeps comparison enabled for all cases to keep getting
signals from beta users. And will switch it to read overlay value
for OEM to debug their solution.

Ignore-AOSP-First: Parent CLs are not in aosp yet
Test: 1. NetworkStatsServiceTest
      2. Test all datasets with script
Bug: 233752318
Change-Id: I869ff05297149bde6e13a204bd8c5a4fece75de0
2022-06-15 19:49:33 +08:00
Remi NGUYEN VAN
b3740168ae Revert "Temporarily disable testUidStatsForTransport"
This reverts commit 87a9bc7edb.

Reason for revert: Prebuilts are updated and tests should pass now

Change-Id: I6dd793e124a2781b9d74d28b7da7ac9f15f41d89
Merged-In: Ib1d180cc799dde94ada642ce752623b4b65f1e31
Merged-In: I44dda14cae265e600010c6f8efe1471ac481c6ea
Merged-In: I702a75e91be0bb582f9cbd7b4a23e1286f8252cf
2022-06-15 02:15:23 +00:00
Remi NGUYEN VAN
d86035f662 Revert "Temporarily disable NsdService unit tests"
This reverts commit a3ce8f8438.

Reason for revert: Prebuilts should be newer now

Change-Id: I717288c9a2e25fb9bc358a61beb8877144ed078c
Merged-In: Ib1d180cc799dde94ada642ce752623b4b65f1e31
Merged-In: I44dda14cae265e600010c6f8efe1471ac481c6ea
Merged-In: I702a75e91be0bb582f9cbd7b4a23e1286f8252cf
2022-06-15 02:13:23 +00:00
Motomu Utsumi
608015f24e Add 3rd deny firewall chain for OEM
Bug: 208371987
Test: atest
CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testFirewallBlocking
ConnectivityServiceTest

Change-Id: Ib521fa02f6a19270cb88a3d85321bda822516c78
(cherry picked from commit 1d9054ba5f)
Merged-In: Ib521fa02f6a19270cb88a3d85321bda822516c78
2022-06-07 05:35:36 +00:00
TreeHugger Robot
52f0fe0c47 Merge changes from topic "cherrypicker-L34800000954905788:N57900001270872696" into tm-dev
* changes:
  Ignore new test until prebuilts are updated.
  Add deny firewall chain for OEM
2022-06-03 16:45:05 +00:00
Patrick Rohr
1f8bd41e87 ethernet: broadcast state change for server interfaces
Also update the test to ensure mFactory.hasInterface is mocked to match
mFactory.getInterfaceState: previously it would be called by the factory
in the mocked getInterfaceState, but the new code calls it directly.

Bug: 171872016
Test: atest EthernetManagerTest
Change-Id: I9ac959f181c88a7992991923b98a836f2833fa88
(cherry picked from commit f33f276b29)
Merged-In: I9ac959f181c88a7992991923b98a836f2833fa88
2022-06-03 21:32:31 +09:00
Lorenzo Colitti
09130e00ae Merge "Verify if the VPN app has been added into power save whilte list" into tm-dev 2022-06-03 11:49:35 +00:00
Motomu Utsumi
9cd4726890 Add deny firewall chain for OEM
Bug: 207773349
Bug: 208371987
Test: atest
CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testFirewallBlocking
--iterations 50 && atest ConnectivityServiceTest --iterations 10

Change-Id: I60d5540821abcced03356f366775f16ee369d7f9
(cherry picked from commit d980149817)
Merged-In: I60d5540821abcced03356f366775f16ee369d7f9
2022-06-03 11:06:46 +00:00
Remi NGUYEN VAN
87a9bc7edb Temporarily disable testUidStatsForTransport
The test cannot pass in branches that use an old prebuilt tethering
module.

Bug: 234099453
Test: atest NetworkStatsServiceTest
Merged-In: Ib1d180cc799dde94ada642ce752623b4b65f1e31
Merged-In: I44dda14cae265e600010c6f8efe1471ac481c6ea
Merged-In: I702a75e91be0bb582f9cbd7b4a23e1286f8252cf
Change-Id: I7ce44dac1b5d730f84f882ba8ae1b741a633e765
2022-06-03 15:52:32 +09:00
Aaron Huang
a2f1cf3576 Hold wifi and mobile interfaces since boot in NetworkStatsService
In current design, the interface will be removed from the list if
the network disconnected which will cause getUidStatsForTransport()
returns unexpected snapshot to caller since the list is empty.

This change also remove interface name from all entries before
the method returns the result.

Ignore-AOSP-First: non-AOSP CL is included in the same topic
Bug: 231514741
Test: FrameworksNetTests
      manual test
Change-Id: Ie60829a65d0d9b5b63ad353695a820c0586e3665
2022-06-03 15:51:19 +09:00
lucaslin
dd9b794e5c Verify if the VPN app has been added into power save whilte list
Bug: 234104087
Test: atest FrameworksNetTests:VpnTest
Change-Id: I2aa99b8ea8dbe668a45782f50a4a0ac82e72b7a2
(cherry picked from commit 802fa5d0ec)
Merged-In: I2aa99b8ea8dbe668a45782f50a4a0ac82e72b7a2
2022-06-03 05:49:21 +00:00
TreeHugger Robot
3caf95c8fc Merge changes from topic "cherrypicker-L15200000954882986:N47600001270136565" into tm-dev
* changes:
  Temporarily disable NsdService unit tests
  Fix service resolve on tethering downstreams
2022-06-02 10:49:33 +00:00
Lorenzo Colitti
9b4d5b7f9e Merge changes from topic "vpnmanager-events-T" into tm-dev
* changes:
  Test VpnManager event for CATEGORY_EVENT_NETWORK_ERROR
  Test VpnManager event for CATEGORY_EVENT_IKE_ERROR
2022-06-02 10:12:53 +00:00
Remi NGUYEN VAN
a3ce8f8438 Temporarily disable NsdService unit tests
The unit tests cannot pass before a newer prebuilt of Tethering is used,
as bootclasspath classes that it tests would be outdated.

This change is not merged in downstreams that build from source (changes
in the merged-in tags are not related changes, however).

Bug: 234099453
Test: atest

Merged-In: Ib1d180cc799dde94ada642ce752623b4b65f1e31
Merged-In: I44dda14cae265e600010c6f8efe1471ac481c6ea
Merged-In: I702a75e91be0bb582f9cbd7b4a23e1286f8252cf
Change-Id: I5b0cb131fcb5feb6b3cfd70e95ba7c5e54fa2294
2022-06-02 17:45:00 +09:00
Junyu Lai
2a21ffa679 Merge changes from topic "increment-crash" into tm-dev
* changes:
  Fix get summary does not include the latest bucket
  Add unit test for MultipathPolicyTracker
2022-06-01 09:45:05 +00:00
Remi NGUYEN VAN
0102c9440a Fix service resolve on tethering downstreams
Tethering downstreams do not have NetworkAgents, and although they have
a netid of 99, Networks with netId 99 are not usable by apps for most
connectivity APIs.

Recent refactoring in NsdService adds the Network of a found service
into its NsdServiceInfo, and uses that network to resolve the service.
In that case the Network has netId 99 and resolving the service fails.

Avoid that problem by:
 - Keeping the Network field null when a service is found on a tethering
   downstream; this avoids giving apps a confusing and unusable Network
   with netId 99
 - Using the interface index found during discovery to resolve the
   service, if the app uses the NsdServiceInfo that was obtained from
   discovery to resolve. If not, all interfaces will be used to resolve,
   as per legacy APIs.

Bug: 233979892
Test: atest NsdServiceTest
      Also manual test with 2 devices connected via hotspot
Change-Id: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a
(cherry picked from commit 1a8ee102d3)
Merged-In: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a
2022-06-01 05:35:36 +00:00
Junyu Lai
e971f15288 Fix get summary does not include the latest bucket
In internalGetSummaryForNetwork, the history object will not
include the latest bucket because of the logic in
NetworkStatsHistory#recordHistory would only include buckets
that atomically occur in the inclusive time range.

This makes querySummaryForDevice callers who are also sensitive
to the latest bucket fails.

This CL revert the behavior back to S, in T this is temporarily
changed after aosp/1937268.

Also, for test purpose, this CL change System.currentTimeMillis to
use mClock when querying.

Ignore-AOSP-First: Urgent fix
Test: NetworkStatsServiceTest#testGetLatestSummary
Bug: 233733267
Change-Id: I55e2a5d953622b68da36a9b8d3e57c88d57543b0
2022-06-01 09:34:30 +08:00
Junyu Lai
9fc333024f Add unit test for MultipathPolicyTracker
This CL adds unit test to test onThresholdReached event
would unregister and re-register usage callback.

Ignore-AOSP-First: Urgent fix
Test: MultipathPolicyTrackerTest#testOnThresholdReached
Bug: 233733267
Change-Id: I6e43ae93055009d91b0795a4466f2c02f4403c0a
2022-05-30 22:16:42 +08:00
lucaslin
affb72d2b8 Test VpnManager event for CATEGORY_EVENT_NETWORK_ERROR
Bug: 191413541
Test: atest FrameworksNetTests:VpnTest
Change-Id: Idffd5f5f8fc6614281f3fb0884228a797d783fe3
(cherry picked from commit cfec723ef9)
Merged-In: Idffd5f5f8fc6614281f3fb0884228a797d783fe3
2022-05-28 06:01:17 +00:00
lucaslin
744c8967e5 Test VpnManager event for CATEGORY_EVENT_IKE_ERROR
Bug: 191413541
Test: atest FrameworksNetTests:VpnTest
Change-Id: Iebc0ac281eb03fac9626c64e44cdd14be1462d89
(cherry picked from commit 827b44daea)
Merged-In: Iebc0ac281eb03fac9626c64e44cdd14be1462d89
2022-05-28 06:01:13 +00:00
Patrick Rohr
d84c99cad2 Merge changes from topics "cherrypicker-L37800000954756398:N06400001268122372", "cherrypicker-L61200000954646707:N00900001267167505", "cherrypicker-L64000000954631044:N08200001267145803" into tm-dev
* changes:
  Temporarily ignore ethernet tests until prebuilts are updated
  Add CTS tests for EthernetNetworkProvider changes
  Move EthernetNetworkFactory to using the NetworkProvider API
  Add NetworkOfferCallback to NetworkInterfaceState
  Change NetworkInterfaceState to hold NetworkProvider instance
  Improve waiting for interface added or removed
  Always wait for interface to be up in EthernetManagerTest
  Assume all Ethernet interfaces have an MTU of 1500.
2022-05-25 23:31:09 +00:00
Patrick Rohr
14f45a3e98 Temporarily ignore ethernet tests until prebuilts are updated
Using Merged-In line of commit that adds the CTS tests to prevent this
change from going anywhere it should not.

Unfortunately, the test runner does not properly parse tests ignored at
the class level.

Test: TH
Bug: 233824546
Ignore-AOSP-First: only needed on tm-dev
Change-Id: Ia911cdfc39614ccda5f2cf8bfd1d913cf80a60ae
Merged-In: I8e806b3b884f2e0b6c1a1d2fffdb9a99c5dd60e8
2022-05-25 11:54:36 -07:00
Patrick Rohr
0ccff8a30b Move EthernetNetworkFactory to using the NetworkProvider API
This CL makes EthernetNetworkFactory inherit from NetworkProvider rather
than NetworkFactory. The name of the class is purposefully unchanged to
make the code review easier (it will be changed to
EthernetNetworkProvider in a follow up).

As part of the conversion, NetworkInterfaceState now registers a
NetworkOffer when the link comes up and unregisters it when the link
goes down. It updates the existing offer when capabilities change (by
calling registerNetworkOffer with an already registered
NetworkOfferCallback).

This change should fix existing refCount issues. When a NetworkOffer is
first registered, it receives callbacks for all existing requests. This
is the main problem with the NetworkFactory implementation where only
one NetworkOffer is registered when the factory is first created; so
when interfaces come up, they do not receive callbacks for existing
requests.

Test: atest EthernetNetworkTest
Bug: 197548738
Change-Id: I5e8e4673d2ed04bc1a0c8d232a8772edfff65b5d
Merged-In: I5e8e4673d2ed04bc1a0c8d232a8772edfff65b5d
2022-05-25 11:50:30 -07:00
Lucas Lin
81f05b9011 Merge changes from topics "CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED", "CATEGORY_EVENT_DEACTIVATED_BY_USER" into tm-dev
* changes:
  Test VpnManager event for CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED
  Test VpnManager event for CATEGORY_EVENT_DEACTIVATED_BY_USER
2022-05-25 10:20:18 +00:00
TreeHugger Robot
898a5f9acc Merge "Fix crash when decrementing data usage request" into tm-dev 2022-05-24 23:52:30 +00:00
Junyu Lai
ecec6d9350 Address comment at ag/18491259 and ag/18486388
Ignore-AOSP-First: in a topic with internal-only changes
Test: TH
Bug: 230289468
Change-Id: Id91fabb47b542d8526d6aa787b5947238c3934fb
2022-05-25 00:41:49 +08:00
Junyu Lai
a69db7de03 Fix crash when decrementing data usage request
When unregistering, if the caller process is dead. The system
can unregsiter for the caller. But the request decrement should
be counted onto the caller uid instead of system uid.

Ignore-AOSP-First: Urgent fix
Test: NetworkStatsObserversTest#testUnregister_knownRequest_invalidUid_doesNotUnregister
Bug: 233580307
Change-Id: I85aee8f395739929bc7086883ace81ac1ecd0730
2022-05-24 23:41:05 +08:00
Junyu Lai
bfc68ac08a Persisting status int on the device if fallback happened
This CL also stop from incresing "successes" counter if the
importer finishes with fallback.

Ignore-AOSP-First: in a topic with internal-only changes
Test: manual
Bug: 230289468
Change-Id: I88fce1b2d0dea3772a8b31df8f8fa93bf13bffad
2022-05-23 17:48:55 +08:00
lucaslin
12c30b9e82 Test VpnManager event for CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED
Bug: 225010642
Test: atest FrameworksNetTests:VpnTest
Change-Id: I078be4e00470efd9d7a2a87b40919116b99c83b8
(cherry picked from commit 0772c169b5)
Merged-In: I078be4e00470efd9d7a2a87b40919116b99c83b8
2022-05-23 08:34:39 +00:00
lucaslin
1c0e75628b Test VpnManager event for CATEGORY_EVENT_DEACTIVATED_BY_USER
Bug: 191413541
Test: atest FrameworksNetTests:VpnTest
Change-Id: Idc876275b88c2f4ddeb85c43d37d5f657b0f307b
(cherry picked from commit c5bf088ced)
Merged-In: Idc876275b88c2f4ddeb85c43d37d5f657b0f307b
2022-05-23 16:32:27 +08:00
Patrick Rohr
64468d1494 Move ipconfig file inside apex data directory
In order to support rollbacks, the ethernet ipconfig file needs to be
written to the data apex's data directory. We still need to support
reading from the legacy location to be backwards compatible.

If the apex file path already exists, then read the IP configuration
from there directly, otherwise, check if the legacy file path exists,
if yes, read the legacy IP configuration and copy it to the new apex
file path.

Support for default IpConfiguration is also being removed in this CL.
The default IpConfiguration (configuration entry for interface "0")
was a way to transition from supporting a single interface to
supporting multiple interfaces and was introduced in P. Every device
that has used such a configuration and has connected to an ethernet
network since upgrading to P+ has already removed the "0" config and
has assigned it to the first interface (probably "eth0"). There has
never been an API to set this, but if someone wanted to install a
default IpConfiguration, they could just configure "eth0" instead.

Bug: 224919694
Test: atest EthernetConfigStoreTest --iterations
Test: manually test
      - adb push <fake ipconfig.txt> /data/misc/ethernet/
      - adb reboot
      - read the IP config from legacy path and the same config
        file is created in the apex file path
      - adb reboot
      - read the IP config from the apex file path directly
Change-Id: Ifb82a5d7fa13d17ea8fd3a42a19cd020cb95e26a
(cherry picked from commit 47641d75d9)
Merged-In: Ifb82a5d7fa13d17ea8fd3a42a19cd020cb95e26a
2022-05-20 07:50:55 +00:00
TreeHugger Robot
0657071494 Merge changes I91e987d6,I03e7cda7 into tm-dev
* changes:
  Changing automotive ethernet allowed UIDs check
  Allow ethernet on automotive to set allowed UIDs
2022-05-20 03:29:14 +00:00
James Mattis
a2ea68df28 Changing automotive ethernet allowed UIDs check
Updating the automotive allowed UIDs check to only work if the
capabilities have a single transport equal to ethernet.

CP of https://r.android.com/2101472

Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I91e987d6b943a3c5986ab88553a6eef0d479b079
Merged-In: I91e987d6b943a3c5986ab88553a6eef0d479b079
2022-05-19 09:13:31 -07:00
Junyu Lai
ac6213123a Merge changes from topic "stats-migration" into tm-dev
* changes:
  Skip PersistentIntTest on S- device
  Don't clobber existing history entries.
  Ensure NetworkStats migrated snapshot is identical
  [MS82.1] Support network stats data migration process
  Add a PersistentInt class.
2022-05-19 14:54:01 +00:00
James Mattis
45f3e41a6a Allow ethernet on automotive to set allowed UIDs
Allow ethernet factories on automotive devices to set the allowed UIDs
on NetworkCapabilities.

CP of https://r.android.com/2072767

Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I03e7cda75f1c530e0d0e4a756330bc9847a96668
Merged-In: I03e7cda75f1c530e0d0e4a756330bc9847a96668
2022-05-19 07:48:05 -07:00
Junyu Lai
c3f7cabe59 Skip PersistentIntTest on S- device
This class is only used in the service runs on T+ devices.
Thus run this test on S- device does not make senses.

Ignore-AOSP-First: in a topic with internal-only changes
Bug: 230289468
Test: atest ConnectivityCoverageTests:PersistentIntTest
      on S device
Change-Id: I97a29df17ef9ee9ab373655f045cdb5c820e06ef
2022-05-19 15:09:42 +08:00
Xiao Ma
9cae3c8a99 Fix the ethernet setting API bug.
After turning off the ethernet settings via api, the ethernet service
can still be started when plugging-in the cable. Improve the api by
ignoring the upcoming interface unsolicited event listener callbacks
and register new interface observer once the ethernet setting is enabled
again.

Bug: 231933028
Test: atest testListenEthernetStateChange_unsolicitedEventListener
Change-Id: I1b1cb7d157f023fca82d75592168bd360a6fa6e1
(cherry picked from commit 94a00dfc64)
Merged-In: I1b1cb7d157f023fca82d75592168bd360a6fa6e1
2022-05-19 01:58:15 +00:00
Lorenzo Colitti
b36e57a004 Don't clobber existing history entries.
Currently, adding a history to a NetworkStatsCollection.Builder
will overwrite any history that was previously passed in with the
same key. This breaks the importer (which is the primary/only
caller of this code), because the importer re-uses the same
NetworkStatsCollection object to import multiple files.

Instead, simply add any passed-in entries after the ones that
were already there. Require the caller to pass in entries in
order, because NetworkStatsHistory internally assumes that
entris are always sorted.

Ignore-AOSP-First: in a topic with internal-only changes
Bug: 230289468
Test: manually verified this unbreaks the importer
Change-Id: Ic8647ff28fca78d579d5f759f96a864877f8158b
2022-05-18 23:51:03 +08:00
Remi NGUYEN VAN
3776d862e2 Ensure NetworkStats migrated snapshot is identical
Read migration snapshot both from the platform API and the legacy
method, and Log.wtf if they are different. Use the legacy method data if
they are.

This ensures that using the migration API is a no-op, and that errors
are reported (through Log.wtf) if it would not have been if used as-is.

Ignore-AOSP-First: in a topic with internal-only changes
Test: NetworkStatsServiceTest
Bug: 230289468
Change-Id: I857ad18183d63d1aa16e89f89eb24009648720a2
2022-05-18 23:51:03 +08:00
Junyu Lai
27e0a9833e [MS82.1] Support network stats data migration process
This includes:
1. Provide NetworkStatsRecorder#importCollectionLocked to
   allow caller to write a NetworkStatsCollection object to
   a standalone file.
2. Do not clear the collection in NetworkStatsRecorder#
   CombiningRewriter, this is safe since pending set will
   still be cleared during forcePersistLocked.
3. Implement the migration process, including recovery and
   safety measures.

Test: NetworkStatsServiceTest NetworkStatsCollectionTest
Test: manual test with
      adb shell device_config put tethering \
      netstats_store_files_in_apexdata true
      adb shell device_config put tethering \
      netstats_import_legacy_target_attempts 1
Ignore-AOSP-First: in a topic with internal-only changes
Bug: 230289468
Change-Id: Ic2002cbfd5a6b3c2226fa8dab22481f8ce656574
2022-05-18 23:34:30 +08:00
Lorenzo Colitti
76c0f6f0e8 Add a PersistentInt class.
This implements a simple integer written to disk backed by
AtomicFile.

Bug: 230289468
Test: new unit test
Ignore-AOSP-First: in a topic with internal-only changes
Change-Id: I1c73c8ac2429f92153cfba3b006b4374e75e65df
2022-05-18 20:54:50 +08:00