Merge "Fix NPE in Binder#getTransactionName"

This commit is contained in:
Marcin Oczeretko
2022-01-18 19:12:40 +00:00
committed by Android (Google) Code Review

View File

@@ -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;
}
/**