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

Commit f6b4b1a4 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by android-build-merger
Browse files

Merge "Work on issue #18201239: ANRs in com.google.process.gapps:" into...

Merge "Work on issue #18201239: ANRs in com.google.process.gapps:" into lmp-mr1-dev automerge: 21326959
automerge: 5346a21b

* commit '5346a21b':
  Work on issue #18201239: ANRs in com.google.process.gapps:
parents 2b2b1a9b 5346a21b
Loading
Loading
Loading
Loading
+12 −5
Original line number Original line Diff line number Diff line
@@ -168,6 +168,13 @@ public final class ActivityThread {
    private static final int LOG_ON_PAUSE_CALLED = 30021;
    private static final int LOG_ON_PAUSE_CALLED = 30021;
    private static final int LOG_ON_RESUME_CALLED = 30022;
    private static final int LOG_ON_RESUME_CALLED = 30022;


    /** Type for IActivityManager.serviceDoneExecuting: anonymous operation */
    public static final int SERVICE_DONE_EXECUTING_ANON = 0;
    /** Type for IActivityManager.serviceDoneExecuting: done with an onStart call */
    public static final int SERVICE_DONE_EXECUTING_START = 1;
    /** Type for IActivityManager.serviceDoneExecuting: done stopping (destroying) service */
    public static final int SERVICE_DONE_EXECUTING_STOP = 2;

    private ContextImpl mSystemContext;
    private ContextImpl mSystemContext;


    static IPackageManager sPackageManager;
    static IPackageManager sPackageManager;
@@ -2781,7 +2788,7 @@ public final class ActivityThread {
            mServices.put(data.token, service);
            mServices.put(data.token, service);
            try {
            try {
                ActivityManagerNative.getDefault().serviceDoneExecuting(
                ActivityManagerNative.getDefault().serviceDoneExecuting(
                        data.token, 0, 0, 0);
                        data.token, SERVICE_DONE_EXECUTING_ANON, 0, 0);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                // nothing to do.
                // nothing to do.
            }
            }
@@ -2810,7 +2817,7 @@ public final class ActivityThread {
                    } else {
                    } else {
                        s.onRebind(data.intent);
                        s.onRebind(data.intent);
                        ActivityManagerNative.getDefault().serviceDoneExecuting(
                        ActivityManagerNative.getDefault().serviceDoneExecuting(
                                data.token, 0, 0, 0);
                                data.token, SERVICE_DONE_EXECUTING_ANON, 0, 0);
                    }
                    }
                    ensureJitEnabled();
                    ensureJitEnabled();
                } catch (RemoteException ex) {
                } catch (RemoteException ex) {
@@ -2838,7 +2845,7 @@ public final class ActivityThread {
                                data.token, data.intent, doRebind);
                                data.token, data.intent, doRebind);
                    } else {
                    } else {
                        ActivityManagerNative.getDefault().serviceDoneExecuting(
                        ActivityManagerNative.getDefault().serviceDoneExecuting(
                                data.token, 0, 0, 0);
                                data.token, SERVICE_DONE_EXECUTING_ANON, 0, 0);
                    }
                    }
                } catch (RemoteException ex) {
                } catch (RemoteException ex) {
                }
                }
@@ -2920,7 +2927,7 @@ public final class ActivityThread {


                try {
                try {
                    ActivityManagerNative.getDefault().serviceDoneExecuting(
                    ActivityManagerNative.getDefault().serviceDoneExecuting(
                            data.token, 1, data.startId, res);
                            data.token, SERVICE_DONE_EXECUTING_START, data.startId, res);
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    // nothing to do.
                    // nothing to do.
                }
                }
@@ -2951,7 +2958,7 @@ public final class ActivityThread {


                try {
                try {
                    ActivityManagerNative.getDefault().serviceDoneExecuting(
                    ActivityManagerNative.getDefault().serviceDoneExecuting(
                            token, 0, 0, 0);
                            token, SERVICE_DONE_EXECUTING_STOP, 0, 0);
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    // nothing to do.
                    // nothing to do.
                    Slog.i(TAG, "handleStopService: unable to execute serviceDoneExecuting for "
                    Slog.i(TAG, "handleStopService: unable to execute serviceDoneExecuting for "
+17 −1
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Iterator;
import java.util.List;
import java.util.List;


import android.app.ActivityThread;
import android.os.Build;
import android.os.Build;
import android.os.DeadObjectException;
import android.os.DeadObjectException;
import android.os.Handler;
import android.os.Handler;
@@ -1693,6 +1694,7 @@ public final class ActiveServices {
                try {
                try {
                    bumpServiceExecutingLocked(r, false, "destroy");
                    bumpServiceExecutingLocked(r, false, "destroy");
                    mDestroyingServices.add(r);
                    mDestroyingServices.add(r);
                    r.destroying = true;
                    mAm.updateOomAdjLocked(r.app);
                    mAm.updateOomAdjLocked(r.app);
                    r.app.thread.scheduleStopService(r);
                    r.app.thread.scheduleStopService(r);
                } catch (Exception e) {
                } catch (Exception e) {
@@ -1814,7 +1816,7 @@ public final class ActiveServices {
    void serviceDoneExecutingLocked(ServiceRecord r, int type, int startId, int res) {
    void serviceDoneExecutingLocked(ServiceRecord r, int type, int startId, int res) {
        boolean inDestroying = mDestroyingServices.contains(r);
        boolean inDestroying = mDestroyingServices.contains(r);
        if (r != null) {
        if (r != null) {
            if (type == 1) {
            if (type == ActivityThread.SERVICE_DONE_EXECUTING_START) {
                // This is a call from a service start...  take care of
                // This is a call from a service start...  take care of
                // book-keeping.
                // book-keeping.
                r.callStart = true;
                r.callStart = true;
@@ -1863,6 +1865,20 @@ public final class ActiveServices {
                if (res == Service.START_STICKY_COMPATIBILITY) {
                if (res == Service.START_STICKY_COMPATIBILITY) {
                    r.callStart = false;
                    r.callStart = false;
                }
                }
            } else if (type == ActivityThread.SERVICE_DONE_EXECUTING_STOP) {
                // This is the final call from destroying the service...  we should
                // actually be getting rid of the service at this point.  Do some
                // validation of its state, and ensure it will be fully removed.
                if (!inDestroying) {
                    // Not sure what else to do with this...  if it is not actually in the
                    // destroying list, we don't need to make sure to remove it from it.
                    Slog.wtfStack(TAG, "Service done with onDestroy, but not inDestroying: "
                            + r);
                } else if (r.executeNesting != 1) {
                    Slog.wtfStack(TAG, "Service done with onDestroy, but executeNesting="
                            + r.executeNesting + ": " + r);
                    r.executeNesting = 1;
                }
            }
            }
            final long origId = Binder.clearCallingIdentity();
            final long origId = Binder.clearCallingIdentity();
            serviceDoneExecutingLocked(r, inDestroying, inDestroying);
            serviceDoneExecutingLocked(r, inDestroying, inDestroying);
+6 −3
Original line number Original line Diff line number Diff line
@@ -105,6 +105,7 @@ final class ServiceRecord extends Binder {
    long restartDelay;      // delay until next restart attempt.
    long restartDelay;      // delay until next restart attempt.
    long restartTime;       // time of last restart.
    long restartTime;       // time of last restart.
    long nextRestartTime;   // time when restartDelay will expire.
    long nextRestartTime;   // time when restartDelay will expire.
    boolean destroying;     // set when we have started destroying the service
    long destroyTime;       // time at which destory was initiated.
    long destroyTime;       // time at which destory was initiated.


    String stringName;      // caching of toString
    String stringName;      // caching of toString
@@ -251,9 +252,11 @@ final class ServiceRecord extends Binder {
                    TimeUtils.formatDuration(executingStart, now, pw);
                    TimeUtils.formatDuration(executingStart, now, pw);
                    pw.println();
                    pw.println();
        }
        }
        if (destroyTime != 0) {
        if (destroying || destroyTime != 0) {
            pw.print(" destroyed=");
            pw.print(prefix); pw.print("destroying="); pw.print(destroying);
                    pw.print(" destroyTime=");
                    TimeUtils.formatDuration(destroyTime, now, pw);
                    TimeUtils.formatDuration(destroyTime, now, pw);
                    pw.println();
        }
        }
        if (crashCount != 0 || restartCount != 0
        if (crashCount != 0 || restartCount != 0
                || restartDelay != 0 || nextRestartTime != 0) {
                || restartDelay != 0 || nextRestartTime != 0) {