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

Commit 60d87624 authored by Dan Egnor's avatar Dan Egnor
Browse files

DropBox logging of app & system server crashes.

The crashes are also reported to the event log (and of course the
main logcat, like they always have been).  Ordinary Log.e(t,m,e) isn't dropboxed
but there's a new Log.wtf() which always is.  (Still @pending in this change.)

Add a hook to IPowerManager to crash the system server on demand
(only for apps with REBOOT permission, since it's basically a restart).
This is not exposed in PowerManager, must be invoked directly -- mostly
this is there so "Bad Behavior" in dev tools can do it.
parent 223bd7af
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -606,7 +606,7 @@ public class ActivityManager {
        public int uid;
        
        /**
         * The tag that was provided when the process crashed.
         * The activity name associated with the error, if known.  May be null.
         */
        public String tag;

+29 −4
Original line number Diff line number Diff line
@@ -979,13 +979,23 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case HANDLE_APPLICATION_ERROR_TRANSACTION: {
        case HANDLE_APPLICATION_CRASH_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder app = data.readStrongBinder();
            ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
            handleApplicationCrash(app, ci);
            reply.writeNoException();
            return true;
        }

        case HANDLE_APPLICATION_WTF_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder app = data.readStrongBinder();
            String tag = data.readString();
            ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
            handleApplicationError(app, tag, ci);
            boolean res = handleApplicationWtf(app, tag, ci);
            reply.writeNoException();
            reply.writeInt(res ? 1 : 0);
            return true;
        }

@@ -2337,7 +2347,20 @@ class ActivityManagerProxy implements IActivityManager
        /* this base class version is never called */
        return true;
    }
    public void handleApplicationError(IBinder app, String tag,
    public void handleApplicationCrash(IBinder app,
            ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(app);
        crashInfo.writeToParcel(data, 0);
        mRemote.transact(HANDLE_APPLICATION_CRASH_TRANSACTION, data, reply, 0);
        reply.readException();
        reply.recycle();
        data.recycle();
    }
    public boolean handleApplicationWtf(IBinder app, String tag,
            ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
    {
        Parcel data = Parcel.obtain();
@@ -2346,10 +2369,12 @@ class ActivityManagerProxy implements IActivityManager
        data.writeStrongBinder(app);
        data.writeString(tag);
        crashInfo.writeToParcel(data, 0);
        mRemote.transact(HANDLE_APPLICATION_ERROR_TRANSACTION, data, reply, 0);
        mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION, data, reply, 0);
        reply.readException();
        boolean res = reply.readInt() != 0;
        reply.recycle();
        data.recycle();
        return res;
    }

    public void signalPersistentProcesses(int sig) throws RemoteException {
+1 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ public class ApplicationErrorReport implements Parcelable {
            StringWriter sw = new StringWriter();
            tr.printStackTrace(new PrintWriter(sw));
            stackTrace = sw.toString();
            exceptionMessage = tr.getMessage();

            // Populate fields with the "root cause" exception
            while (tr.getCause() != null) {
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ interface IActivityController
     * it immediately.
     */
    boolean appCrashed(String processName, int pid,
            String tag, String shortMsg, String longMsg,
            String shortMsg, String longMsg,
            long timeMillis, String stackTrace);
    
    /**
+5 −3
Original line number Diff line number Diff line
@@ -242,8 +242,9 @@ public interface IActivityManager extends IInterface {
    // Special low-level communication with activity manager.
    public void startRunning(String pkg, String cls, String action,
            String data) throws RemoteException;

    public void handleApplicationError(IBinder app, String tag,
    public void handleApplicationCrash(IBinder app,
            ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException;
    public boolean handleApplicationWtf(IBinder app, String tag,
            ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException;
    
    /*
@@ -349,7 +350,7 @@ public interface IActivityManager extends IInterface {
    // Please keep these transaction codes the same -- they are also
    // sent by C++ code.
    int START_RUNNING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;
    int HANDLE_APPLICATION_ERROR_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+1;
    int HANDLE_APPLICATION_CRASH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+1;
    int START_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+2;
    int UNHANDLED_BACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+3;
    int OPEN_CONTENT_URI_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+4;
@@ -446,4 +447,5 @@ public interface IActivityManager extends IInterface {
    int KILL_APPLICATION_PROCESS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+98;
    int START_ACTIVITY_INTENT_SENDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+99;
    int OVERRIDE_PENDING_TRANSITION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+100;
    int HANDLE_APPLICATION_WTF_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+101;
}
Loading