Skip to content

Availability checks for APermissionManager and AParcel functions #29

@marcprux

Description

@marcprux

When building with the nightly-6.3 SDK (see #27), we check for availability for various API. This highlights a couple of functions that require later version of Android, such as the Android (nightly-6.3, aarch64, 29) build:

/Users/runner/work/Android/Android/Sources/AndroidManifest/PermissionCheck.swift:78:13: error: 'APermissionManager_checkPermission' is only available in Android 31 or newer
 45 | }
 46 | 
 47 | public extension Permission {
    |        `- note: add '@available' attribute to enclosing extension
 48 |     
 49 |     /// Checks this permission for a specific process/user pair using
    :
 68 |     ///   - uid: User ID to evaluate. Defaults to the current user ID.
 69 |     /// - Returns: Permission check status.
 70 |     internal func _check(
    |                   `- note: add '@available' attribute to enclosing instance method
 71 |         pid: pid_t = getpid(),
 72 |         uid: uid_t = getuid()
    :
 76 |         #if os(Android)
 77 |         returnCode = rawValue.withCString {
 78 |             APermissionManager_checkPermission($0, pid, uid, &result)
    |             |- error: 'APermissionManager_checkPermission' is only available in Android 31 or newer
    |             `- note: add 'if #available' version check
 79 |         }
 80 |         #else

and the Android (nightly-6.3, aarch64, 31) build:

/Users/runner/work/Android/Android/Sources/AndroidBinder/Parcel.swift:675:9: error: 'AParcel_marshal' is only available in Android 33 or newer
 620 | // MARK: - Handle: Position & Size
 621 | 
 622 | internal extension Parcel.Handle {
     |          `- note: add '@available' attribute to enclosing extension
 623 | 
 624 |     /**
     :
 672 |      * Available since API level 33.
 673 |      */
 674 |     func marshal(into buffer: UnsafeMutablePointer<UInt8>, start: Int, length: Int) -> Result<Void, AndroidBinderError> {
     |          `- note: add '@available' attribute to enclosing instance method
 675 |         AParcel_marshal(pointer, buffer, start, length).mapError()
     |         |- error: 'AParcel_marshal' is only available in Android 33 or newer
     |         `- note: add 'if #available' version check
 676 |     }
 677 | 

You might consider guarding these within if #available(Android 33, *) { checks, which was added in swiftlang/swift#84574 and so will require the 6.3 SDK + NDK 28+.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions