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

Commit f54fcb71 authored by Ben Miles's avatar Ben Miles Committed by Android (Google) Code Review
Browse files

Merge "Improve debug store logging for enhanced ANR actionability" into main

parents 54ce4f30 6e191ea8
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.Message;
import android.os.RemoteException;
import android.util.Log;

import com.android.internal.os.DebugStore;
import com.android.internal.os.SomeArgs;

import java.lang.ref.WeakReference;
@@ -79,6 +80,9 @@ public abstract class JobServiceEngine {
    /** Message that the network to use has changed. */
    private static final int MSG_INFORM_OF_NETWORK_CHANGE = 8;

    private static final boolean DEBUG_STORE_ENABLED =
            com.android.internal.os.Flags.debugStoreEnabled();

    private final IJobService mBinder;

    /**
@@ -125,6 +129,12 @@ public abstract class JobServiceEngine {
            JobServiceEngine service = mService.get();
            if (service != null) {
                Message m = Message.obtain(service.mHandler, MSG_EXECUTE_JOB, jobParams);
                if (DEBUG_STORE_ENABLED) {
                    DebugStore.recordScheduleStartJob(
                            System.identityHashCode(m.obj),
                            jobParams.getJobId(),
                            jobParams.getJobNamespace());
                }
                m.sendToTarget();
            }
        }
@@ -144,6 +154,12 @@ public abstract class JobServiceEngine {
            JobServiceEngine service = mService.get();
            if (service != null) {
                Message m = Message.obtain(service.mHandler, MSG_STOP_JOB, jobParams);
                if (DEBUG_STORE_ENABLED) {
                    DebugStore.recordScheduleStopJob(
                            System.identityHashCode(m.obj),
                            jobParams.getJobId(),
                            jobParams.getJobNamespace());
                }
                m.sendToTarget();
            }
        }
@@ -164,6 +180,11 @@ public abstract class JobServiceEngine {
            switch (msg.what) {
                case MSG_EXECUTE_JOB: {
                    final JobParameters params = (JobParameters) msg.obj;
                    long debugStoreId = -1;
                    if (DEBUG_STORE_ENABLED) {
                            debugStoreId =
                                    DebugStore.recordStartJob(System.identityHashCode(params));
                    }
                    try {
                        params.enableCleaner();
                        boolean workOngoing = JobServiceEngine.this.onStartJob(params);
@@ -174,17 +195,29 @@ public abstract class JobServiceEngine {
                    } catch (Exception e) {
                        Log.e(TAG, "Error while executing job: " + params.getJobId());
                        throw new RuntimeException(e);
                    } finally {
                        if (DEBUG_STORE_ENABLED) {
                            DebugStore.recordEventEnd(debugStoreId);
                        }
                    }
                    break;
                }
                case MSG_STOP_JOB: {
                    final JobParameters params = (JobParameters) msg.obj;
                    long debugStoreId = -1;
                    if (DEBUG_STORE_ENABLED) {
                        debugStoreId = DebugStore.recordStopJob(System.identityHashCode(params));
                    }
                    try {
                        boolean ret = JobServiceEngine.this.onStopJob(params);
                        ackStopMessage(params, ret);
                    } catch (Exception e) {
                        Log.e(TAG, "Application unable to handle onStopJob.", e);
                        throw new RuntimeException(e);
                    } finally {
                        if (DEBUG_STORE_ENABLED) {
                            DebugStore.recordEventEnd(debugStoreId);
                        }
                    }
                    break;
                }
+31 −28
Original line number Diff line number Diff line
@@ -1157,19 +1157,15 @@ public final class ActivityThread extends ClientTransactionHandler
                CompatibilityInfo compatInfo, int resultCode, String data, Bundle extras,
                boolean ordered, boolean assumeDelivered, int sendingUser, int processState,
                int sendingUid, String sendingPackage) {
            long debugStoreId = -1;
            if (DEBUG_STORE_ENABLED) {
                debugStoreId = DebugStore.recordScheduleReceiver();
            }
            updateProcessState(processState, false);
            ReceiverData r = new ReceiverData(intent, resultCode, data, extras,
                    ordered, false, assumeDelivered, mAppThread.asBinder(), sendingUser,
                    sendingUid, sendingPackage);
            r.info = info;
            sendMessage(H.RECEIVER, r);
            if (DEBUG_STORE_ENABLED) {
                DebugStore.recordEventEnd(debugStoreId);
                DebugStore.recordScheduleBroadcastReceive(System.identityHashCode(r), intent);
            }
            sendMessage(H.RECEIVER, r);
        }

        public final void scheduleReceiverList(List<ReceiverInfo> info) throws RemoteException {
@@ -1219,6 +1215,9 @@ public final class ActivityThread extends ClientTransactionHandler
                Trace.instant(Trace.TRACE_TAG_ACTIVITY_MANAGER, "scheduleCreateService. token="
                        + token);
            }
            if (DEBUG_STORE_ENABLED) {
                DebugStore.recordScheduleServiceCreate(System.identityHashCode(s), info);
            }
            sendMessage(H.CREATE_SERVICE, s);
        }

@@ -1241,6 +1240,9 @@ public final class ActivityThread extends ClientTransactionHandler
                Trace.instant(Trace.TRACE_TAG_ACTIVITY_MANAGER, "scheduleBindService. token="
                        + token + " bindSeq=" + bindSeq);
            }
            if (DEBUG_STORE_ENABLED) {
                DebugStore.recordScheduleServiceBind(System.identityHashCode(s), s.intent);
            }
            sendMessage(H.BIND_SERVICE, s);
        }

@@ -1274,6 +1276,9 @@ public final class ActivityThread extends ClientTransactionHandler
                    Trace.instant(Trace.TRACE_TAG_ACTIVITY_MANAGER, "scheduleServiceArgs. token="
                            + token + " startId=" + s.startId);
                }
                if (DEBUG_STORE_ENABLED) {
                    DebugStore.recordScheduleServiceStart(System.identityHashCode(s), s.args);
                }
                sendMessage(H.SERVICE_ARGS, s);
            }
        }
@@ -1341,6 +1346,9 @@ public final class ActivityThread extends ClientTransactionHandler
                FileDescriptor applicationSharedMemoryFd,
                long startRequestedElapsedTime,
                long startRequestedUptime) {
            if (DEBUG_STORE_ENABLED) {
                DebugStore.recordScheduleBindApplication();
            }
            if (services != null) {
                if (false) {
                    // Test code to make sure the app could see the passed-in services.
@@ -1518,10 +1526,6 @@ public final class ActivityThread extends ClientTransactionHandler
                boolean sticky, boolean assumeDelivered, int sendingUser, int processState,
                int sendingUid, String sendingPackage)
                throws RemoteException {
            long debugStoreId = -1;
            if (DEBUG_STORE_ENABLED) {
                debugStoreId = DebugStore.recordScheduleRegisteredReceiver();
            }
            updateProcessState(processState, false);

            // We can't modify IIntentReceiver due to UnsupportedAppUsage, so
@@ -1546,9 +1550,6 @@ public final class ActivityThread extends ClientTransactionHandler
                receiver.performReceive(intent, resultCode, dataStr, extras, ordered, sticky,
                        sendingUser);
            }
            if (DEBUG_STORE_ENABLED) {
                DebugStore.recordEventEnd(debugStoreId);
            }
        }

        @Override
@@ -2548,7 +2549,7 @@ public final class ActivityThread extends ClientTransactionHandler
                    Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "bindApplication");
                    if (DEBUG_STORE_ENABLED) {
                        debugStoreId =
                                DebugStore.recordHandleBindApplication();
                                DebugStore.recordBindApplication();
                    }
                    AppBindData data = (AppBindData)msg.obj;
                    handleBindApplication(data);
@@ -2575,20 +2576,10 @@ public final class ActivityThread extends ClientTransactionHandler
                        }
                    }
                    ReceiverData receiverData = (ReceiverData) msg.obj;
                    if (DEBUG_STORE_ENABLED) {
                        debugStoreId =
                            DebugStore.recordBroadcastReceive(
                                receiverData.intent, System.identityHashCode(receiverData));
                    }

                    try {
                        handleReceiver(receiverData);
                    } finally {
                        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
                        if (DEBUG_STORE_ENABLED) {
                            DebugStore.recordEventEnd(debugStoreId);
                            shouldLogLongMessage = false;
                        }
                    }
                    break;
                case CREATE_SERVICE:
@@ -2598,7 +2589,9 @@ public final class ActivityThread extends ClientTransactionHandler
                    }
                    CreateServiceData createServiceData = (CreateServiceData) msg.obj;
                    if (DEBUG_STORE_ENABLED) {
                        debugStoreId = DebugStore.recordServiceCreate(createServiceData.info);
                        debugStoreId =
                                DebugStore.recordServiceCreate(
                                        System.identityHashCode(msg.obj));
                    }

                    try {
@@ -2619,7 +2612,8 @@ public final class ActivityThread extends ClientTransactionHandler
                    BindServiceData bindData = (BindServiceData) msg.obj;
                    if (DEBUG_STORE_ENABLED) {
                        debugStoreId =
                                DebugStore.recordServiceBind(bindData.rebind, bindData.intent);
                                DebugStore.recordServiceBind(
                                        System.identityHashCode(msg.obj));
                    }
                    try {
                        handleBindService(bindData);
@@ -2647,8 +2641,9 @@ public final class ActivityThread extends ClientTransactionHandler
                    }
                    ServiceArgsData serviceData = (ServiceArgsData) msg.obj;
                    if (DEBUG_STORE_ENABLED) {
                        debugStoreId = DebugStore.recordServiceOnStart(serviceData.startId,
                                serviceData.flags, serviceData.args);
                        debugStoreId =
                                DebugStore.recordServiceStart(
                                        System.identityHashCode(msg.obj));
                    }

                    try {
@@ -5051,6 +5046,11 @@ public final class ActivityThread extends ClientTransactionHandler
                + ": " + e.toString(), e);
        }

        long debugStoreId = -1;
        if(DEBUG_STORE_ENABLED) {
            debugStoreId = DebugStore.recordBroadcastReceive(System.identityHashCode(data),
                receiver.getClass().getSimpleName());
        }
        try {
            if (localLOGV) Slog.v(
                TAG, "Performing receive of " + data.intent
@@ -5075,6 +5075,9 @@ public final class ActivityThread extends ClientTransactionHandler
            }
        } finally {
            sCurrentBroadcastIntent.set(null);
            if(DEBUG_STORE_ENABLED) {
                DebugStore.recordEventEnd(debugStoreId);
            }
        }

        if (receiver.getPendingResult() != null) {
+6 −1
Original line number Diff line number Diff line
@@ -1829,7 +1829,8 @@ public final class LoadedApk {
                    if (DEBUG_STORE_ENABLED) {
                        debugStoreId =
                                DebugStore.recordBroadcastReceiveReg(
                                        intent, System.identityHashCode(this));
                                    System.identityHashCode(this),
                                    receiver.getClass().getName());
                    }

                    try {
@@ -1935,6 +1936,10 @@ public final class LoadedApk {
                            + " seq=" + seq + " to " + mReceiver);
                }
            }

            if (DEBUG_STORE_ENABLED) {
                DebugStore.recordScheduleBroadcastReceiveReg(System.identityHashCode(args), intent);
            }
            if (intent == null || !mActivityThread.post(args.getRunnable())) {
                IActivityManager mgr = ActivityManager.getService();
                if (ActivityThread.DEBUG_BROADCAST) Slog.i(ActivityThread.TAG,
+248 −116

File changed.

Preview size limit exceeded, changes collapsed.

+247 −164

File changed.

Preview size limit exceeded, changes collapsed.