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

Commit e269a5ac authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by Android (Google) Code Review
Browse files

Merge "Fix reading exception from Parcel" into pi-dev

parents 657f173a 2214b828
Loading
Loading
Loading
Loading
+21 −21
Original line number Diff line number Diff line
@@ -1857,26 +1857,7 @@ public final class Parcel {
        int code = readExceptionCode();
        if (code != 0) {
            String msg = readString();
            String remoteStackTrace = null;
            final int remoteStackPayloadSize = readInt();
            if (remoteStackPayloadSize > 0) {
                remoteStackTrace = readString();
            }
            Exception e = createException(code, msg);
            // Attach remote stack trace if availalble
            if (remoteStackTrace != null) {
                RemoteException cause = new RemoteException(
                        "Remote stack trace:\n" + remoteStackTrace, null, false, false);
                try {
                    Throwable rootCause = ExceptionUtils.getRootCause(e);
                    if (rootCause != null) {
                        rootCause.initCause(cause);
                    }
                } catch (RuntimeException ex) {
                    Log.e(TAG, "Cannot set cause " + cause + " for " + e, ex);
                }
            }
            SneakyThrow.sneakyThrow(e);
            readException(code, msg);
        }
    }

@@ -1921,7 +1902,26 @@ public final class Parcel {
     * @param msg The exception message.
     */
    public final void readException(int code, String msg) {
        SneakyThrow.sneakyThrow(createException(code, msg));
        String remoteStackTrace = null;
        final int remoteStackPayloadSize = readInt();
        if (remoteStackPayloadSize > 0) {
            remoteStackTrace = readString();
        }
        Exception e = createException(code, msg);
        // Attach remote stack trace if availalble
        if (remoteStackTrace != null) {
            RemoteException cause = new RemoteException(
                    "Remote stack trace:\n" + remoteStackTrace, null, false, false);
            try {
                Throwable rootCause = ExceptionUtils.getRootCause(e);
                if (rootCause != null) {
                    rootCause.initCause(cause);
                }
            } catch (RuntimeException ex) {
                Log.e(TAG, "Cannot set cause " + cause + " for " + e, ex);
            }
        }
        SneakyThrow.sneakyThrow(e);
    }

    /**