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

Commit 83f92894 authored by lpeter's avatar lpeter
Browse files

Don't log Invalidation metrics before booting completed.

Flag: EXEMPT bugfix

I use abtd/runs with this CL to verify that this CL fixes
the boot time regression.

Test result as below:
SystemServerTiming_StartPackageManagerService-mean:486.00

The link to abtd/runs as below:
https://android-build.corp.google.com/test_investigate/invocation/I68600010419379184/test/TR52929803037174313/

Bug: 429069340
Test: Manual test
Change-Id: Ifb88b024c746fffacebe50528af41ecbbe250448
parent 182e1409
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);
    }