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

Commit eba527a6 authored by Joanne Chung's avatar Joanne Chung Committed by Android (Google) Code Review
Browse files

Merge "Catch NPE when reportInstallationToSecurityLog" into main

parents 20ff223a 42592cc8
Loading
Loading
Loading
Loading
+19 −12
Original line number Original line Diff line number Diff line
@@ -310,6 +310,10 @@ final class PackageMetrics {
        if (!SecurityLog.isLoggingEnabled()) {
        if (!SecurityLog.isLoggingEnabled()) {
            return;
            return;
        }
        }
        // TODO: Remove temp try-catch to avoid IllegalStateException. The reason is because
        //  the scan result is null for installExistingPackageAsUser(). Because it's installing
        //  a package that's already existing, there's no scanning or parsing involved
        try {
            final PackageSetting ps = mInstallRequest.getScannedPackageSetting();
            final PackageSetting ps = mInstallRequest.getScannedPackageSetting();
            if (ps == null) {
            if (ps == null) {
                return;
                return;
@@ -323,6 +327,9 @@ final class PackageMetrics {
                SecurityLog.writeEvent(SecurityLog.TAG_PACKAGE_UPDATED, packageName, versionCode,
                SecurityLog.writeEvent(SecurityLog.TAG_PACKAGE_UPDATED, packageName, versionCode,
                        userId);
                        userId);
            }
            }
        } catch (IllegalStateException | NullPointerException e) {
            // no-op
        }
    }
    }


    private static void reportUninstallationToSecurityLog(String packageName, long versionCode,
    private static void reportUninstallationToSecurityLog(String packageName, long versionCode,