Merge "Work on issue #18201239: ANRs in com.google.process.gapps:" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
213269599b
@@ -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;
|
||||||
@@ -2758,7 +2765,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.
|
||||||
}
|
}
|
||||||
@@ -2787,7 +2794,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) {
|
||||||
@@ -2815,7 +2822,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) {
|
||||||
}
|
}
|
||||||
@@ -2897,7 +2904,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.
|
||||||
}
|
}
|
||||||
@@ -2928,7 +2935,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 "
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -1692,6 +1693,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) {
|
||||||
@@ -1813,7 +1815,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;
|
||||||
@@ -1862,6 +1864,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);
|
||||||
|
|||||||
@@ -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);
|
||||||
TimeUtils.formatDuration(destroyTime, now, pw);
|
pw.print(" destroyTime=");
|
||||||
|
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user