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

Commit 203a9ab7 authored by Narayan Kamath's avatar Narayan Kamath
Browse files

Revert "Log the apk optimization state in the MetricsLogger"

This reverts commit 0a8bea81.


E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: ActivityManager
E AndroidRuntime: java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.android.server.am.ProcessRecord.requiredAbi' on a null object reference
E AndroidRuntime:        at com.android.server.am.ActivityMetricsLogger.logAppTransition(ActivityMetricsLogger.java:504)
E AndroidRuntime:        at com.android.server.am.ActivityMetricsLogger.access$100(ActivityMetricsLogger.java:62)

Bug: 73626352
Change-Id: Idd50e0d2cf34e5393b4ae76ef8bc48b0067532eb
parent 0a8bea81
Loading
Loading
Loading
Loading
+0 −5
Original line number Original line Diff line number Diff line
@@ -939,11 +939,6 @@ message AppStartChanged {
    // Empty if not set.
    // Empty if not set.
    optional string launch_token = 13;
    optional string launch_token = 13;


    // The compiler filter used when when the package was optimized.
    optional string package_optimization_compilation_filter = 14;

    // The reason why the package was optimized.
    optional string package_optimization_compilation_reason = 15;
}
}


message AppStartCancelChanged {
message AppStartCancelChanged {
+0 −34
Original line number Original line Diff line number Diff line
/**
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.content.pm.dex;

import android.content.pm.ApplicationInfo;

/**
 * Art manager local system service interface.
 *
 * @hide Only for use within the system server.
 */
public abstract class ArtManagerInternal {

    /**
     * Return optimization information about the application {@code info} when
     * in executes using the specified {@code abi}.
     */
    public abstract PackageOptimizationInfo getPackageOptimizationInfo(
            ApplicationInfo info, String abi);
}
+0 −47
Original line number Original line Diff line number Diff line
/**
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.content.pm.dex;

/**
 * Encapsulates information about the optimizations performed on a package.
 *
 * @hide
 */
public class PackageOptimizationInfo {
    private final String mCompilationFilter;
    private final String mCompilationReason;

    public PackageOptimizationInfo(String compilerFilter, String compilationReason) {
        this.mCompilationReason = compilationReason;
        this.mCompilationFilter = compilerFilter;
    }

    public String getCompilationReason() {
        return mCompilationReason;
    }

    public String getCompilationFilter() {
        return mCompilationFilter;
    }

    /**
     * Create a default optimization info object for the case when we have no information.
     */
    public static PackageOptimizationInfo createWithNoInfo() {
        return new PackageOptimizationInfo("no-info", "no-info");
    }
}
+0 −10
Original line number Original line Diff line number Diff line
@@ -5274,16 +5274,6 @@ message MetricsEvent {
    // OS: P
    // OS: P
    FIELD_QS_MODE = 1311;
    FIELD_QS_MODE = 1311;


    // FIELD: The compiler filter used when when optimizing the package.
    //        Logged together with app transition events.
    // OS: P
    PACKAGE_OPTIMIZATION_COMPILATION_FILTER = 1312;

    // FIELD: The reason for optimizing the package.
    //        Logged together with app transition events.
    // OS: P
    PACKAGE_OPTIMIZATION_COMPILATION_REASON = 1313;

    // ---- End P Constants, all P constants go above this line ----
    // ---- End P Constants, all P constants go above this line ----
    // Add new aosp constants above this line.
    // Add new aosp constants above this line.
    // END OF AOSP CONSTANTS
    // END OF AOSP CONSTANTS
+49 −88
Original line number Original line Diff line number Diff line
@@ -24,8 +24,6 @@ import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TR
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_WINDOWS_DRAWN_DELAY_MS;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.APP_TRANSITION_WINDOWS_DRAWN_DELAY_MS;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_CLASS_NAME;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_CLASS_NAME;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_INSTANT_APP_LAUNCH_TOKEN;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_INSTANT_APP_LAUNCH_TOKEN;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.PACKAGE_OPTIMIZATION_COMPILATION_REASON;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.PACKAGE_OPTIMIZATION_COMPILATION_FILTER;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_COLD_LAUNCH;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_COLD_LAUNCH;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_HOT_LAUNCH;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_HOT_LAUNCH;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_REPORTED_DRAWN_NO_BUNDLE;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_TRANSITION_REPORTED_DRAWN_NO_BUNDLE;
@@ -38,8 +36,6 @@ import static com.android.server.am.MemoryStatUtil.MemoryStat;
import static com.android.server.am.MemoryStatUtil.readMemoryStatFromMemcg;
import static com.android.server.am.MemoryStatUtil.readMemoryStatFromMemcg;


import android.content.Context;
import android.content.Context;
import android.content.pm.dex.ArtManagerInternal;
import android.content.pm.dex.PackageOptimizationInfo;
import android.metrics.LogMaker;
import android.metrics.LogMaker;
import android.os.Handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
@@ -52,7 +48,6 @@ import android.util.StatsLog;


import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.os.SomeArgs;
import com.android.internal.os.SomeArgs;
import com.android.server.LocalServices;


import java.util.ArrayList;
import java.util.ArrayList;


@@ -74,7 +69,7 @@ class ActivityMetricsLogger {
    private static final long INVALID_START_TIME = -1;
    private static final long INVALID_START_TIME = -1;


    private static final int MSG_CHECK_VISIBILITY = 0;
    private static final int MSG_CHECK_VISIBILITY = 0;
    private static final int MSG_LOG_APP_TRANSITION = 1;
    private static final int MSG_LOG_APP_START_MEMORY_STATE_CAPTURE = 1;


    // Preallocated strings we are sending to tron, so we don't have to allocate a new one every
    // Preallocated strings we are sending to tron, so we don't have to allocate a new one every
    // time we log.
    // time we log.
@@ -97,9 +92,6 @@ class ActivityMetricsLogger {
    private final SparseArray<StackTransitionInfo> mStackTransitionInfo = new SparseArray<>();
    private final SparseArray<StackTransitionInfo> mStackTransitionInfo = new SparseArray<>();
    private final SparseArray<StackTransitionInfo> mLastStackTransitionInfo = new SparseArray<>();
    private final SparseArray<StackTransitionInfo> mLastStackTransitionInfo = new SparseArray<>();
    private final H mHandler;
    private final H mHandler;

    private ArtManagerInternal mArtManagerInternal;

    private final class H extends Handler {
    private final class H extends Handler {


        public H(Looper looper) {
        public H(Looper looper) {
@@ -113,12 +105,12 @@ class ActivityMetricsLogger {
                    final SomeArgs args = (SomeArgs) msg.obj;
                    final SomeArgs args = (SomeArgs) msg.obj;
                    checkVisibility((TaskRecord) args.arg1, (ActivityRecord) args.arg2);
                    checkVisibility((TaskRecord) args.arg1, (ActivityRecord) args.arg2);
                    break;
                    break;
                case MSG_LOG_APP_TRANSITION:
                case MSG_LOG_APP_START_MEMORY_STATE_CAPTURE:
                    logAppTransition(msg.arg1, msg.arg2, (StackTransitionInfo) msg.obj);
                    logAppStartMemoryStateCapture((StackTransitionInfo) msg.obj);
                    break;
                    break;
            }
            }
        }
        }
    }
    };


    private final class StackTransitionInfo {
    private final class StackTransitionInfo {
        private ActivityRecord launchedActivity;
        private ActivityRecord launchedActivity;
@@ -459,15 +451,6 @@ class ActivityMetricsLogger {
            if (type == -1) {
            if (type == -1) {
                return;
                return;
            }
            }
            mHandler.obtainMessage(MSG_LOG_APP_TRANSITION, mCurrentTransitionDeviceUptime,
                    mCurrentTransitionDelayMs, info).sendToTarget();
        }
    }

    // This gets called on the handler without holding the activity manager lock.
    private void logAppTransition(int currentTransitionDeviceUptime, int currentTransitionDelayMs,
            StackTransitionInfo info) {
        final int type = getTransitionType(info);
            final LogMaker builder = new LogMaker(APP_TRANSITION);
            final LogMaker builder = new LogMaker(APP_TRANSITION);
            builder.setPackageName(info.launchedActivity.packageName);
            builder.setPackageName(info.launchedActivity.packageName);
            builder.setType(type);
            builder.setType(type);
@@ -484,8 +467,8 @@ class ActivityMetricsLogger {
            }
            }
            builder.addTaggedData(APP_TRANSITION_IS_EPHEMERAL, isInstantApp ? 1 : 0);
            builder.addTaggedData(APP_TRANSITION_IS_EPHEMERAL, isInstantApp ? 1 : 0);
            builder.addTaggedData(APP_TRANSITION_DEVICE_UPTIME_SECONDS,
            builder.addTaggedData(APP_TRANSITION_DEVICE_UPTIME_SECONDS,
                currentTransitionDeviceUptime);
                    mCurrentTransitionDeviceUptime);
        builder.addTaggedData(APP_TRANSITION_DELAY_MS, currentTransitionDelayMs);
            builder.addTaggedData(APP_TRANSITION_DELAY_MS, mCurrentTransitionDelayMs);
            builder.setSubtype(info.reason);
            builder.setSubtype(info.reason);
            if (info.startingWindowDelayMs != -1) {
            if (info.startingWindowDelayMs != -1) {
                builder.addTaggedData(APP_TRANSITION_STARTING_WINDOW_DELAY_MS,
                builder.addTaggedData(APP_TRANSITION_STARTING_WINDOW_DELAY_MS,
@@ -496,16 +479,6 @@ class ActivityMetricsLogger {
                        info.bindApplicationDelayMs);
                        info.bindApplicationDelayMs);
            }
            }
            builder.addTaggedData(APP_TRANSITION_WINDOWS_DRAWN_DELAY_MS, info.windowsDrawnDelayMs);
            builder.addTaggedData(APP_TRANSITION_WINDOWS_DRAWN_DELAY_MS, info.windowsDrawnDelayMs);
        final ArtManagerInternal artManagerInternal = getArtManagerInternal();
        final PackageOptimizationInfo packageOptimizationInfo = artManagerInternal == null
                ? PackageOptimizationInfo.createWithNoInfo()
                : artManagerInternal.getPackageOptimizationInfo(
                        info.launchedActivity.info.applicationInfo,
                        info.launchedActivity.app.requiredAbi);
        builder.addTaggedData(PACKAGE_OPTIMIZATION_COMPILATION_REASON,
                packageOptimizationInfo.getCompilationReason());
        builder.addTaggedData(PACKAGE_OPTIMIZATION_COMPILATION_FILTER,
                packageOptimizationInfo.getCompilationFilter());
            mMetricsLogger.write(builder);
            mMetricsLogger.write(builder);
            StatsLog.write(
            StatsLog.write(
                    StatsLog.APP_START_CHANGED,
                    StatsLog.APP_START_CHANGED,
@@ -515,17 +488,15 @@ class ActivityMetricsLogger {
                    info.launchedActivity.info.name,
                    info.launchedActivity.info.name,
                    info.launchedActivity.launchedFromPackage,
                    info.launchedActivity.launchedFromPackage,
                    isInstantApp,
                    isInstantApp,
                currentTransitionDeviceUptime * 1000,
                    mCurrentTransitionDeviceUptime * 1000,
                    info.reason,
                    info.reason,
                currentTransitionDelayMs,
                    mCurrentTransitionDelayMs,
                    info.startingWindowDelayMs,
                    info.startingWindowDelayMs,
                    info.bindApplicationDelayMs,
                    info.bindApplicationDelayMs,
                    info.windowsDrawnDelayMs,
                    info.windowsDrawnDelayMs,
                launchToken,
                    launchToken);
                packageOptimizationInfo.getCompilationReason(),
            mHandler.obtainMessage(MSG_LOG_APP_START_MEMORY_STATE_CAPTURE, info).sendToTarget();
                packageOptimizationInfo.getCompilationFilter());
        }

        logAppStartMemoryStateCapture(info);
    }
    }


    private int convertAppStartTransitionType(int tronType) {
    private int convertAppStartTransitionType(int tronType) {
@@ -615,14 +586,4 @@ class ActivityMetricsLogger {
                        launchedActivity.appInfo.uid)
                        launchedActivity.appInfo.uid)
                : null;
                : null;
    }
    }

    private ArtManagerInternal getArtManagerInternal() {
        if (mArtManagerInternal == null) {
            // Note that this may be null.
            // ArtManagerInternal is registered during PackageManagerService
            // initialization which happens after ActivityManagerService.
            mArtManagerInternal = LocalServices.getService(ArtManagerInternal.class);
        }
        return mArtManagerInternal;
    }
}
}
Loading