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

Commit 3d86b88f authored by louis_chang's avatar louis_chang
Browse files

[ActivityManager] Avoid NullPointerException if no

crash info

Symptom:
This issue happens because the ANR process got killed
(because it crashed) before the ANR dialog dismissed.
In that case, the process record is marked as crashed
(ProcessRecord.crashing = true). When the ANR dialog
dismissed by user, it will cause NullPointerException
when writeToParcel while performing IPC because there
is no crash info (ApplicationErrorReport.crashInfo = null)

Solution:
Check crashinfo before access it

Change-Id: I2995de57684c1e13aab8297f5eea1e82ca3b7ad8
parent 80e455e3
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -235,10 +235,13 @@ public class ApplicationErrorReport implements Parcelable {
        dest.writeString(processName);
        dest.writeString(processName);
        dest.writeLong(time);
        dest.writeLong(time);
        dest.writeInt(systemApp ? 1 : 0);
        dest.writeInt(systemApp ? 1 : 0);
        dest.writeInt(crashInfo != null ? 1 : 0);


        switch (type) {
        switch (type) {
            case TYPE_CRASH:
            case TYPE_CRASH:
                if (crashInfo != null) {
                    crashInfo.writeToParcel(dest, flags);
                    crashInfo.writeToParcel(dest, flags);
                }
                break;
                break;
            case TYPE_ANR:
            case TYPE_ANR:
                anrInfo.writeToParcel(dest, flags);
                anrInfo.writeToParcel(dest, flags);
@@ -259,10 +262,11 @@ public class ApplicationErrorReport implements Parcelable {
        processName = in.readString();
        processName = in.readString();
        time = in.readLong();
        time = in.readLong();
        systemApp = in.readInt() == 1;
        systemApp = in.readInt() == 1;
        boolean hasCrashInfo = in.readInt() == 1;


        switch (type) {
        switch (type) {
            case TYPE_CRASH:
            case TYPE_CRASH:
                crashInfo = new CrashInfo(in);
                crashInfo = hasCrashInfo ? new CrashInfo(in) : null;
                anrInfo = null;
                anrInfo = null;
                batteryInfo = null;
                batteryInfo = null;
                runningServiceInfo = null;
                runningServiceInfo = null;