Commit Graph

612 Commits

Author SHA1 Message Date
Jeff Davidson
3bbf8f320d Revert Network Stats API stub for tracking of metered networks.
Bug: 25813958
Change-Id: I9d2835b7bacfffef05b1588f1301afc70f5f582f
2016-01-29 10:36:52 -08:00
Zoltan Szatmary-Ban
4ff8b948b0 Introduce DEVICESUMMARY access level to NetworkStatsAccess.
Apps with PACKAGE_USAGE_STATS app op or READ_NETWORK_USAGE_HISTORY
granted can query the summarized device data usage (but not individual
uids running in other users or profiles).

Bug:26677052
Change-Id: Id51631638f338a8cf48172c9b41746228a335084
2016-01-26 13:59:52 +00:00
Jeff Davidson
131806f111 Implement roaming tracking in NetworkStats summary queries.
Whether a network is deemed roaming or not was already being tracked
as part of the NetworkIdentitySet, so the underlying data store
already tracks roaming and native data separately. However, this data
was being aggregated together in NetworkStatsCollection#getSummary,
since the NetworkIdentitySet is converted to an iface name for the
purposes of matching, and the iface name will be identical whether or
not the iface is considered roaming. Now it is separated.

Also fixes a long-standing bug in NetworkIdentitySet where an identity
read from a saved file would always be considered roaming == false,
even if it wasn't at the time it was written.

Bug: 25813438
Change-Id: I11ab5b51182ed8da7af8fde468df065f9fdc3dad
2016-01-19 16:57:51 -08:00
Jeff Davidson
b7ab1f9da6 Define new APIs for metering and roaming network stats buckets.
These are analagous to the state buckets for tracking whether usage is
incurred while the app is in the foreground or background. We will
additionally track whether data usage is incurred over a metered or
unmetered network, and whether it is incurred over a roaming or native
network.

The APIs are not implemented in this CL; the existing buckets are
still returned with METERING_ALL and ROAMING_ALL to indicate that this
is not yet being tracked.

Bug: 25813438
Bug: 25813958
Change-Id: I76dd3dd063ed28ef5579ca3a978570532e7836bc
2016-01-06 14:15:46 -08:00
Jeff Davidson
8dc22e3e90 Relax permissions around NetworkStatsManager APIs.
Currently, access to network usage history and statistics requires a
signature|privileged permission, an AppOps bit (associated with the
PACKAGE_USAGE_STATS permission), or device/profile ownership. Once
access is granted via one of these mechanisms, it generally applies to
any UID running in the same user as the caller.

This CL expands access as follows:

-Any app can access its own usage history with no extra requirements.
-Carrier-privileged applications can access usage history for the
entire device.
-Device owners can access per-UID breakdowns for usage. Previously
they could access the summary for the whole device, but not the
individual breakdowns.

We simplify the permission model by defining three access levels -
DEFAULT (own app only), USER (all apps in the same user), and DEVICE
(all apps on the device), and propagate these levels throughout.

Finally, this CL fixes an apparent bug in
NetworkStatsSerice#hasAppOpsPermissions - if the AppOp bit was in
MODE_DEFAULT, hasAppOpsPermission would always return false instead of
falling back to the PackageManager permission check.

Bug: 25812859
Bug: 25813856
Change-Id: Ic96e0776e2a4215a400163872acea1ededfaced9
2015-12-14 17:16:37 -08:00
Jeff Sharkey
7b124cb8e6 Add tagging variants for DatagramSocket.
Oops, we missed these along the way.

Bug: 25799174
Change-Id: I4ad368f9faee4b1996d605534dce4c2b23dbe200
2015-12-04 15:32:07 -07:00
Daichi Hirono
dbccfac26f Add capability to receive FD with NativeDaemonConnector.
BUG=25755372

Change-Id: I2888219b77cf04f4bf749d5518ff62ba16258f2d
2015-12-04 14:16:00 +09:00
Christopher Tate
c1c71fdff5 Introduce socket stats tag for restore traffic
As well as system API for emplacing it.

Change-Id: If33fbd23552261efe3b00d75c22ff823564f43e6
2015-11-10 11:13:12 -08:00
Jeff Sharkey
6d3c359289 Yell when calling installd with PM lock held.
As a matter of policy, we should never be holding the mPackages lock
while calling down into installd.  This little bit of logic helps us
catch accidental cases where this happens.

Change-Id: I676c81df43ef936ffd36290d45a79429630c1b4b
2015-11-03 14:44:20 -08:00
Jeff Sharkey
c109706f45 Yell if NDC callers are holding bad locks.
The current MountService design heavily depends on down-callers not
holding any locks, since the vast majority of events are unsolicited
and bubble up to the framework.

This simple API gives us an easy way to track down people calling
while holding a lock they shouldn't be.

Bug: 25443096
Change-Id: Ifcbda95f00d5be8c1b88d58ca67927e76c713c3e
2015-11-03 10:39:45 -08:00
Jeff Sharkey
077f2c9c6b Merge branch 'mnc-dr-dev-plus-aosp' of /usr/local/google/game/mirror/googleplex-android_googlesource_com/platform/frameworks/base into mnc-dr-dev-plus-aosp 2015-10-20 18:34:32 +00:00
Jeff Sharkey
385f839a2c Merge "Ignore network policies with missing IMSI." into mnc-dr-dev am: 38463bb950 am: 5d7604323f
am: 3b30aae6e7

* commit '3b30aae6e702cbdad4ada69b76e4bc50fa2e161c':
  Ignore network policies with missing IMSI.
2015-10-20 18:33:48 +00:00
Jeff Sharkey
1bb0a51092 Merge "Ignore network policies with missing IMSI." into mnc-dr-dev am: 38463bb950 am: 5d7604323f
am: 3b30aae6e7

* commit '3b30aae6e702cbdad4ada69b76e4bc50fa2e161c':
  Ignore network policies with missing IMSI.
2015-10-20 18:30:16 +00:00
Jeff Sharkey
32933d6da3 Ignore network policies with missing IMSI.
In rare cases, we might have created a network policy before an IMSI
was available.  Because this policy is persisted, and we incorrectly
think that it always applies, we end up annoying the user when data
usage goes over the 2GB default warning threshold.

This patch fixes the network matching logic to ignore these empty
network policies when present.

Bug: 24972775
Change-Id: Id26499b6716121dddf0f2c05b848b0bed5995e72
2015-10-19 16:52:08 -07:00
Elliott Hughes
8dc3833e83 resolved conflicts for a884d81e to stage-aosp-master
Change-Id: Ice485967fa96f13786024b6939b826638e906ff0
2015-09-24 10:01:32 -07:00
Daniel Micay
aa49801a92 constify JNINativeMethod function pointer tables
Change-Id: I4036c924958221cbc644724f8eb01c5de3cd7954
2015-09-22 17:10:35 -04:00
Zoltan Szatmary-Ban
06a45679aa Remove uids with empty history from NetworkStats uid enumeration
Bug: 23018174
Change-Id: I1a482280599e0f5da18a208e727653d4bd4107ec
2015-08-14 16:21:52 +01:00
Jeff Sharkey
b1f84a006f Merge changes I9971c466,Ib42474fd into mnc-dev
* changes:
  Kill MediaProvider during drastic changes.
  Use best volume description for MTP.
2015-07-08 21:55:54 +00:00
Jeff Sharkey
6928e332da Kill MediaProvider during drastic changes.
Sadly MediaProvider makes a ton of assumptions about storage paths
not changing.  To ensure that it picks up radical storage changes,
kill it and let it restart to pick up new paths.

Also give ourselves a longer timeout when benchmarking.

Bug: 20275423
Change-Id: I9971c4667dabdc685cb23528443f085f152c461d
2015-07-08 14:06:40 -07:00
Zoltan Szatmary-Ban
f34946fabb Expose time-interval detail query on INetworkStatsSession
Also, force polling when a session is opened for NetworkStatsManager.

Bug: 21864554
Bug: 21754685
Change-Id: I24ea822c2d5bc1421ec7ee65d0cfe27cf02dd69e
2015-07-07 17:36:54 +01:00
Todd Kennedy
fd6ca6c8d4 Handle volume benchmark timeout
If a volume benchmark operation times out, we don't want to show
a cryptic toast message. Instead, we return a very large integer
[eg Long.MAX_INT]. The storage wizard can then use this value
to show an appropriate dialog if it chooses.

Bug: 21376364
Change-Id: I3d97336e19c93511cfff2cbdb2f07ab033a1143d
2015-06-23 14:40:32 -07:00
Jeff Sharkey
8806907cc9 Update file size formatting.
Per UX, default strings should have space between value and units
resulting in "12.3 GB".  Add a formatting variant that returns the
various components for callers who want to build their own strings.

For now there is only one mounted emulated volume at a time, and
it's always the primary storage, so give it the default rootId to
keep old Uris working.

Change-Id: Ifcc72a91a6b397ee65dc92642153286186eb64ac
2015-06-15 21:39:28 -07:00
Zoltan Szatmary-Ban
567b6f86e7 Replace renamed reference to NetworkStats in javadoc
Bug: 21572680
Change-Id: Iad43af4d8a6d178f3396f23a74f1568e6faed311
2015-06-04 14:15:47 +01:00
Zoltan Szatmary-Ban
43a69f7a67 Rename NetworkUsageStats -> NetworkStats
Also making other changes to Data Usage API as requested by API review.

Bug: 20823478
Change-Id: Id766c5a725c856da9d8883d73ae788fc1472440a
2015-05-13 17:53:17 +01:00
Prerepa Viswanadham
24d204021b Merge commit '17455a3' into master_merge 2015-05-01 10:12:11 -07:00
Zoltan Szatmary-Ban
3a0699a153 Fix potential NPE on devices without DPMS
Bug: 20563108
Change-Id: Ie2bda65c834ddad9db8753f7616c2754072551cd
2015-04-30 10:38:24 +01:00
Jan Nordqvist
23b9a0d58d Added parameter to avoid having a stream opened,
and with that, file truncated on no-op.

Change-Id: I5813e4fd269c639a437e17f2554efa4db735a8ba
2015-04-23 15:42:55 -07:00
Qiwen Zhao
bbed6c22f2 Merge KDataBinder/ from platform/vendor/google/prototypes/data-binding to tools/data-binding/ 2015-04-08 15:58:36 -07:00
Chong Zhang
1f71c037e3 Merge "fix the flash caused by missing setMatrix() when surface size changes" 2015-04-06 21:35:15 +00:00
Zoltan Szatmary-Ban
fec3d1ff1c Data usage API: any uid is accessible to system apps running in any user
This CL mostly affects Settings app as it can run in a user different
than UserHandle.OWNER. Since it is a system app it should have access
to all uid's data usage, regardless of which user it is currently running
in.

Bug: 19967498
Change-Id: I4a7787134d998457f7e2a1029183d44d9584083e
2015-03-31 18:09:20 +01:00
Jeff Sharkey
6f2ba5ec43 Progress towards dynamic storage support.
Storage devices are no longer hard-coded, and instead bubble up from
whatever Disk and VolumeBase that vold uncovered, turning into
sibling Java objects in MountService.  We now treat vold events as
the source-of-truth for state, and synchronize our state by asking
vold to "reset" whenever we reconnect.

We've now moved to a model where all storage devices are mounted in
the root mount namespace (user boundaries protected with GIDs), so
we no longer need app-to-vold path translation.  This also means that
zygote only needs to bind mount the user-specific /mnt/user/n/ path
onto /storage/self/ to make legacy paths like /sdcard work.  This
grealy simplifies a lot of system code.

Many parts of the platform depend on a primary storage device always
being present, so we hack together a stub StorageVolume when vold
doesn't have a volume ready yet.

StorageVolume isn't really a volume anymore; it's the user-specific
view onto a volume, so MountService now filters and builds them
based on the calling user.  StorageVolume is now immutable, making
it easier to reason about.

Environment now builds all of its paths dynamically based on active
volumes.  Adds utility methods to turn int types and flags into
user-readable strings for debugging purposes.

Remove UMS sharing support for now, since no current devices support
it; MTP is the recommended solution going forward because it offers
better multi-user support.

Simplify unmount logic, since vold will now gladly trigger EJECTING
broadcast and kill stubborn processes.

Bug: 19993667
Change-Id: I9842280e61974c91bae15d764e386969aedcd338
2015-03-30 19:46:23 -07:00
The Android Automerger
d70d9eec14 merge in master-release history after reset to master 2015-03-28 01:05:55 -07:00
Wenchao Tong
efd57ecab8 Keep debug information in NetworkStats files
Create two special SETs.

SET_DBG_VPN_IN is used by individual applications to know
how much traffic of the NetworkIdentity was actually moved
from a VPN app.
SET_DBG_VPN_OUT is used by the VPN app to know how much
traffic of the NetworkIdentity was deducted.

A debug application can restore the raw stats by these
entries.
  raw_traffic = recorded_entry (TAG_NONE, SET_ALL)
              + recorded_entry (TAG_NONE, SET_DBF_VPN_OUT)
              - recorded_entry (TAG_NONE, SET_DBF_VPN_IN)

The two debug SETs are not returned by
NetworkStatsService.openSession(). These debug entries are
retrieved by NetworkStatsCollection.dump().

Bug: 19536273
Change-Id: I03ef9f7667f5f2f48cbe3f6b11447fe7ead8ad3b
2015-03-27 13:49:13 -07:00
The Android Automerger
ced7642e4b merge in master-release history after reset to master 2015-03-26 01:03:50 -07:00
Zoltan Szatmary-Ban
b293e46f2c Data Usage public API
Added new API consisting of android.app.usage.NetworkUsageManager and
android.app.usage.NetworkUsageStats. Through them data usage on a
network interface can be programmatically queried. Both summary and
details are available.

Bug: 19208876
Change-Id: I0e0c4b37ae23ad1e589d4b0c955b93f28ba4333e
2015-03-25 15:53:38 +00:00
The Android Automerger
bde8f08a69 merge in master-release history after reset to master 2015-03-14 01:05:17 -07:00
Wenchao Tong
fccef1da81 NetworkStatsService to adjust VPN stats before recording.
* Creates a new Parcelable class VpnInfo to hold required
  parameters for VPN stats adjustments.
* ConnectivityService to collect infomation and provide
  a list of VpnInfo, one for each user.
* NetworkStatsService passes the VpnInfo array to
  NetworkStatsRecorder.
* NetworkStatsRecorder calls NetworkStats.migrateTun()
  to do the math.
* Poll NetworkStats when the vpn application calls
  setUnderlyingNetworks().

Bug: 19536273
Change-Id: I7a4c7726b8243fead10416f7ec6eb5cf95f20183
2015-03-12 17:43:41 -07:00
Wenchao Tong
0fc8eeb07f Merge "NetworkStats to support VPN accounting." 2015-03-12 22:10:56 +00:00
Wenchao Tong
9ba4d7429b NetworkStats to support VPN accounting.
Create a new method to migrate underlying network traffic
from VPN app to other apps.

Bug: 19536273
Change-Id: I3434cad361592e26b01225edf8012f7b16afc98f
2015-03-09 11:38:10 -07:00
The Android Automerger
3265d9ec0e merge in master-release history after reset to master 2015-03-05 01:01:25 -08:00
John Spurlock
ad5bfa5be8 Remove unused imports in frameworks/base.
Change-Id: I031443de83f93eb57a98863001826671b18f3b17
2015-02-28 14:47:49 -05:00
Qiwen Zhao
54e0c99fe8 Initial empty repository 2014-12-10 14:10:18 -08:00
Jeff Sharkey
1201ce15e2 am 7639e76b: am 2f1e953f: am 4df65bf1: Merge "Direct notification of network interface changes." into lmp-mr1-dev
* commit '7639e76b812f8d9b57eb2680e4d9519ae36fb778':
  Direct notification of network interface changes.
2014-12-09 23:20:26 +00:00
Jeff Sharkey
382a6b06c5 am c54f4ec8: am 5b41696c: am a8fb5803: Merge "Offer to "merge" subscribers for data usage." into lmp-mr1-dev
* commit 'c54f4ec856c057039d87450dd5d3d7fe41d3f162':
  Offer to "merge" subscribers for data usage.
2014-12-09 22:23:19 +00:00
Jeff Sharkey
7639e76b81 am 2f1e953f: am 4df65bf1: Merge "Direct notification of network interface changes." into lmp-mr1-dev
* commit '2f1e953f8fd6d7ee32c00a680f887607f1005f62':
  Direct notification of network interface changes.
2014-12-09 00:18:01 +00:00
Jeff Sharkey
5fb4f650df Direct notification of network interface changes.
Connectivity broadcasts recently changed and are no longer sent for
certain types of network changes.  For example, when stacked network
interfaces change for a mobile network.  To ensure that we pick up
all these details, directly wire the two services together.

Also remove some unused code for split network types.

Bug: 18666753
Change-Id: I0467bd5b330c0e0cb51af2306d821b41ad16337a
2014-12-08 14:50:14 -08:00
Jeff Sharkey
c54f4ec856 am 5b41696c: am a8fb5803: Merge "Offer to "merge" subscribers for data usage." into lmp-mr1-dev
* commit '5b41696c56c124124d48168227a83b63bd55aea7':
  Offer to "merge" subscribers for data usage.
2014-12-08 19:44:27 +00:00
Jeff Sharkey
ae5a8a5ec8 Offer to "merge" subscribers for data usage.
There are some cases where multiple subscriber identities (IMSI)
should be treated as "merged together" from a data usage
perspective.  This is done by extending the template used for
matching purposes to support multiple subscribers.

Then, when we query historical usage or set network policies, we
normalize the matching template to merge to any other identities
that should be included.  When normalizing, the "lowest" identity
is always used for equality and storage purposes, which allows
identities to come and go over time.

This change also fixes data usage recording for multi-SIM devices
by passing along the concrete subscriber identity for each network
interface.  Also correctly create default policies for multi-SIM
devices.  This change also drops setPolicyDataEnable() until it can
be wired up to the right underlying NetworkAgent.  (This means we
still bring up the network, and then rely on iptables rules to block
traffic when over the limit, instead of proactively disabling the
connection.)

Bug: 18012787
Change-Id: If6acf32009fdfea2b836f5aff8e2f3e5e0248b4a
2014-12-08 08:42:59 -08:00
Nick Kralevich
f6e06b3226 resolved conflicts for merge of eb0754b2 to master
Change-Id: Ifcde272f882e55998b16e02cca1e827dec35ce6f
2014-12-02 16:22:57 -08:00
Paul Lawrence
eb0754b2da am 1056d5a9: am 75f304f9: Merge changes Ibfb5c6ab,I712919ae into lmp-mr1-dev
* commit '1056d5a997e3f30230e1e4316310586dd15a4600':
  Add mechanism for securely returning parameters though NativeDaemonConnector
  Revert "DO NOT MERGE: Don't log passwords returned from vdc"
2014-12-02 20:30:01 +00:00