New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idle mode awareness #47
Conversation
task wrapper(type: Wrapper) { | ||
gradleVersion = '2.2.1' | ||
gradleVersion = '2.8.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.8.0 does not work, I'll have to fix this to 2.8.
Sorry i missed this over the weekend, i'll check tonight or tomorrow. Thanks. |
@@ -19,7 +20,7 @@ buildscript { | |||
} | |||
|
|||
dependencies { | |||
classpath 'com.android.tools.build:gradle:1.1.3' | |||
classpath 'com.android.tools.build:gradle:1.3.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I shouldn't go around trying to upgrade everything. This for some reason breaks jacoco. ./gradlew tasks --stacktrace
produces:
Could not determine the dependencies of task ':jacocoTestReport'.
...
Task with path 'testDebug' not found in root project 'jobqueue'.
Since this build tool bump is not really necessary I'm going to discard it.
Also removes gradle version bump since it breaks jacoco.
I'm not sure if you can add it to the constructor (you should) but just adding TargetAPI can fix it. A better/nicer way to do it would be moving it to another method which has the TargetAPI check. |
overall looks good to me except the gradle 2.8 update. |
Lint errors are all fixed, let me know if you're fine with how I pulled out the code into separate methods. Running tests
|
hmm i did just run
|
If I change the dependency to "testDebugUnitTest" I get
The stack trace shows that it can't find Did you have any luck running it? Could be that my setup is foobar in some way. |
I'll just merge it and fix whatever is wrong in tests. |
i rebased my delay group branch with this and running tests works fine. So everything should be OK. Thanks again! |
Awesome, thanks a lot! Cheers :) |
private static IntentFilter getNetworkIntentFilter() { | ||
IntentFilter networkIntentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); | ||
if (VERSION.SDK_INT >= 23) { | ||
networkIntentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. (y)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
@mseshachalam +1. I don't have time to work on this for a few days, but if you make a pull request with your fix maybe @yigit can take a look before I can. |
@TargetApi(23) | ||
private static IntentFilter getNetworkIntentFilter() { | ||
IntentFilter networkIntentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); | ||
if (VERSION.SDK_INT >= 23) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Build.VERSION_CODES.M
instead of a magic number? It would be easier to read in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this.
I believe I had Lint issues or Android Studio yelling at me about VERSION_CODES.M because of the compileSdkVersion or targetSdkVersion being lower than 23; could be making that up haha.
Android M adds Doze mode and App Standby. This change aims to make the Job Manager work with Doze mode.
Doze mode disables access to network while active, but isConnectedOrConnecting() says there is network. This results in the Job Manager thinking there is network, scheduling jobs to run that require the network, those jobs failing and then being rescheduled (just to fail again).
Additionally when Doze exits a network broadcast (CONNECTIVITY_ACTION) is NOT sent. So until another job is entered into the queue or the device loses internet and gains it back, networking jobs will be idle even after Doze is finished. By listening to ACTION_DEVICE_IDLE_MODE_CHANGED the Job Manager can update the network queue accordingly.
This is important especially for IDLE_MAINTENANCE which is entered periodically during doze (granting network access if available). If we don't listen to this broadcast it's unlikely we'll wake up to do work during this maintenance window.