253 Commits

Author SHA1 Message Date
Paul Jensen
bb2e0e9816 Disallow requesting networks with mutable NetworkCapabilities.
It's not clear what it means to request a network with a mutable
NetworkCapability like NET_CAPABILITY_VALIDATED or
NET_CAPABILITY_CAPTIVE_PORTAL.  Presently requesting such a network
would fail in a number of different ways:
1. The NetworkFactories would fail to match the request against their
   filter which doesn't include stateful NetworkCapabilities.
2. If the NetworkFactories did match, they'd bring up networks to try
   and satisfy the requests, but the networks would not have any
   mutable NetworkCapabilities initially so they'd be reaped.
Because of these problems it's safest to simply disallow these
requests.

Bug: 21343774
Change-Id: I56303242b81d39b370b8d5d1e32059bfcfc25949
2015-06-23 14:13:10 -04:00
Paul Jensen
8e21d29f7e Merge "Don't send spurious onAvailable NetworkCallbacks when rematching" into mnc-dev 2015-06-20 01:12:20 +00:00
Paul Jensen
3d911469a1 Don't send spurious onAvailable NetworkCallbacks when rematching
Bug:21762680
Change-Id: Ia701045dffc666fe75fba0e1771872147e37179a
2015-06-19 00:06:57 +00:00
Chris Wren
3d2b621204 Merge "high-frequency notification stats." into mnc-dev 2015-06-17 15:43:41 +00:00
Chris Wren
5eab2b72af high-frequency notification stats.
Aggregate and then periodically report stats that are high-frequency
because they are driven by app behavior, not user behavior.

Reuse the NotificationUsageStats facility.
Remove redundant stats.
Lessen memory foot print.
Enable in-memeory aggregates with small, bounded memory footprint.

Bug: 20258744
Change-Id: I87e391419c53917fa13c68a56f8cdb40a7c8e548
2015-06-17 11:42:45 -04:00
dcashman
87f794f0bf Make keysetmgrservice gurantees explicit.
Add exceptions/checks for keysetmgrservice interractions which *should* never
happen, but would result in NPE or invalid metadata.  Also handle mismatches
between package and keyset metadata in packages.xml.

Bug: 20128916
Change-Id: Ia0f63f78d232d9d8d9fbe4cd8e6cc3406e5192a7
2015-06-15 17:14:54 -07:00
Paul Jensen
0a2823e539 Remove most sleep() calls from ConnectivityServiceTest
Change-Id: I90d2f6811ed1cb84614101200ac377e920bd864a
2015-06-12 10:31:09 -04:00
Robert Greenwalt
3cbad5c17f Merge "Remove network requests properly." into mnc-dev 2015-06-11 02:19:17 +00:00
Robert Greenwalt
348e98dba0 Remove network requests properly.
We used to only remove requests that we'd acted on but that's
just wrong.

Also adds test case which exposed the problem but passes with the fix.

bug:20731384
Change-Id: I581a005560cc71167b857abf2452769399a9e1b7
2015-06-10 14:44:34 -07:00
Paul Jensen
67b0b0756b Avoid overlapping NetIDs in ConnectivityServiceTest with real NetIDs
Overlapping the NetIDs can cause the ConnectivityService instance under test
to inadvertently use real networks, for example when NetworkMonitor attempts
to validate a network.  This fixes test hangs when run on devices with
active internet connections.

Change-Id: I5e1898953f0117b9f75beccac4a52ae2db173567
2015-06-10 11:30:26 -04:00
Paul Jensen
577d79b556 Merge "Revive ConnectivityServiceTest and add some tests." into mnc-dev 2015-06-04 13:11:34 +00:00
Paul Jensen
d7b6ca91e9 Revive ConnectivityServiceTest and add some tests.
Change-Id: I44740a7b21cff18ac2a67d09c4d0e597add19ee0
2015-06-04 09:09:36 -04:00
Lorenzo Colitti
f68edb1611 Actually fall back from yiaddr to ciaddr.
The initial implementation of toDhcpResults attempted to get the
leased IP address from ciaddr if yiaddr was 0.0.0.0, but it never
actually did so because a) it used == instead of equals(), and b)
the parsing code never populated mClientIp for a DhcpOfferPacket
or DhcpAckPacket.

Fix this and add a test for it.. Technically DHCP does not use
ciaddr (only bootp uses it), but in 5.0 we would use ciaddr if
yiaddr was 0.0.0.0 and a bit more compatibility shouldn't hurt.

Bug: 19704592
Change-Id: I1f58555f0c10b9c576995a6edb759a83d8938ea0
2015-06-04 14:57:11 +09:00
Lorenzo Colitti
d973537ee1 Fix DHCP lease time parsing.
Currently we treat a lease time larger than 2**31-1 as a negative
value, which causes DhcpClient to attempt to renew its IP address
constantly. Fix this by properly handling large and infinite
lifetimes, and while we're at it, impose a minimum lease time of
60 seconds.

Bug: 21352084
Change-Id: If62c9efeffad6222e2fe0c110f77d0e4c70de96d
2015-06-02 16:21:17 +09:00
dcashman
e7b021735e Fix PackageManagerSettingsTests and add KeySet info.
Add unit tests for the keyset portion of packages.xml.  Also fix previously
broken test by adding UserManagerService reference.

Bug: 19530911
Bug: 19530120
Change-Id: I251fc3e9dc983f1d63f9e84905d3ed0e64843def
2015-04-28 15:06:23 -07:00
dcashman
67633a17fa Add KeySetManagerService unit tests.
Bug: 19530120
Change-Id: Ie5601f7cafd4b853c6436941cfed48622549d928
2015-04-27 14:44:30 -07:00
Etan Cohen
644f41368f Merge commit '4cb5d80' into merge2 2015-04-24 14:03:28 -07:00
Lorenzo Colitti
6332b7e3bc Merge "Set the secs field in the BOOTP header." into m-wireless-dev 2015-04-21 07:39:02 +00:00
Lorenzo Colitti
3e979321a5 Set the secs field in the BOOTP header.
We mostly follow RFC 2131, which says that secs is the number of
seconds "since client began address acquisition or renewal
process", and thus set secs to zero on renew. This is different
from our current behaviour, which keeps on counting without
resetting secs to zero on renew.

Bug: 19704592
Change-Id: Ifbb7644094c579be626ffb698eee87047425dbf0
2015-04-21 16:21:21 +09:00
Erik Kline
082474a505 CONNECTIVITY_ACTION is the new _IMMEDIATE
Bug: 20013379
Change-Id: I3e904dc0a0ddb30c7bb8cdb24d0762052ddc59eb
2015-04-21 13:04:36 +09:00
Erik Kline
f851d6dd2a CONNECTIVITY_ACTION is the new _IMMEDIATE
Bug: 20013379
Change-Id: I3e904dc0a0ddb30c7bb8cdb24d0762052ddc59eb
2015-04-20 16:11:58 +09:00
Andres Morales
8fa5665f0e Wire up GateKeeper to LockSettingsService
Adds:
- Communication to GKService
- password upgrade flow
- enroll takes previous credential

Change-Id: I0161b64642be3d0e34ff4a9e6e3ca8569f2d7c0a
2015-04-13 18:38:45 -07:00
Fyodor Kupolov
385de624aa Use UserHandle instead of int for public APIs
Bug: 20049349
Change-Id: If5671fb47aa9a3cffebff16787daeae9ca7361e8
2015-04-13 09:31:16 -07:00
Fyodor Kupolov
2e29aa5ea7 Merge "Added getUserCreationTime to query user/profile creation time" 2015-04-10 23:33:29 +00:00
Dianne Hackborn
4870e9d5eb More work on device idle mode and other power stuff.
Add idle mode support to the alarm manager.  Introduce
a new concept of flags associated with alarms to tell
the alarm manager how to treat the alarm -- they allow
everything from the alarm that will bring us out of idle
mode, to alarms that are allowed when idle or should
also bring us out of idle.  The standalone boolean is
now also a flag.

(Note there is currently no protection from user space
setting the flags however it wants; I will be working
on that in a follow-up change.)

When in idle mode, the alarm manager pushes all alarms
that shouldn't execute during that time over to a
separate list that is not executed until out of idle.
To help with this, I reworked a bit how Alarm objects
are managed, so that when rebatching or moving between
lists we don't have to allocated new objects but can
just use the same existing instance.

Also tweaked the sync manager to deal with idle mode,
which currently just means doing the same thing as when
low on storage -- turning off sync.

Add new ACTION_CHARGING and ACTION_DISCHARGING broadcasts
that apps can listen for to know when the device is actively
charging and discharging.  These are better than the old
POWER_CONNECTED and POWER_DISCONNECTED ones because we only
report charging when we actually see that there is enough
power being provided to charge the battery (and will report
discharging if there is not enough power).

The job controller uses these new actions for scheduling
jobs that want to run while plugged in.  Removed the
"stable charging" stuff while doing so, since the new
charging state serves as an even better signal for that.

Introduced two new process states: FOREGROUND_SERVICE and
TOP_SLEEPING.  This will allow us to treat foreground services
specially (such as still allowing network access to them for
background music playback) while not mixing them together with
whatever happens to be the top activity while the device is
asleep.

Also some other small cleanup here and there.

Change-Id: I7a9808b578bad6f50deb8e1baf919298512a0d3a
2015-04-09 14:05:17 -07:00
Fyodor Kupolov
ff7233e2e3 Added getUserCreationTime to query user/profile creation time
Added public api to query creation time of the user or of a managed profile
associated with the calling user.

Bug: 20049349
Change-Id: I7f9263fe434233e6f7d4f165c974cab64ca7107c
2015-04-08 11:28:52 -07:00
Lorenzo Colitti
a12bde3567 Deal with null characters in string options.
This currently truncates all strings at the first NULL character,
except for vendorInfo, which is an opaque string.

Bug: 19985674
Change-Id: Ie53b2c55eb8a5204d7b2c7e2d8587743d923647a
2015-04-01 17:53:14 +09:00
Lorenzo Colitti
c2abb2bf5e Deal with null characters in string options.
This currently truncates all strings at the first NULL character,
except for vendorInfo, which is an opaque string.

Bug: 19985674
Change-Id: Ie53b2c55eb8a5204d7b2c7e2d8587743d923647a
2015-04-01 13:55:34 +09:00
Fyodor Kupolov
262f9952e6 Support for nested bundles in setApplicationRestrictions
Added new restriction types - bundle and bundle-array.

Modified RestrictionsManager.getManifestRestrictions to support new
hierarchical restrictions.
Added RestrictionsManager.convertRestrictionsToBundle, which enables
programmatic conversion from a list of RestrictionEntries to a Bundle.

Modified read/write methods for application restrictions in UserManagerService.
Added unit tests.

Bug: 19540606
Change-Id: I32b264e04d5d177ea5b4c39a8ace5ee0ce907970
2015-03-30 17:59:07 -07:00
Svet Ganov
fc2d615a7b Fix build
Change-Id: Ib3fc843ad02ea3a83f03cf1d6b063d4031da51b1
2015-03-28 21:08:44 -07:00
Svet Ganov
12a692a5e8 Fix runtime permissinos toggling and relax XML parsing.
1. Fixed the case where runtime permissons can be toggled by a
   developer via a system property.

2. Relaxed the runtime permission XML parsing to be more fault
   toelrant and consistent wiht the reset of the package manager
   parse code.

3. Fixed a deadlock due to calling in to the activity manager
   with the package manager lock held to kill an app.

Change-Id: I11dfb57ad4d8119baea79227dc2a3fe5e2208515
2015-03-28 20:14:58 -07:00
Svetoslav
c6d1c345f4 Runtime permissions: per user permission tracking.
Before all permissions were granted at install time at once, so the user
was persented with an all or nothing choice. In the new runtime permissions
model all dangarous permissions (nomal are always granted and signature
one are granted if signatures match) are not granted at install time and
the app can request them as necessary at runtime.

Before, all granted permission to an app were identical for all users as
granting is performed at install time. However, the new runtime model
allows the same app running under two different users to have different
runtime permission grants. This change refactors the permissions book
keeping in the package manager to enable per user permission tracking.

The change also adds the app facing APIs for requesting runtime permissions.

Change-Id: Icbf2fc2ced15c42ca206c335996206bd1a4a4be5
2015-03-23 18:50:35 -07:00
Paul Jensen
43564472ee Remove dead code, mostly DataStateTracker.
(cherry picked from AOSP commit 7fad4eb4b52bc6c7ddad47f70e0c310093fbde3b)

Change-Id: I18c44cd08dfb51e02a96d0b726e9af1db21e3058
2015-03-18 12:29:13 -04:00
Andreas Gampe
db64454b33 resolved conflicts for merge of b6b9fe21 to master
Change-Id: If4f62aa1fd8bb774288a677e7008e86a7e3ea6d9
2015-03-13 00:04:10 -07:00
Paul Jensen
7fad4eb4b5 Remove dead code, mostly DataStateTracker.
Change-Id: I1433937bffdb29bd42fb1adbfcf0a50ceffac7dd
2015-03-11 10:03:58 -04:00
Esteban Talavera
8add57224f Remove deprecated version of setProfileOwner that takes packageName
The ComponentName equivalent should be used instead.

Bug: 17654371
Change-Id: I7001e86ab1709b824944148a3c44af5243dacb83
2014-12-24 09:38:13 +00:00
Jeff Sharkey
3256601f5e 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
Sreeram Ramachandran
21b5ee3f0e Eliminate race conditions in UID-based network filtering.
The previous code retrieved information from the legacy tracker multiple
times for each user query, leading to race conditions where the info
could've changed between the calls.

Refactors the handling of legacy data types in ConnectivityService and
unifies call paths so that APIs that deal with legacy data types
(NetworkInfo and int/networkType) and newer types (such as Network) go
through common code paths, using NetworkState to hold all the necessary
data pieces. This enables follow-on bug fixes to getActiveNetworkInfo().

The changes are limited to public "query" APIs (those that retrieve some
network information or the other). More details about the specific
changes and their rationale can be found in the code review thread.

Bug: 17460017
Change-Id: I656ee7eddf2b8cace5627036452bb5748043406c
2014-11-21 08:07:13 -08:00
Adrian Roos
e542499a30 Add LockSettingsStorage tests
Bug: 18163444
Change-Id: I563276e6d445d43d05bf0d3c633440a8e0109b69
2014-11-10 21:03:12 +00:00
Jeff Sharkey
d634d39c60 Merge "Follow API removal." into lmp-mr1-dev 2014-10-27 22:01:58 +00:00
Jeff Sharkey
cff1d67339 Follow API removal.
Bug: 18118003
Change-Id: Iad73ce748e05ba0660246e8dbb041415c187f792
2014-10-27 14:53:40 -07:00
Jeff Sharkey
036ebd782c Follow ArraySet refactoring.
Bug: 18115729
Change-Id: I2c32965b621b5bb57ff3bde02b00b31b59a5cd6d
2014-10-27 13:51:23 -07:00
Matthew Williams
48a30db75d Fix lock ordering in JobScheduler
BUG: 17625667
Two part clean-up.
1) Don't try to lock in onControllerStateChanged. Do it in the handleMessage
instead where the rest of the locking is. This is sufficient to fix this bug.
2) The other side of the deadlock came b/c we lock when cancelling and calling
stopTrackingJob. Controllers handle their own locking so this isn't
necessary. B/c of a potential race from the controller side, added an explicit
check for the JSS to only run an expired job if it still exists.

Change-Id: Iaeebbc19437eb5b73e3ced3168f1fc13e564a4be
2014-09-23 17:34:46 -07:00
Amith Yamasani
0e8d7d63ba Add some @SystemApi tags for internal user-related APIs
Also added an internal isManagedProfile()

Bug: 17371392
Change-Id: Ibcc26771d954505cbd530192bf4a8a25a8d4cae0
2014-09-03 13:17:28 -07:00
Matthew Williams
d1c06753d0 Implement API review feedback for JobScheduler
BUG: 17005336

Took the opportunity to clean up some back-off logic

Change-Id: Ibc8ae34d1d44dd064ba071e4cbad17872f7e38cf
2014-08-22 16:08:45 -07:00
Narayan Kamath
31fe102d57 Remove a line that was accidentally committed.
Prevents the APK from being installed.

bug: 17153971

Change-Id: Ic53c94dc6f0583371965d5edb0b12248c915214e
2014-08-22 11:37:20 +00:00
Narayan Kamath
d8b54e831d Fix service tests.
Depending on a LOCAL_JAVA_LIBRARY doesn't do anything at runtime
unless the library is manually added to the class path. Since
system server classes (and the system server) can't be instrumented
like a normal app can, we can't really write "real" Instrumentation
Tests for its classes.

Given that, we can just compile the classes under test into the same
jar file as the testcases.

Change-Id: Ie4377bf81b9542ceca938e26ac78e30835fc40bc
2014-08-21 12:31:39 +01:00
Jose Lima
235510e672 Made AlarmClockInfo a nested class in AlarmManager
Bug: 16959028
Change-Id: I150eaaff765d1e214c3621c1bf50162ec0dac8ec
2014-08-14 02:10:41 +00:00
Amith Yamasani
95ab784944 Decouple user limit from guest creation
Allow Guest to be created even if there are N users.
Allow N users to be created even if there are N-1 users
   and a Guest.
Limit number of guests and managed profiles that can
be added.

Added unit tests.

Bug: 15934700
Change-Id: I1a8f0fa38a91d71ef7b2980e05c974244dfc337a
2014-08-13 20:09:20 +00:00
Robert Greenwalt
6831f1d80f Remove dead code 2.
Removing ConnectivityService.NetworkFactory.  This requires disabling
the ConnectivityServiceTest, but that's been broken since we stopped
using NetworkStateTrackers anyway.

Change-Id: I9b86bd37eb9d018c40f60dca5b00d62c36d4e3ad
2014-07-28 14:48:52 -07:00