Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ constructor(

companion object {
val permissions = buildList {
add(Manifest.permission.BODY_SENSORS)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
add(Manifest.permission.BODY_SENSORS)
}
Comment on lines +87 to +89

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For improved readability and to make the code more self-documenting, consider extracting Build.VERSION_CODES.VANILLA_ICE_CREAM into a named constant. This makes the reason for this specific API level check more explicit, as it relates to the maxSdkVersion for the BODY_SENSORS permission in your manifest.

For example, you could define a constant in the companion object and use it in the check:

private const val MAX_BODY_SENSORS_SDK = Build.VERSION_CODES.VANILLA_ICE_CREAM

// ... inside buildList
if (Build.VERSION.SDK_INT <= MAX_BODY_SENSORS_SDK) {
    add(Manifest.permission.BODY_SENSORS)
}

add(Manifest.permission.ACCESS_FINE_LOCATION)
add(Manifest.permission.ACTIVITY_RECOGNITION)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
Expand Down
Loading