History log of /frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
e9a988caca733d2f292991a52a0047685a69812f 28-May-2016 Dianne Hackborn <hackbod@google.com> Work on issue #28942589: Tune job scheduler

We now have a new settings key that provides all of the existing
tuning parameters, plus some newly redone ones for dealing with
different memory levels.

Changed the minimum batching for overall jobs from 2 to 1, so
we will never get in the way of immediately scheduling jobs
when the developer asks for this. We should now be able to rely
on the doze modes to do better batching of jobs for us when it
is really important.

Also work on issue #28981330: Excessive JobScheduler wakeup alarms.
Use a work source with scheduled alarms to blame them on the app
whose job they are being scheduled for, and add a check for whether
a job's timing constraint has been satisfied before considering it
a possible candidate for the next alarm. (If it is satisified,
the time is in the past, so we should not schedule an alarm for it.)

Finally clean up a bunch of the dumpsys output to make it easier
to understand.

Change-Id: I06cf2c1310448f47cf386f393e9b267335fabaeb
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
99d5d3d7759883119665d928d110edb14df44ecc 16-May-2016 Felipe Leme <felipeal@google.com> Added a onRestrictBackgroundBlacklistChanged() callback.

When an UID is added / removed to the Data Saver blacklist, it's
necessary to notify internal components such as the Settings UI (which
was erroneously listening to UID rules changes instead).

BUG: 28743623
BUG: 28791717

Change-Id: I11c85e141dfe074ad390fd324309d2412bfbbd45
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
781ba14af2a8c8e85f684208055dba0ebfd5db30 10-May-2016 Felipe Leme <felipeal@google.com> Fixed connectivity state in some power saving scenarios.

NetworkPolicyManagerService (NPMS) manages 4 type of network restriction
when apps are running on background:

- Data Saver Mode (data usage restriction on metered-networks)
- Battery Saver Mode (power restriction on all networks)
- Doze Mode (power restriction on all networks)
- App Idle (power restriction on all networks)

These restrictions affects 2 parts of the system:

- Internal framework state on NPMS which is propagated to other internal
classes.
- External firewall rules (managed by netd).

Although each of the power-related restrictions have their own external firewall
rules, internally apps are whitelisted to them through the same
whitelist, and the current code is only updating the internal state (and
notifying the internal listeners) when Battery Saver Mode is on.

As a consequence of this problem, there are scenarios where an app
correctly does not have internet access (because the firewall rules are
properly set), but the NetworkInfo state returns the wrong state (like
CONNECTED / CONNECTED).

This CL fixes this problem by splitting the power-related logic from
updateRulesForRestrictBackgroundLocked() into its own
method (updateRulesForPowerRestrictionsLocked()), and making sure such
method is called whenever the firewall rules are updated.

Externally to this change, the CTS tests were also improved to verify
the apps get the proper connection state; it can be verified by running:

cts-tradefed run commandAndExit cts -m CtsHostsideNetworkTests \
-t com.android.cts.net.HostsideRestrictBackgroundNetworkTests

BUG: 28521946
Change-Id: Id5187eb7a59c549ef30e2b17627ae2d734afa789
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
d31a97fd83468d27d0f4c6e1455c2f6f59d5a7c9 06-May-2016 Felipe Leme <felipeal@google.com> Fixed connectivity state in some restricted network scenarios.

NetworkPolicyManagerService (NMPS) keeps an internal list of uid
rules (mUidRules) for network restrictions, and when these rules
changes it needs to notify external listeners (such as
ConnectivityService / CS).

Prior to Android N, both Data Saver mode (the feature previously known
as "Restrict Baground Data") and Battery Save mode used the same set of
firewall rules to implement their restrictions: when Battery Saver mode
NPMS would mark all networks as metered and set the proper firewall
rules externally.

Recently, these 2 modes were split in 2 distinct firewall rules and
NMPS.updateRuleForRestrictBackgroundLocked() was changed to update
the mUidRules logic based on the Data Saver firewall (since the Battery
Saver firewall changes are handled externally, on
updateRuleForRestrictPowerLocked()). As such, CS was not notified when
the power-related changes were made, which would cause apps to get a
state of CONNECTED / CONNECTED when querying its active connection.

Another scenario that is not properly handled is when a UID whitelisted
for Data Saver is brought back to foreground: although the proper
firewall rules are set, CS is not notified, and the apps state would be
DISCONNECTED / BLOCKED.

This CL introduces many changes that fix this issue:

- Fixed updateRuleForRestrictBackgroundLocked() to invoke
onUidRulesChanged() when the Battery Saver status changed.
- Fixed updateRuleForRestrictBackgroundLocked() to invoke
onUidRulesChanged() when an app whitelisted for Data Saver is brought
back to the foreground.
- Added a new API (onRestrictPowerChanged() and getRestrictPower())
to notify external services about Battery Saver mode changes.
- Fixed CS logic to properly handle the Battery Saver changes.

Externally to this change, the CTS tests were also improved to verify
the apps get the proper connection state; they can be verified running:

cts-tradefed run commandAndExit cts -m CtsHostsideNetworkTests \
-t com.android.cts.net.HostsideRestrictBackgroundNetworkTests

BUG: 28521946

Change-Id: I8eaccd39968eb4b8c6b34f462fbc541e5daf55f1
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
ef3aa6ee53c5e4f1c50dd5a9b5821c54e449d4b3 30-Apr-2016 Dianne Hackborn <hackbod@google.com> Fix issue #28477006: Add small event log to job scheduler

Added. Also fixed dumpsys output when filtering, to apply the
filter to (almost) all of the output.

Change-Id: Iafb446599ad8fddbe8a766784deff618a6cfdbb7
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
1b6519bd87a59a10e9928e5772a17976692611da 28-Apr-2016 Jeff Sharkey <jsharkey@android.com> Flag to mark foreground jobs, fix data saver.

When a job will eventually run in the foreground, the internal
scheduling needs to ignore any background network restrictions when
satisfying constraints. This also means the job should ignore the
current device doze state, since the requesting app could get the
same behavior by starting their own foreground service.

Always dispatch network policy changes to ConnectivityService first
to ensure that it has up-to-date information. Fix bugs around data
saver that were causing networks to not be marked as BLOCKED for
background apps; before this fix apps would have been spinning in
internal connectivity loops, thinking that the network was actually
connected when the kernel was actually blocking their traffic.

Offer new ConnectivityService method overloads to ignore the blocked
state for a specific UID.

Print unsatisfied job constraints to aid debugging.

Bug: 26571724
Change-Id: Iaaa17933e6dc1bf6d3dff26d0bfc12222e51e241
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
f07c7b9fd0a640bff4bf7690373613da217fe69b 22-Apr-2016 Jeff Sharkey <jsharkey@android.com> API changes for DownloadManager and JobScheduler.

To support moving DownloadManager, add new JobScheduler network type
constraint that matches "any network except roaming." Also add an
API to get a specific JobInfo by ID.

Since the default network can be different on a per-app basis, and
individual apps may be blocked due to app standby, evaluate job
connectivity constraints on a per-UID basis. To implement this
cleanly, add NetworkInfo.isMetered() to match the isRoaming() API.

Add new DownloadManager APIs to support charging and device idle
constraints, which are plumbed through to JobScheduler under the
hood when scheduled.

Add filtering to JobScheduler dumpsys to omit noisy details for
packages the caller isn't interested in.

Bug: 28098882, 26571724, 19821935
Change-Id: I09ca7184ef7ce6adba399f579d415a5fb2ea6110
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
88c4135d88eb59320fe93801088bcd6c47e50efb 08-Apr-2016 Dianne Hackborn <hackbod@google.com> Fix issue #26879170: Adjust doze maintenance windows...

...based on network availability

There is a new light maintenance state "waiting for network"
that we go in to after idle if the network is not currently
available. We will stay in this state the same duration as idle,
so if we are continually without network access this effectively
doubles the light doze idle durations.

Get rid of some wrongly copy/pasted code to allow doze light
to still work even if we don't have an SMD. It doesn't need
one.

Also a bunch of improvements to the shell commands to make it
easier to test / debug.

Change-Id: Iad024840661479dbfd54b5b3db6ab96fefe59bc0
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
141f11c82a2dbf042833f75aeae6f028e8ae2084 06-Apr-2016 Dianne Hackborn <hackbod@google.com> More work on issue #26390151: Add new JobScheduler API...

...for monitoring content providers

- Improve media provider change reporting so that observers can
avoid spurious reports of the top-level content directory changing.
- Fix a bug where collected content changes while a job was running
were not being properly propagated to the next job.

Change-Id: I29e3c2960e6fec75b16ee3ee6588d47342bf8c75
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
0529dac587b1361eac359737a5f10972bce5fd0d 15-Mar-2016 Shreyas Basarge <snb@google.com> Fix for JobScheduler jobs not running

If the device is powered off when a job is
supposed to run, its delay and deadline both
are set to 0 on boot. If the deadlineExpired alarm
runs first, the job is discarded from
TimeController's tracked jobs list. The delay
constraint is never set to true and the job
would never be executed. This behavior is fixed
here.

Dump modified to print jobId and uId instead of
hash to make it more meaningful.

Bug: 27619643
Change-Id: If03e3d6f194f15fe43b697dcb4198137fa7ed646
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
b0001f6fb1383d9824c2733896b0b348e7f77240 16-Feb-2016 Dianne Hackborn <hackbod@google.com> Remove internal locking from JobStatus.

Now all state of JobStatus is implicitly protected by the lock
of whoever is using it -- in this case the global lock for the
JobSchedulerService. This allows us to remove all of the atomic
variables and just replace those with a simple bit field.

The required constraints for a job are now statically defined
once a JobStatus is created, and don't change. (They wouldn't
change before, but now this is absolutely specified to be the
case.) This required tweaking the constructors a bit so that
the earliest and latest run times are computed as part of the
core class initialization.

Also clarified methods on StateController that are called with
the lock held, and took advantage of that in the various
controllers to not now redundantly re-acquire the lock.

Change-Id: I595c5e7d1bff1bd2ff906d612581af82878a25ee
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
33d31c5b70c7d056e799e34bb6eccbe6939714ea 16-Feb-2016 Dianne Hackborn <hackbod@google.com> Simplify job scheduler service locking.

Unify all locks to just one lock protecting the entire service.
There is really no need for more complicated locking -- there is
nothing in the code that can take a long time to complete. And
having a single lock will allow various parts of the code to be
much simpler and easier to maintain.

This is just the first step of the change, switching all of the
locking to use one lock. With this done, we can now start
simplifying the code. For example, JobStatus no longer needs
to do any locking (or have atomic variables and such), it can
just rely on its callers holding the global service lock.

Change-Id: I502916ed7f2994b601750c67a59a96b1a4e95c6d
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
1a30bd9b13fd127d9bbfdc5fd4cb2f80ab7ece21 11-Jan-2016 Dianne Hackborn <hackbod@google.com> Add and implement JobScheduler content observer APIs.

Allows one to schedule jobs to run when content URIs
change, and find out what changed when the job executes.

This required adding a new API to StateController to
tell it when we are about to start executing a job, so
we can transfer the currently collected changes out of
its internal state to fill it in to the JobParameters.

Also some additional dumpsys debug output to help
understand what is going on in the job scheduler.

Change-Id: I91f51b226ff4add7a271a8333beffa5e86c7bf18
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
6078b50b017fbcf8d6cbf9f83226ed5667d5729e 12-Jun-2014 Robert Greenwalt <rgreenwalt@google.com> Apply API Council comments to ConnectivityManager

rename isNetworkActive -> isDefaultNetworkActive
rename registerNetworkActiveListener -> registerDefaultNetworkActiveListener
make listenForNetwork/requestNetwork take a NetworkRequest
rename NetworkCallbackListener -> NetworkCallback
rename listenForNetwork -> registerNetworkCallback
rename releaseNetworkRequest -> unregisterNetworkCallback
remove NetworkRequest param from NetworkCallback functions
rename onNetworkCapabilitiesChagned to onCapabilitiesChanged
remove onReleased
change time units in onLosing from Sec -> ms

bug: 15142362
Change-Id: Ibc96e3f461706efe1eafa0d85605249cfd6e9fdd
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java
7060b04f6d92351b67222e636ab378a0273bf3e7 10-Jun-2014 Christopher Tate <ctate@google.com> Out with the old; in with the new

Switch to the official "JobScheduler" etc naming.

Bug 14997851

Change-Id: I73a61aaa9af0740c114d08188bd97c52f3ac86b7
/frameworks/base/services/core/java/com/android/server/job/controllers/ConnectivityController.java