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

Commit ad4ff82c authored by Yifei Zhang's avatar Yifei Zhang
Browse files

surfacecontrol: mark mCalls Nullable & fix missing null checks

- Check for null properly for debug function to prevent runtime restarts
- NPE can occur when sLogAllTxCallsOnApply is reset. In operations
  involving two transactions (e.g. merge), we only check null for mCalls
  but not other.mCalls. This commit fixes this case.

Test: manual
Bug: 266978825
Flag: EXEMPT, bug fix
Change-Id: I5c480a410cf91b04c44deb00b12eb169216f899e
parent 291ac766
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -3026,6 +3026,7 @@ public final class SurfaceControl implements Parcelable {
        // Only non-null if the SurfaceControlRegistry is enabled. This list tracks the set of calls
        // made through this transaction object, and is dumped (and cleared) when the transaction is
        // later applied.
        @Nullable
        ArrayList<String> mCalls;

        Runnable mFreeNativeResources;
@@ -4898,10 +4899,12 @@ public final class SurfaceControl implements Parcelable {
                SurfaceControlRegistry.getProcessInstance().checkCallStackDebugging(
                        "merge", this, null, "otherTx=" + other.getId());
                if (mCalls != null) {
                    if (other.mCalls != null) {
                        mCalls.addAll(other.mCalls);
                        other.mCalls.clear();
                    }
                }
            }
            mResizedSurfaces.putAll(other.mResizedSurfaces);
            other.mResizedSurfaces.clear();
            mReparentedSurfaces.putAll(other.mReparentedSurfaces);
+7 −3
Original line number Diff line number Diff line
@@ -334,14 +334,18 @@ public class SurfaceControlRegistry {
            if (call == APPLY) {
                // Log the apply and dump the calls on that transaction
                Log.e(TAG, msg, new Throwable());
                if (tx.mCalls != null) {
                    for (int i = 0; i < tx.mCalls.size(); i++) {
                        Log.d(TAG, "        " + tx.mCalls.get(i));
                    }
                }
            } else if (matchesForCallStackDebugging(sc != null ? sc.getName() : null, call)) {
                // Otherwise log this call to the transaction if it matches the tracked calls
                Log.e(TAG, msg, new Throwable());
                if (tx.mCalls != null) {
                    tx.mCalls.add(msg);
                }
            }
        } else {
            // Log this call if it matches the tracked calls
            if (!matchesForCallStackDebugging(sc != null ? sc.getName() : null, call)) {