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

Commit 9f21709b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't log Invalidation metrics before booting completed." into main

parents 87a25681 83f92894
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.util.SparseArray;

import com.android.internal.util.FrameworkStatsLog;
import com.android.server.LocalServices;
import com.android.server.SystemServiceManager;
import com.android.server.pm.pkg.AndroidPackage;

import java.io.File;
@@ -206,6 +207,8 @@ public final class PackageMetrics {
    private final SparseArray<InstallStep> mInstallSteps = new SparseArray<>();
    private final InstallRequest mInstallRequest;

    private static SystemServiceManager sSystemServiceManager = null;

    PackageMetrics(InstallRequest installRequest) {
        // New instance is used for tracking installation metrics only.
        // Other metrics should use static methods of this class.
@@ -618,6 +621,16 @@ public final class PackageMetrics {
     * Metrics for reporting what kind of reason to call the invalidation.
     */
    public static void reportCacheInvalidationEvent(int cacheType, int invalidationReason) {
        if (sSystemServiceManager == null) {
            sSystemServiceManager = LocalServices.getService(SystemServiceManager.class);
            if (sSystemServiceManager == null) {
                return;
            }
        }
        if (!sSystemServiceManager.isBootCompleted()) {
            return;
        }
        // TODO(b/430272418): Implement a local counter for periodic metrics reporting.
        FrameworkStatsLog.write(FrameworkStatsLog.PACKAGE_MANAGER_CACHE_INVALIDATION_REPORTED,
                cacheType, invalidationReason);
    }