-
Notifications
You must be signed in to change notification settings - Fork 319
do-not-review-wip-kumann-pblsamples #764
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @kumann-dev, 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 new Android application module, Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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 new playbilling module, which serves as a sample for integrating the Google Play Billing Library. The changes include adding necessary dependencies, setting up the module's Gradle build file, and providing a BillingClientWrapper class to encapsulate billing logic.
My review focuses on several key areas:
- Application Configuration: The new module is set up as an application but lacks a launchable activity in its manifest, which is a critical issue. The application ID also uses the
com.examplenamespace, which should be avoided. - Code Quality and Best Practices: I've pointed out a potential memory leak related to context handling in
BillingClientWrapper, a redundant cast, and several files missing a final newline character. - Security: There are hardcoded placeholder tokens in the billing wrapper, which represents a critical security vulnerability if translated to production code.
Overall, the PR provides a good starting point for a billing sample, but the identified issues, especially the critical ones, should be addressed to ensure the application is correctly configured, robust, and secure.
| <application | ||
| android:allowBackup="true" | ||
| android:icon="@mipmap/ic_launcher" | ||
| android:label="@string/app_name" | ||
| android:roundIcon="@mipmap/ic_launcher_round" | ||
| android:supportsRtl="true" | ||
| android:theme="@style/Theme.Snippets" /> |
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.
This module is configured as an application via plugins { alias(libs.plugins.android.application) } in build.gradle, but there's no launchable Activity declared in the AndroidManifest.xml. An application module requires at least one Activity with an intent filter for android.intent.action.MAIN and android.intent.category.LAUNCHER to be installed and launched on a device.
For example:
<application ...>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>| .setSubscriptionUpdateParams( | ||
| SubscriptionUpdateParams.newBuilder() | ||
| // purchaseToken can be found in Purchase#getPurchaseToken | ||
| .setOldPurchaseToken("old_purchase_token") |
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.
| // You could initiate a query here or show an error message. | ||
| return; | ||
| } | ||
| String purchaseTokenOfExistingSubscription = "purchase_token"; |
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.
| }; | ||
|
|
||
| this.billingClient = | ||
| BillingClient.newBuilder(context) |
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.
To prevent potential memory leaks, the BillingClient should be initialized with the application context, not an activity context. The documentation for BillingClient.newBuilder() specifies that the application context should be used.
| BillingClient.newBuilder(context) | |
| BillingClient.newBuilder(context.getApplicationContext()) |
| public BillingClientWrapper(Context context, Activity activity) { | ||
| this.context = context; | ||
| this.activity = activity; |
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.
| androidxHiltNavigationCompose = "1.3.0" | ||
| appcompat = "1.7.1" | ||
| arcorePlayServices = "1.0.0-alpha09" | ||
| playbilling = "8.3.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.
| .setProductList( | ||
| ImmutableList.of( | ||
| QueryProductDetailsParams.Product.newBuilder() | ||
| .setProductId("product_id_example") |
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.
Hardcoding product IDs like "product_id_example" makes the code less flexible and harder to maintain, especially if you have multiple products or different product IDs for different build variants (e.g., debug vs. release). It's better to pass these values as parameters or retrieve them from a configuration.
| } | ||
|
|
||
| defaultConfig { | ||
| applicationId "com.example.pbl" |
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.
| @@ -0,0 +1 @@ | |||
| /build No newline at end of file | |||
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.
| public void addition_isCorrect() { | ||
| assertEquals(4, 2 + 2); | ||
| } | ||
| } No newline at end of file |
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.
No description provided.