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

Commit 28d940e3 authored by Marcin Oczeretko's avatar Marcin Oczeretko
Browse files

Fix NPE in Binder#getTransactionName

Bug: 214053959
Test: manual

Change-Id: Ie77080d20f638e5e6e0a6ecb255d45bdb12f3c4d
parent 702c8991
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -311,6 +311,7 @@ public class Binder implements IBinder {
    private final long mObject;

    private IInterface mOwner;
    @Nullable
    private String mDescriptor;
    private volatile String[] mTransactionTraceNames = null;
    private volatile String mSimpleDescriptor = null;
@@ -930,8 +931,8 @@ public class Binder implements IBinder {
                transactionNames[i] = buf.toString();
                buf.setLength(0);
            }
            mTransactionTraceNames = transactionNames;
            mSimpleDescriptor = descriptor;
            mTransactionTraceNames = transactionNames;
        }
        final int index = transactionCode - FIRST_CALL_TRANSACTION;
        if (index < 0 || index >= mTransactionTraceNames.length) {
@@ -940,13 +941,19 @@ public class Binder implements IBinder {
        return mTransactionTraceNames[index];
    }

    private String getSimpleDescriptor() {
        final int dot = mDescriptor.lastIndexOf(".");
    private @NonNull String getSimpleDescriptor() {
        String descriptor = mDescriptor;
        if (descriptor == null) {
            // Just "Binder" to avoid null checks in transaction name tracing.
            return "Binder";
        }

        final int dot = descriptor.lastIndexOf(".");
        if (dot > 0) {
            // Strip the package name
            return mDescriptor.substring(dot + 1);
            return descriptor.substring(dot + 1);
        }
        return mDescriptor;
        return descriptor;
    }

    /**