-
Notifications
You must be signed in to change notification settings - Fork 204
Adds default watch face updater mechanism #154
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
Conversation
Summary of ChangesHello @garanj, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial feature for Wear OS applications that provide a default watch face: the ability to automatically update that watch face when the main application itself is updated. By leveraging a Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a mechanism to automatically update the default watch face when the main application is updated. The implementation uses a BroadcastReceiver
for MY_PACKAGE_REPLACED
which triggers a WorkManager
job. The overall approach is sound, but I have a few suggestions to improve code quality, correctness, and resource management.
My main points are:
- In
UpdateReceiver
, theonReceive
parameters can be non-nullable, simplifying the code. - In
UpdateWorker
, there's a potential resource leak withParcelFileDescriptor
that should be fixed using ause
block. - The worker should return
Result.failure()
when an error occurs to correctly signal the job status. - I've also pointed out some opportunities for code simplification and improving maintainability, such as removing a redundant
appContext
property and extracting a magic number from the Gradle scripts into a version catalog constant.
Watch Face Push allows the developer to supply a default watch face. However, this watch face will not be updated when the containing app is updated.
To enable this behavior, this PR adds a receiver for the
MY_PACKAGE_REPLACED
action.When triggered, this creates a WorkManager job which checks to see whether the newly-supplied package contains an update for the default watch face. This requires checking to see if the default watch face is already installed, and whether the latest version is greater than the existing installed version.
This PR also modifies the build process to keep the default watch face and Wear OS app version code aligned at all times, so if a change is made to the default watch face, it is not necessary to manually change the watch face version code - it is enough to increment the overall app version code.