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

Commit 3612487d authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #2174566: HOT STABILITY: NPE in activity manager

- Don't crash if the service's app process doesn't have a thread (this
  can happen if we are currently starting the process and then try to
  start the service again).
- Be more robust about deciding to start a service's process: try each
  time it is started; the startProcess call will take care of ignoring
  it if the process is already started.
- Fix some issues where we would leave dead processes on the low memory
  list.

Change-Id: I490e01ba7b45adc191bab7ace377b6873e284897
parent 348b92bd
Loading
Loading
Loading
Loading
+17 −13
Original line number Diff line number Diff line
@@ -4556,7 +4556,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
                    long now = SystemClock.uptimeMillis();
                    for (i=0; i<count; i++) {
                        ProcessRecord rec = mLRUProcesses.get(i);
                        if (rec.thread != null &&
                        if (rec != app && rec.thread != null &&
                                (rec.lastLowMemory+GC_MIN_INTERVAL) <= now) {
                            // The low memory report is overriding any current
                            // state for a GC request.  Make sure to do
@@ -9852,6 +9852,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
            mLRUProcesses.remove(index);
        }
        mProcessesToGc.remove(app);
        
        // Dismiss any open dialogs.
        if (app.crashDialog != null) {
            app.crashDialog.dismiss();
@@ -10519,7 +10521,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
        //Log.i(TAG, "Bring up service:");
        //r.dump("  ");
        if (r.app != null) {
        if (r.app != null && r.app.thread != null) {
            sendServiceArgsLocked(r, false);
            return true;
        }
@@ -10550,7 +10552,6 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
            // restart the application.
        }
        if (!mPendingServices.contains(r)) {
        // Not running -- get it started, and enqueue this service record
        // to be executed when the app comes up.
        if (startProcessLocked(appName, r.appInfo, true, intentFlags,
@@ -10562,8 +10563,11 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
            bringDownServiceLocked(r, true);
            return false;
        }
        
        if (!mPendingServices.contains(r)) {
            mPendingServices.add(r);
        }
        
        return true;
    }