Skip to content

[Dependency Updates] Update androidxWorkManagerVersion to 2.7.1#17892

Merged
ParaskP7 merged 3 commits intotrunkfrom
deps/update-androidx-work-manager-to-2.7.1
Feb 9, 2023
Merged

[Dependency Updates] Update androidxWorkManagerVersion to 2.7.1#17892
ParaskP7 merged 3 commits intotrunkfrom
deps/update-androidx-work-manager-to-2.7.1

Conversation

@ParaskP7
Copy link
Copy Markdown
Contributor

@ParaskP7 ParaskP7 commented Feb 6, 2023

Parent #17564

This PR update androidxWorkManagerVersion to 2.7.1.

Also, this PR removes the extra androidx.work:work-gcm dependency which adds supported the use of GCMNetworkManager as a scheduler when Google Play Services is available for API levels <= 22 (ea2c854).


PS: @ravishanker I added you as the main reviewer, that is, in addition to the @wordpress-mobile/apps-infrastructure team itself, but not entirely randomly as I am seeing you having some experience on working with these workers/schedulers, and want someone from the WordPress team to be aware of and sign-off on that change for WPAndroid.


To test:

  1. See the dependency tree diff result and verify correctness.
  2. Thoroughly smoke test any work manager related functionality on both, the WordPress and Jetpack apps, and see if they both work as expected.
  3. In addition to the above smoke test, you can expand the below and follow the inner and more explicit test steps within (although verifying on UploadWorker.kt should be enough):
1. UploadWorker.kt
  • Go to Post screen.
  • Create a new post and publish it.
  • Turn device offline.
  • Go to this post and update it.
  • Notice the warning message: We'll publish the post when your device is back online.
  • Turn device online.
  • Notice this post being automatically uploaded.
  • Open this post on a web browser and verify the post is indeed updated.
2. ReminderWorker.kt
  • Go to Site Settings screen.
  • Find the Blogging section, click on Reminders, toggle-on every day and click on Update.
  • Notice the All set! bottom sheet appearing, click Done.
  • Close the app, preferably swipe the app off.
  • Go to the device's Settings app, find the Date & Time section, turn Automatic date & time off.
  • Set the device's date to a day after today.
  • Open the app.
  • Verify the Blogging Reminders notification appearing. For example, the notification title could be Daily Prompt, while the notification description something like Is there anything you feel too old to do anymore?.
3. LocalNotificationWorker.kt
  • (❓) I am not sure how to test this functionality as I can't easily find the entry point to it.
  • (❗️) All I could do to test this was to manually comment out the if check within the CreateSiteNotificationScheduler.scheduleCreateSiteNotificationIfNeeded() function and verified that the LocalNotificationWorker.doWork() function was called after setting the device's date to day/week after today.
4. WeeklyRoundupWorker.kt
  • (❓) I am not sure how to test this functionality as I can't easily find the entry point to it.
  • (❗️) All I could do to test this was to manually comment out the if check within the CreateSiteNotificationScheduler.scheduleCreateSiteNotificationIfNeeded() function and verified that the LocalNotificationWorker.doWork() function was called after setting the device's date to day/week after today.

Regression Notes

  1. Potential unintended areas of impact

    • Potential breakage or misbehaviour on any or all scheduling related app functionalities, like post/page offline-to-online upload, blogging reminders, weekly roundup and local notifications.
    • The androidx.work:work-gcm that got removed might be causing some kind of misbehaviour (see ea2c854). Cc @malinajirka as an extra pair of eyes on that. 🙏
  2. What I did to test those areas of impact (or what existing automated tests I relied on)

    • See To test section above.
  3. What automated tests I added (or what prevented me from doing so)

    • N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

This dependency was added as part of this
82b0c50 commit (see PR below), which
supported the use of GCMNetworkManager as a scheduler when Google Play
Services is available for API levels <= 22. This was an optional
dependency that helped with more reliable and performant background
processing on older API versions as GCMNetworkManager on api <= 22 (see
2.2.0 release notes below). However, since this project is now on
api >= 24 (see 'minSdkVersion'), this dependency is no longer
necessary and thus can be removed.

- PR: Issue/10572 update work manager #13542
#13542
- Work Manager 2.2.0: https://developer.android.com/jetpack/androidx/
releases/work#2.2.0

------------------------------------------------------------------------

Also, the 'Dependency Analysis' plugin advised in favor of that removal,
thus, it is most probably safe to do this removal at this point:

Dependencies which should be removed or changed to runtime-only:
  runtimeOnly 'androidx.work:work-gcm:2.7.1' (was implementation)
@ParaskP7 ParaskP7 added this to the Future milestone Feb 6, 2023
@ParaskP7 ParaskP7 self-assigned this Feb 6, 2023
@wpmobilebot
Copy link
Copy Markdown
Contributor

Found 1 violations:

The PR caused the following dependency changes:

-+--- androidx.work:work-runtime:2.7.0
++--- androidx.work:work-runtime:2.7.1
-+--- androidx.work:work-runtime-ktx:2.7.0
-|    +--- androidx.work:work-runtime:2.7.0 (*)
-|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> 1.6.21 (*)
-|    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0 -> 1.6.4 (*)
++--- androidx.work:work-runtime-ktx:2.7.1
+|    +--- androidx.work:work-runtime:2.7.1 (*)
+|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> 1.6.21 (*)
+|    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0 -> 1.6.4 (*)
-+--- androidx.work:work-gcm:2.7.0
-|    +--- androidx.work:work-runtime:2.7.0 (*)
-|    +--- com.google.android.gms:play-services-gcm:17.0.0
-|    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
-|    |    +--- androidx.core:core:1.0.0 -> 1.8.0 (*)
-|    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
-|    |    +--- com.google.android.gms:play-services-base:17.0.0 -> 18.0.1 (*)
-|    |    +--- com.google.android.gms:play-services-basement:17.0.0 -> 18.1.0 (*)
-|    |    +--- com.google.android.gms:play-services-iid:17.0.0
-|    |    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
-|    |    |    +--- androidx.core:core:1.0.0 -> 1.8.0 (*)
-|    |    |    +--- com.google.android.gms:play-services-base:17.0.0 -> 18.0.1 (*)
-|    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 -> 18.1.0 (*)
-|    |    |    +--- com.google.android.gms:play-services-stats:17.0.0
-|    |    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
-|    |    |    |    \--- com.google.android.gms:play-services-basement:17.0.0 -> 18.1.0 (*)
-|    |    |    \--- com.google.android.gms:play-services-tasks:17.0.0 -> 18.0.1 (*)
-|    |    \--- com.google.android.gms:play-services-stats:17.0.0 (*)
-|    \--- androidx.room:room-runtime:2.2.5 -> 2.4.2 (*)
 +--- com.google.firebase:firebase-messaging:21.1.0
-|    \--- com.google.android.gms:play-services-stats:17.0.0 (*)
+|    \--- com.google.android.gms:play-services-stats:17.0.0
+|         +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
+|         \--- com.google.android.gms:play-services-basement:17.0.0 -> 18.1.0 (*)

Please review and act accordingly

@wpmobilebot
Copy link
Copy Markdown
Contributor

WordPress📲 You can test these changes on WordPress by downloading wordpress-installable-build-pr17892-ea2c854.apk
💡 Scan this QR code with your Android phone to download and install the APK directly on it.
AppWordPress
Build FlavorJalapeno
Build TypeDebug
Commitea2c854
Note: This installable build uses the JalapenoDebug build flavor, and does not support Google Login.

@wpmobilebot
Copy link
Copy Markdown
Contributor

Jetpack📲 You can test these changes on Jetpack by downloading jetpack-installable-build-pr17892-ea2c854.apk
💡 Scan this QR code with your Android phone to download and install the APK directly on it.
AppJetpack
Build FlavorJalapeno
Build TypeDebug
Commitea2c854
Note: This installable build uses the JalapenoDebug build flavor, and does not support Google Login.

@ParaskP7 ParaskP7 requested review from a team and ravishanker February 6, 2023 15:32
@ParaskP7 ParaskP7 marked this pull request as ready for review February 6, 2023 15:32
@ravishanker
Copy link
Copy Markdown
Contributor

LocalNotificationWorker and WeeklyRoundupWorker can be tested through App Settings > Debug settings > Force show Weekly Roundup notification (scroll to the bottom to find it)

@ParaskP7
Copy link
Copy Markdown
Contributor Author

ParaskP7 commented Feb 7, 2023

👋 @ravishanker !

LocalNotificationWorker and WeeklyRoundupWorker can be tested through App Settings > Debug settings > Force show Weekly Roundup notification (scroll to the bottom to find it)

Oh, I didn't know about this debug setting, this is interesting indeed, thanks for sharing! 💯

But, and please correct me if I am wrong, to my understanding from checking the DebugSettingsViewModel.onForceShowWeeklyRoundupClick() function (and then testing it just to be sure) is that showing weekly roundup notifications like that does flow through the WeeklyRoundupWorker.doWork() function that I am targeting in the tests above, all this debug setting is doing is to show these notifications, right? 🤔

@ravishanker
Copy link
Copy Markdown
Contributor

all this debug setting is doing is to show these notifications, right? 🤔

Correct, it is just showing a local notification

To test if the notification is shown through worker, change the delay here to something like 1 minute:

Also, verify in logcat, notifications are scheduled like:

WM-SystemJobScheduler: Scheduling work ID 1182934f-f3fc-41f1-954a-43cd9eb3f626 Job ID 1

@ParaskP7
Copy link
Copy Markdown
Contributor Author

ParaskP7 commented Feb 8, 2023

👋 @ravishanker !

To test if the notification is shown through worker, change the delay here to something like 1 minute:
...
Also, verify in logcat, notifications are scheduled like:

WM-SystemJobScheduler: Scheduling work ID 1182934f-f3fc-41f1-954a-43cd9eb3f626 Job ID 1

Great, thanks again for guiding me into that so we can test this feature effectively! 💯

FYI: For completeness purposes, in addition to the above, in order to get that working with something like 1 minute, one would need to also switch off and then back on the Notification Settings, which is found by clicking the ⚙️ while in the main Notifications tab. Otherwise, even if the InitialDelay value is changed, the weekly roundup notification isn't triggered/shown.

As such, with the above addition step, I managed to understand how to test this feature effectively (ish). 🎉

PS: Not that it matters to testing this feature, but for completeness purposes, I was trying to figure out how this one time work manager request makes this weekly roundup notification shown every week. I was trying to find that so as to make this weekly roundup notification show every 1 minute, timeboxed my investigation to 5' mins, but couldn't, I give-up for now... 😅

Copy link
Copy Markdown
Contributor

@ravishanker ravishanker left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ParaskP7 ParaskP7 merged commit 811f400 into trunk Feb 9, 2023
@ParaskP7 ParaskP7 deleted the deps/update-androidx-work-manager-to-2.7.1 branch February 9, 2023 09:04
@malinajirka
Copy link
Copy Markdown
Contributor

Little late to the party, I was at a meetup and I noticed this ping today - I don’t foresee any issue with removing the legacy WM dependency, but take it with a grain of salt as I don't remember much from this part of the codebase :).

@ParaskP7
Copy link
Copy Markdown
Contributor Author

Better late than never @malinajirka , much appreciated your input here! 🙇

I don’t foresee any issue with removing the legacy WM dependency...

Same, I am glad we align on that! 🥇

...but take it with a grain of salt as I don't remember much from this part of the codebase :).

True, will keep an eye on that! 😄 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants