Skip to content

Use JobScheduler for push #735

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

Merged
merged 3 commits into from
Sep 16, 2017
Merged

Conversation

natario1
Copy link
Contributor

@natario1 natario1 commented Sep 10, 2017

Wraps PushService initialization in the PushServiceUtils class. On Android Oreo, it uses the Job scheduler APIs to launch PushService26. This is already declared in our manifest so no changes for developers.

FIxes #729

  • As far as I know PushService26 being a declared service must be public. Correct me if I am wrong
  • Can rename to PushServiceOreo if you think it's better
  • As far as I know JobScheduler APIs are not testable with Robolectric (it won't schedule), we would need androidTests
  • Unit tests aside, if someone could test on real setup that would be great

@codecov
Copy link

codecov bot commented Sep 10, 2017

Codecov Report

Merging #735 into master will decrease coverage by 0.19%.
The diff coverage is 14.45%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #735     +/-   ##
===========================================
- Coverage     53.58%   53.39%   -0.2%     
+ Complexity     1747     1746      -1     
===========================================
  Files           131      132      +1     
  Lines         10258    10284     +26     
  Branches       1435     1426      -9     
===========================================
- Hits           5497     5491      -6     
- Misses         4304     4338     +34     
+ Partials        457      455      -2
Impacted Files Coverage Δ Complexity Δ
.../src/main/java/com/parse/GcmBroadcastReceiver.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...arse/src/main/java/com/parse/PushServiceApi26.java 0% <0%> (ø) 0 <0> (?)
Parse/src/main/java/com/parse/Parse.java 50.23% <100%> (ø) 22 <0> (ø) ⬇️
...arse/src/main/java/com/parse/PushServiceUtils.java 20% <20%> (ø) 3 <3> (?)
Parse/src/main/java/com/parse/PushService.java 64.1% <26.47%> (-21.84%) 16 <6> (-2)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dfc41e8...4e4ed12. Read the comment docs.

@flovilmart flovilmart requested review from mmimeault and a team and removed request for a team and mmimeault September 10, 2017 17:05
<application />
<application>
<service
android:name=".PushService26"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PushServiceApi26?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah better.

synchronized (PushService.class) {
serviceLifecycleCallbacks.remove(callbacks);
if (serviceLifecycleCallbacks.size() <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for getting rid of this block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I just think it made no sense to null this. These ServiceLifecycleCallbacks are made just for internal use in tests (PushServiceTest) so we can design them as we wish, I think the old logic was way too verbose


// Our manifest file is OK.
static boolean isSupported() {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should you check whether the job service is declared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original PushService has a check here because it must be declared by the developer in each app. With PushServiceApi26 I have declared it in our own manifest, which should be merged with the application manifest when building the app. So I guess that's a true.

@rogerhu rogerhu merged commit aab7ae5 into parse-community:master Sep 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants