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

Commit ff072725 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Work on issue #17624121: Settings crash while launching on wiped device

Cleaner paths and better error reporting when a problem goes wrong
while binding an application.  This gets rid of the (recently added)
error about removing a process that hasn't been killed, and cleanly
kills the process along with more detailed errors about where things
failed.

Change-Id: I710a209c14da1515929e6254396b793177eee115
parent 58817f50
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1909,7 +1909,8 @@ public final class ActiveServices {
        }
    }

    boolean attachApplicationLocked(ProcessRecord proc, String processName) throws Exception {
    boolean attachApplicationLocked(ProcessRecord proc, String processName)
            throws RemoteException {
        boolean didSomething = false;
        // Collect any services that are waiting for this process to come up.
        if (mPendingServices.size() > 0) {
@@ -1929,7 +1930,7 @@ public final class ActiveServices {
                    realStartServiceLocked(sr, proc, sr.createdFromFg);
                    didSomething = true;
                }
            } catch (Exception e) {
            } catch (RemoteException e) {
                Slog.w(TAG, "Exception in new application when starting service "
                        + sr.shortName, e);
                throw e;
+8 −6
Original line number Diff line number Diff line
@@ -2617,7 +2617,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        int lrui = mLruProcesses.lastIndexOf(app);
        if (lrui >= 0) {
            if (!app.killed) {
                Slog.wtf(TAG, "Removing process that hasn't been killed: " + app);
                Slog.wtfStack(TAG, "Removing process that hasn't been killed: " + app);
                Process.killProcessQuiet(app.pid);
                Process.killProcessGroup(app.info.uid, app.pid);
            }
@@ -6114,7 +6114,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            // todo: Yikes!  What should we do?  For now we will try to
            // start another process, but that could easily get us in
            // an infinite loop of restarting processes...
            Slog.w(TAG, "Exception thrown during bind!", e);
            Slog.wtf(TAG, "Exception thrown during bind of " + app, e);
            app.resetPackageList(mProcessStats);
            app.unlinkDeathRecipient();
@@ -6138,6 +6138,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                    didSomething = true;
                }
            } catch (Exception e) {
                Slog.wtf(TAG, "Exception thrown launching activities in " + app, e);
                badApp = true;
            }
        }
@@ -6147,6 +6148,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            try {
                didSomething |= mServices.attachApplicationLocked(app, processName);
            } catch (Exception e) {
                Slog.wtf(TAG, "Exception thrown starting services in " + app, e);
                badApp = true;
            }
        }
@@ -6157,6 +6159,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                didSomething |= sendPendingBroadcastsLocked(app);
            } catch (Exception e) {
                // If the app died trying to launch the receiver we declare it 'bad'
                Slog.wtf(TAG, "Exception thrown dispatching broadcasts in " + app, e);
                badApp = true;
            }
        }
@@ -6170,14 +6173,13 @@ public final class ActivityManagerService extends ActivityManagerNative
                        compatibilityInfoForPackageLocked(mBackupTarget.appInfo),
                        mBackupTarget.backupMode);
            } catch (Exception e) {
                Slog.w(TAG, "Exception scheduling backup agent creation: ");
                e.printStackTrace();
                Slog.wtf(TAG, "Exception thrown creating backup agent in " + app, e);
                badApp = true;
            }
        }
        if (badApp) {
            // todo: Also need to kill application to deal with all
            // kinds of exceptions.
            app.kill("error during init", true);
            handleAppDiedLocked(app, false, true);
            return false;
        }
+2 −2
Original line number Diff line number Diff line
@@ -503,7 +503,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
        return resumedActivity;
    }

    boolean attachApplicationLocked(ProcessRecord app) throws Exception {
    boolean attachApplicationLocked(ProcessRecord app) throws RemoteException {
        final String processName = app.processName;
        boolean didSomething = false;
        for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
@@ -521,7 +521,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
                            if (realStartActivityLocked(hr, app, true, true)) {
                                didSomething = true;
                            }
                        } catch (Exception e) {
                        } catch (RemoteException e) {
                            Slog.w(TAG, "Exception in new application when starting activity "
                                  + hr.intent.getComponent().flattenToShortString(), e);
                            throw e;