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

Unverified Commit 8906450a authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #8589 from cketti/nullability-cleanup

Use smart casts to avoid awkward `if` conditions
parents 7fe83468 e3fc4564
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -148,13 +148,14 @@ class SettingsProvider : ContentProvider(), KoinComponent {
        val packageInfo = packageManager.getPackageInfo(callerPackage, PackageManager.GET_SIGNATURES)

        // We don't expect our callers to have multiple signers, so we don't service such requests.
        if (packageInfo.signatures?.size != 1) {
        val signatures = packageInfo.signatures
        if (signatures == null || signatures.size != 1) {
            return null
        }

        // In case of signature rotation, this will report the oldest used certificate, pretending that the signature
        // rotation never took place. We can only rely on our allowlist being up-to-date in this case.
        return packageInfo.signatures?.firstOrNull()
        return signatures.firstOrNull()
    }

    @TargetApi(Build.VERSION_CODES.P)
@@ -164,15 +165,16 @@ class SettingsProvider : ContentProvider(), KoinComponent {
        val packageInfo = packageManager.getPackageInfo(callerPackage, PackageManager.GET_SIGNING_CERTIFICATES)

        // We don't expect our callers to have multiple signers, so we don't service such requests.
        if (packageInfo.signingInfo?.hasMultipleSigners() == true) {
        val signingInfo = packageInfo.signingInfo
        if (signingInfo == null || signingInfo.hasMultipleSigners()) {
            return null
        }

        // We currently don't support servicing requests from callers that performed certificate rotation.
        if (packageInfo.signingInfo?.hasPastSigningCertificates() == true) {
        if (signingInfo.hasPastSigningCertificates()) {
            return null
        }

        return packageInfo.signingInfo?.signingCertificateHistory?.firstOrNull()
        return signingInfo.signingCertificateHistory?.firstOrNull()
    }
}