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

Commit ab5efde8 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change Iff5b8ce3 into eclair

* changes:
  Work on issue 2259506: camera ANRed and then device runtime restarted
parents dc49acb0 f670ef72
Loading
Loading
Loading
Loading
+47 −21
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
    static final int LOG_AM_SERVICE_CRASHED_TOO_MUCH = 30034;
    static final int LOG_AM_SCHEDULE_SERVICE_RESTART = 30035;
    static final int LOG_AM_PROVIDER_LOST_PROCESS = 30036;
    static final int LOG_AM_PROCESS_START_TIMEOUT = 30037;
    
    static final int LOG_BOOT_PROGRESS_AMS_READY = 3040;
    static final int LOG_BOOT_PROGRESS_ENABLE_SCREEN = 3050;
@@ -5199,13 +5200,23 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
        
        if (gone) {
            Log.w(TAG, "Process " + app + " failed to attach");
            EventLog.writeEvent(LOG_AM_PROCESS_START_TIMEOUT, pid, app.info.uid,
                    app.processName);
            mProcessNames.remove(app.processName, app.info.uid);
            Process.killProcess(pid);
            if (mPendingBroadcast != null && mPendingBroadcast.curApp.pid == pid) {
                Log.w(TAG, "Unattached app died before broadcast acknowledged, skipping");
                mPendingBroadcast = null;
                scheduleBroadcastsLocked();
            // Take care of any launching providers waiting for this process.
            checkAppInLaunchingProvidersLocked(app, true);
            // Take care of any services that are waiting for the process.
            for (int i=0; i<mPendingServices.size(); i++) {
                ServiceRecord sr = mPendingServices.get(i);
                if (app.info.uid == sr.appInfo.uid
                        && app.processName.equals(sr.processName)) {
                    Log.w(TAG, "Forcing bringing down service: " + sr);
                    mPendingServices.remove(i);
                    i--;
                    bringDownServiceLocked(sr, true);
                }
            }
            Process.killProcess(pid);
            if (mBackupTarget != null && mBackupTarget.app.pid == pid) {
                Log.w(TAG, "Unattached app died before backup, skipping");
                try {
@@ -5216,6 +5227,11 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
                    // Can't happen; the backup manager is local
                }
            }
            if (mPendingBroadcast != null && mPendingBroadcast.curApp.pid == pid) {
                Log.w(TAG, "Unattached app died before broadcast acknowledged, skipping");
                mPendingBroadcast = null;
                scheduleBroadcastsLocked();
            }
        } else {
            Log.w(TAG, "Spurious process start timeout - pid not known for " + app);
        }
@@ -9949,21 +9965,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
            app.pubProviders.clear();
        }
        
        // Look through the content providers we are waiting to have launched,
        // and if any run in this process then either schedule a restart of
        // the process or kill the client waiting for it if this process has
        // gone bad.
        for (int i=0; i<NL; i++) {
            ContentProviderRecord cpr = (ContentProviderRecord)
                    mLaunchingProviders.get(i);
            if (cpr.launchingApp == app) {
                if (!app.bad) {
        // Take care of any launching providers waiting for this process.
        if (checkAppInLaunchingProvidersLocked(app, false)) {
            restart = true;
                } else {
                    removeDyingProviderLocked(app, cpr);
                    NL = mLaunchingProviders.size();
                }
            }
        }
        
        // Unregister from connected content providers.
@@ -10060,6 +10064,28 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
        }
    }
    boolean checkAppInLaunchingProvidersLocked(ProcessRecord app, boolean alwaysBad) {
        // Look through the content providers we are waiting to have launched,
        // and if any run in this process then either schedule a restart of
        // the process or kill the client waiting for it if this process has
        // gone bad.
        int NL = mLaunchingProviders.size();
        boolean restart = false;
        for (int i=0; i<NL; i++) {
            ContentProviderRecord cpr = (ContentProviderRecord)
                    mLaunchingProviders.get(i);
            if (cpr.launchingApp == app) {
                if (!alwaysBad && !app.bad) {
                    restart = true;
                } else {
                    removeDyingProviderLocked(app, cpr);
                    NL = mLaunchingProviders.size();
                }
            }
        }
        return restart;
    }
    
    // =========================================================
    // SERVICES
    // =========================================================