Clean up app following death when creating service
If an app has died, run through the cleanup before relaunching its service. Also a little simplifying refactor. Fixes bug 16979752. Change-Id: I376cbef2ea00fc626588386317f092cc6dea0bdc
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import android.os.DeadObjectException;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemProperties;
|
||||
@@ -1424,6 +1425,9 @@ public final class ActiveServices {
|
||||
app.repProcState);
|
||||
r.postNotification();
|
||||
created = true;
|
||||
} catch (DeadObjectException e) {
|
||||
Slog.w(TAG, "Application dead when creating service " + r);
|
||||
mAm.appDiedLocked(app);
|
||||
} finally {
|
||||
if (!created) {
|
||||
app.services.remove(r);
|
||||
|
||||
@@ -4201,6 +4201,10 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
}
|
||||
}
|
||||
|
||||
final void appDiedLocked(ProcessRecord app) {
|
||||
appDiedLocked(app, app.pid, app.thread);
|
||||
}
|
||||
|
||||
final void appDiedLocked(ProcessRecord app, int pid,
|
||||
IApplicationThread thread) {
|
||||
|
||||
@@ -8474,7 +8478,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
"Existing provider " + cpr.name.flattenToShortString()
|
||||
+ " is crashing; detaching " + r);
|
||||
boolean lastRef = decProviderCountLocked(conn, cpr, token, stable);
|
||||
appDiedLocked(cpr.proc, cpr.proc.pid, cpr.proc.thread);
|
||||
appDiedLocked(cpr.proc);
|
||||
if (!lastRef) {
|
||||
// This wasn't the last ref our process had on
|
||||
// the provider... we have now been killed, bail.
|
||||
@@ -8924,7 +8928,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
+ ") early provider death");
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
appDiedLocked(proc, proc.pid, proc.thread);
|
||||
appDiedLocked(proc);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
|
||||
@@ -1158,7 +1158,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
Slog.e(TAG, "Second failure launching "
|
||||
+ r.intent.getComponent().flattenToShortString()
|
||||
+ ", giving up", e);
|
||||
mService.appDiedLocked(app, app.pid, app.thread);
|
||||
mService.appDiedLocked(app);
|
||||
stack.requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null,
|
||||
"2nd-crash", false);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user