Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Snippets Groups Projects

feat:2376: Check compatibility with sdk34, allows use on android above sdk33.

Merged Guillaume Jacquart requested to merge 2376-Android_14_compatibility into main

Description

This MR prepare AdvancedPrivacy for Android 14 (codename 'u' ; sdk 34)

AdvancedPrivacy use private API from android framework. It implies taht we can't rely on compilator or warning for correct use of this API, specificaly in the case of new Android version, with API upgrade. To mitigate this risk, we explicitely redeclare the private API we use in the module :permissionseos:libs:hidden-apis-stub' . It allows us to avoid reflection, and to document (with a simple check in the corresponding source code in android_framework_base project) availability of hidden APIs, depending on sdk version.

Screenshots

No changes.

Technical details

There wasn't any visible change in the hidden API we use ; but we was explicitely failing early on android sdk > 33 . This rule is removed here.

Tests

No regressions on Android 12 ;

Tested on a FP3 with in progress /e/ V1-u .

Issues

https://gitlab.e.foundation/e/os/backlog/-/issues/2376

10 commandments of code reviews

:family: :heart: https://gitlab.e.foundation/internal/wiki/-/wikis/mobile-team/guidelines/Code-review

Summary by CodeRabbit

  • New Features

    • Updated target SDK to 34, enabling access to the latest Android features.
    • Enhanced dependency versions for improved performance and bug fixes, including androidx_core and orbotservice.
  • Documentation

    • Updated deprecation messages and guidelines in various classes to reflect new API standards, improving clarity for developers.
  • Refactor

    • Simplified conditional logic in the permissions module for better code efficiency.
Edited by CodeRabbitAI

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Guillaume Jacquart changed the description

    changed the description

  • Draft: wait for merge of orbotservice update to update submodule and orbotservice to version orbot-17.2.1-2

  • added 1 commit

    • 3d950a9b - feat:2376: Update orbotservice to 17.2.1-2

    Compare with previous version

  • Guillaume Jacquart marked this merge request as ready

    marked this merge request as ready

  • Walkthrough

    Walkthrough

    The changes primarily involve upgrading the target SDK to 34 and updating various library dependencies to their latest versions, enhancing compatibility and performance. Additionally, several methods in the hidden APIs have had their deprecation notices adjusted to reflect new API levels, improving clarity regarding future SDK compatibility and guiding developers on usage. Overall, these modifications streamline the codebase and ensure adherence to the latest Android standards.

    Changes

    Files Change Summary
    build.gradle Updated targetSdk from 33 to 34.
    gradle/libs.versions.toml Incremented orbotservice version from orbot-17.2.1-1 to orbot-17.2.1-2.
    ipscrambling/dependencies.gradle Updated androidx_core from 1.6.0 to 1.13.1, androidx_localbroadcast from 1.0.0 to 1.1.0, and orbot_service from orbot-17.2.1-1 to orbot-17.2.1-2.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/app/AppOpsManager.java Updated copyright notice, added @RequiresPermission annotation to setMode, and updated deprecation annotations for methods.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/app/NotificationChannel.java Updated copyright notice and added sourcing comments.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/PackageManager.java Updated deprecation annotations for multiple methods to reflect changes from API 34 to API 35.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/UserInfo.java Updated getUserHandle method to reflect deprecation from API 34 to API 35.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/net/VpnManager.java Updated deprecation annotations for prepareVpn, setVpnPackageAuthorization, and getAlwaysOnVpnPackageForUser from API 34 to API 35.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/os/ServiceManager.java Updated copyright, added annotations for getService, marking it deprecated since API 35.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserHandle.java Updated copyright and added deprecation annotations for myUserId() method from API 34 to API 35.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserManager.java Updated deprecation annotations for getProfiles and isManagedProfile methods from API 34 to API 35.
    permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt Simplified conditional logic for SDK version checks, consolidating multiple cases into a single logic branch.

    Sequence Diagram(s)

    sequenceDiagram
        participant Developer
        participant SDK
        participant App
    
        Developer->>SDK: Check SDK version
        SDK-->>Developer: Return SDK 34
        Developer->>App: Update targetSdk to 34
        Developer->>SDK: Check dependencies
        SDK-->>Developer: Return updated library versions
        Developer->>App: Update dependencies
        Developer->>App: Simplify permission checks

    Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

    Share
    Tips

    Chat

    There are 3 ways to chat with CodeRabbit:

    • Review comments: Directly reply to a review comment made by CodeRabbit. Example:

      • I pushed a fix in commit <commit_id>.
      • Generate unit testing code for this file.
    • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:

      • @coderabbitai generate unit testing code for this file.
      • @coderabbitai modularize this function.
    • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:

      • @coderabbitai generate interesting stats about this repository and render them as a table.
      • @coderabbitai show all the console.log statements in this repository.
      • @coderabbitai read src/utils.ts and generate unit testing code.
      • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
      • @coderabbitai help me debug CodeRabbit configuration file.

    Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

    CodeRabbit Commands (invoked as PR comments)

    • @coderabbitai pause to pause the reviews on a PR.
    • @coderabbitai resume to resume the paused reviews.
    • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
    • @coderabbitai full review to do a full review from scratch and review all the files again.
    • @coderabbitai summary to regenerate the summary of the PR.
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
    • @coderabbitai help to get help.

    Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

    CodeRabbit Configuration File (.coderabbit.yaml)

    • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
    • Please see the configuration documentation for more information.
    • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

    Documentation and Community

    • Visit our Documentation for detailed information on how to use CodeRabbit.
    • Join our Discord Community to get help, request features, and share feedback.
    • Follow us on X/Twitter for updates and announcements.
    Edited by CodeRabbitAI
  • Actionable comments posted: 0

    Outside diff range, codebase verification and nitpick comments (1)
    ipscrambling/dependencies.gradle (1)

    24-24: Inconsistent versioning for orbot_service and orbot_service_dependencies.

    The orbot_service version has been updated to orbot-17.2.1-2, but orbot_service_dependencies still references the old version orbot-17.2.1-1. This inconsistency could lead to potential issues. Please update orbot_service_dependencies to orbot-17.2.1-2 for consistency.

    • ipscrambling/dependencies.gradle: Update orbot_service_dependencies version to orbot-17.2.1-2.
    Analysis chain

    Version update for orbot_service approved.

    The version update from orbot-17.2.1-1 to orbot-17.2.1-2 likely includes critical updates or patches.

    Ensure compatibility and verify the impact on the project.

    Scripts executed

    The following scripts were executed for the analysis:

    Script:

    #!/bin/bash
    # Description: Verify the impact of the `orbot_service` version update on the project.
    
    # Test: Search for the usage of `orbot_service`. Expect: No breaking changes.
    rg --type gradle -A 5 'orbot_service'
    

    Length of output: 2104


    Script:

    #!/bin/bash
    # Description: Verify if `orbot_service_dependencies` should also be updated to `orbot-17.2.1-2` and check for any other references that might need updating.
    
    # Test: Search for all occurrences of `orbot_service_dependencies` and `orbot_service` in the project.
    rg 'orbot_service_dependencies'
    rg 'orbot_service'
    

    Length of output: 1818

  • Walkthrough

    Walkthrough

    The changes involve updating several components of an Android project, including the build.gradle file to target SDK version 34, dependency version upgrades for libraries such as androidx_core and orbotservice, and modifications to various classes related to deprecated methods and permissions. These updates enhance compatibility with newer Android features, streamline code clarity, and ensure compliance with recent SDK standards.

    Changes

    File Path Change Summary
    build.gradle Updated targetSdk from 33 to 34 in ext.buildConfig.
    gradle/libs.versions.toml Incremented orbotservice version from 17.2.1-1 to 17.2.1-2.
    ipscrambling/dependencies.gradle Updated dependencies: androidx_core from 1.6.0 to 1.13.1, androidx_localbroadcast from 1.0.0 to 1.1.0, orbot_service from 17.2.1-1 to 17.2.1-2.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/app/AppOpsManager.java Updated copyright years and added permissions annotation to setMode method; updated deprecation annotations for strOpToOp and setMode to API 35.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/PackageManager.java Updated deprecation annotations for various methods to reflect API 35.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserManager.java Updated deprecation annotations for methods getProfiles and isManagedProfile to API 35.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/net/VpnManager.java Updated deprecation annotations for methods related to VPN to API 35.
    permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserHandle.java Updated copyright years; added annotations indicating API 30 and deprecation at API 35 for myUserId.
    permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt Simplified conditional logic for SDK version checks, consolidating cases for versions above 29.

    Recent review details

    Configuration used: CodeRabbit UI Review profile: CHILL

    Commits

    Files that changed from the base of the PR and between 9d1d655a and 3d950a9b.

    Files selected for processing (13)
    • build.gradle (1 hunks)
    • gradle/libs.versions.toml (1 hunks)
    • ipscrambling/dependencies.gradle (2 hunks)
    • ipscrambling/orbotservice (1 hunks)
    • permissionseos/libs/hidden-apis-stub/src/main/java/android/app/AppOpsManager.java (4 hunks)
    • permissionseos/libs/hidden-apis-stub/src/main/java/android/app/NotificationChannel.java (2 hunks)
    • permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/PackageManager.java (7 hunks)
    • permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/UserInfo.java (2 hunks)
    • permissionseos/libs/hidden-apis-stub/src/main/java/android/net/VpnManager.java (4 hunks)
    • permissionseos/libs/hidden-apis-stub/src/main/java/android/os/ServiceManager.java (2 hunks)
    • permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserHandle.java (2 hunks)
    • permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserManager.java (2 hunks)
    • permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt (4 hunks)
    Files skipped from review due to trivial changes (4)
    • build.gradle
    • gradle/libs.versions.toml
    • ipscrambling/orbotservice
    • permissionseos/libs/hidden-apis-stub/src/main/java/android/app/NotificationChannel.java
    Additional comments not posted (26)
    permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/UserInfo.java (1)

    31-32: Update Deprecation Timeline.

    The change updates the @DeprecatedSinceApi annotation from api = 34 to api = 35, reflecting the updated deprecation timeline. This change is correct and ensures the method's documentation is up to date.

    permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserHandle.java (1)

    28-32: Add Annotations for API Usage and Deprecation.

    The @TargetApi(30) and @DeprecatedSinceApi(api = 35, message = "Check availability in SDK35") annotations provide clear documentation on the intended usage and deprecation status of the myUserId method. This enhances code maintainability and clarity.

    permissionseos/libs/hidden-apis-stub/src/main/java/android/os/ServiceManager.java (1)

    27-31: Add Annotations for API Usage and Deprecation.

    The @TargetApi(30) and @DeprecatedSinceApi(api = 35, message = "Check availability in SDK35") annotations provide clear documentation on the intended usage and deprecation status of the getService method. This enhances code maintainability and clarity.

    permissionseos/libs/hidden-apis-stub/src/main/java/android/app/AppOpsManager.java (4)

    2-2: Update copyright notice.

    The copyright notice update to reflect the years 2022 to 2024 is correct.


    24-24: Add @RequiresPermission annotation.

    The addition of the @RequiresPermission annotation from the androidx.annotation package is appropriate and enhances clarity regarding required permissions.


    34-35: Update deprecation annotation for strOpToOp method.

    The @DeprecatedSinceApi annotation update to indicate deprecation since API level 35 is correct.


    43-46: Update deprecation and permission annotations for setMode method.

    The @DeprecatedSinceApi annotation update to indicate deprecation since API level 35 and the addition of the @RequiresPermission annotation are correct and enhance clarity.

    permissionseos/libs/hidden-apis-stub/src/main/java/android/os/UserManager.java (4)

    2-2: Update copyright notice.

    The copyright notice update to reflect the year 2024 is correct.


    32-33: Add comments regarding alternative permissions.

    The added comments clarify that starting from API 33, the permission android.permission.QUERY_USERS can be used as an alternative to android.permission.MANAGE_USERS. This information is useful and enhances clarity.


    36-37: Update deprecation annotation for getProfiles method.

    The @DeprecatedSinceApi annotation update to indicate deprecation since API level 35 is correct.


    48-49: Update deprecation annotation for isManagedProfile method.

    The @DeprecatedSinceApi annotation update to indicate deprecation since API level 35 is correct.

    permissionseos/libs/hidden-apis-stub/src/main/java/android/net/VpnManager.java (4)

    2-2: Update copyright notice.

    The copyright notice update to reflect the years 2022 to 2024 is correct.


    33-34: Update deprecation annotation for prepareVpn method.

    The @DeprecatedSinceApi annotation update to indicate deprecation since API level 35 is correct.


    46-47: Update deprecation annotation for setVpnPackageAuthorization method.

    The @DeprecatedSinceApi annotation update to indicate deprecation since API level 35 is correct.


    57-58: Update deprecation and permission annotations for getAlwaysOnVpnPackageForUser method.

    The @DeprecatedSinceApi annotation update to indicate deprecation since API level 35 and the addition of the @RequiresPermission annotation are correct and enhance clarity.

    permissionseos/libs/hidden-apis-stub/src/main/java/android/content/pm/PackageManager.java (5)

    38-39: Deprecation message update approved.

    The deprecation message for NameNotFoundException has been correctly updated to indicate SDK35.


    53-54: Deprecation message update approved.

    The deprecation message for grantRuntimePermission has been correctly updated to indicate SDK35.


    65-66: Deprecation message update approved.

    The deprecation message for revokeRuntimePermission has been correctly updated to indicate SDK35.


    77-80: Deprecation message update approved.

    The deprecation message for getApplicationInfoAsUser has been correctly updated to indicate SDK35 and provide additional guidance.


    91-94: Deprecation message update approved.

    The deprecation message for getInstalledPackagesAsUser has been correctly updated to indicate SDK35 and provide additional guidance.

    ipscrambling/dependencies.gradle (2)

    14-14: Version update for androidx_localbroadcast approved.

    The version update from 1.0.0 to 1.1.0 likely includes improvements or changes in functionality.

    Ensure compatibility and verify the impact on the project.

    Verification successful

    Version update for androidx_localbroadcast approved.

    The version update from 1.0.0 to 1.1.0 likely includes improvements or changes in functionality. The usage of LocalBroadcastManager in the project appears to be straightforward and should not be affected by the update.

    • OrbotSupervisor.kt: Usage of LocalBroadcastManager for registering/unregistering broadcast receivers and sending broadcast intents.
    Scripts executed

    The following scripts were executed for the analysis:

    Script:

    #!/bin/bash
    # Description: Verify the impact of the `androidx_localbroadcast` version update on the project.
    
    # Test: Search for the usage of `androidx_localbroadcast`. Expect: No breaking changes.
    rg --type gradle -A 5 'androidx.localbroadcastmanager'
    

    Length of output: 937


    Script:

    #!/bin/bash
    # Description: Search for the usage of `androidx.localbroadcastmanager` in the codebase.
    
    # Test: Search for the usage of `androidx.localbroadcastmanager`. Expect: No breaking changes.
    rg 'androidx.localbroadcastmanager'
    

    Length of output: 898


    Script:

    #!/bin/bash
    # Description: Extract relevant code segments from `OrbotSupervisor.kt` that use `androidx.localbroadcastmanager`.
    
    # Test: Extract code segments. Expect: No breaking changes.
    rg --type kotlin -A 5 'androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance' ipscrambling/src/main/java/foundation/e/advancedprivacy/ipscrambler/OrbotSupervisor.kt
    

    Length of output: 908


    10-10: Version update for androidx_core approved.

    The version update from 1.6.0 to 1.13.1 is significant and likely includes important enhancements or bug fixes.

    Ensure compatibility and verify the impact on the project.

    permissionseos/src/main/java/foundation/e/advancedprivacy/externalinterfaces/permissions/PermissionsPrivacyModuleImpl.kt (4)

    125-125: Simplification of conditional logic in setBlockable approved.

    The simplification enhances readability and maintainability while preserving functionality.


    133-133: Simplification of conditional logic in setVpnPackageAuthorization approved.

    The simplification enhances readability and maintainability while preserving functionality.


    201-201: Simplification of conditional logic in getAlwaysOnVpnPackage approved.

    The simplification enhances readability and maintainability while preserving functionality.


    2-3: Overall changes approved.

    The overall changes enhance readability and maintainability while preserving functionality.


    Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

    Share
    Tips

    Chat

    There are 3 ways to chat with CodeRabbit:

    • Review comments: Directly reply to a review comment made by CodeRabbit. Example:

      • I pushed a fix in commit <commit_id>.
      • Generate unit testing code for this file.
    • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:

      • @coderabbitai generate unit testing code for this file.
      • @coderabbitai modularize this function.
    • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:

      • @coderabbitai generate interesting stats about this repository and render them as a table.
      • @coderabbitai show all the console.log statements in this repository.
      • @coderabbitai read src/utils.ts and generate unit testing code.
      • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
      • @coderabbitai help me debug CodeRabbit configuration file.

    Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

    CodeRabbit Commands (invoked as PR comments)

    • @coderabbitai pause to pause the reviews on a PR.
    • @coderabbitai resume to resume the paused reviews.
    • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
    • @coderabbitai full review to do a full review from scratch and review all the files again.
    • @coderabbitai summary to regenerate the summary of the PR.
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
    • @coderabbitai help to get help.

    Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

    CodeRabbit Configuration File (.coderabbit.yaml)

    • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
    • Please see the configuration documentation for more information.
    • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

    Documentation and Community

    • Visit our Documentation for detailed information on how to use CodeRabbit.
    • Join our Discord Community to get help, request features, and share feedback.
    • Follow us on X/Twitter for updates and announcements.
  • CodeRabbitAI changed the description

    changed the description

  • Sayantan Roychowdhury approved this merge request

    approved this merge request

  • added 1 commit

    • d627af6b - tech:2376: Improve sdk specific method naming.

    Compare with previous version

  • Guillaume Jacquart reset approvals from @SayantanRC by pushing to the branch

    reset approvals from @SayantanRC by pushing to the branch

  • Vincent Bourgmayer resolved all threads

    resolved all threads

  • Sayantan Roychowdhury approved this merge request

    approved this merge request

  • Vincent Bourgmayer
  • Vincent Bourgmayer resolved all threads

    resolved all threads

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading