Skip to content

Conversation

@M1n9yu23
Copy link

@M1n9yu23 M1n9yu23 commented Jan 2, 2026

Summary

This PR updates the permission handling logic to support API 36+ granular permissions and fixes code formatting issues (indentation and unused imports).

The Problem

During debugging on the API 36 emulator, I observed an inconsistency in permission states. Even after granting "All" permissions in the dialog, the system still flags some permissions as "denied".

I verified this using the following debug code in MainActivity.kt:

private val requestPermissions = registerForActivityResult(
    ActivityResultContracts.RequestMultiplePermissions()
) { permissions ->
    val allGranted = permissions.values.all { it }
    if (allGranted) {
        Log.d("MainActivity", "All permissions granted")
    } else {
        // On API 36, this block executes even if the user taps "Allow All"
        Log.d("MainActivity", "Not all permissions granted")
    }
}

The Fix

To ensure robust behavior and prevent potential issues:

  1. Conditional Logic: Updated PreparingViewModel to request READ_HEART_RATE on API 36+ and fallback to BODY_SENSORS for older versions.
  2. Code Style: Corrected indentation and removed unused imports to align with the project's coding standards.

The `BODY_SENSORS` permission is no longer sufficient for heart rate monitoring on Android 16 (API 36+) due to the introduction of granular permissions.

Changes included in this commit:
- Conditionally request `READ_HEART_RATE` on Baklava (API 36) and above.
- Fallback to `BODY_SENSORS` for Android 15 (Vanilla Ice Cream) and below.
- Apply spotless formatting to comply with the project style guide.
@gemini-code-assist
Copy link

Summary of Changes

Hello @M1n9yu23, 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 primarily focuses on enhancing the application's robustness and code quality. It introduces a critical fix for permission handling on Android API 36+, ensuring that health-related permissions are requested correctly and consistently across different Android versions. Additionally, it includes a series of code style improvements, such as correcting indentation and removing unnecessary imports, to align the codebase with established coding standards.

Highlights

  • API 36+ Permission Update: The permission handling logic has been updated to correctly request "READ_HEART_RATE" for Android API 36 (Baklava) and newer, while falling back to "BODY_SENSORS" for older API levels. This addresses an observed inconsistency where permissions were flagged as denied even after being granted on API 36 emulators.
  • Code Style Refinements: Various code style issues, including inconsistent indentation and unused import statements, have been resolved across several files to improve code readability and maintainability.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 effectively addresses the permission handling for Android API 35+ by correctly using the granular READ_HEART_RATE permission while maintaining backward compatibility with BODY_SENSORS. The changes in PreparingViewModel.kt are well-implemented and follow best practices for handling version-specific permissions. Additionally, the pull request includes several valuable code style improvements across multiple files, such as removing unused imports, fixing indentation, and adding braces to control flow statements, which all contribute to better code readability and maintainability. Overall, this is a solid contribution that improves both the functionality and quality of the codebase.

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.

1 participant