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

Commit edf37479 authored by Hall Liu's avatar Hall Liu
Browse files

Fix race+logging issue in SystemStateHelper

SystemStateHelper wasn't locking when entering the onProjectionChanged
logic. This occasionally causes a race condition that takes out the
system server during CTS.

Bug: 181057509
Test: atest CtsTelecomTestCases
Change-Id: I1460f0a048ed0bee553944f99ee4d406c1a257ae
parent 2649674f
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ public class SystemStateHelper implements UiModeManager.OnProjectionStateChangeL
    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.startSession("SSP.oR");
            Log.startSession("SSH.oR");
            try {
                String action = intent.getAction();
                if (UiModeManager.ACTION_ENTER_CAR_MODE_PRIORITIZED.equals(action)) {
@@ -116,12 +116,20 @@ public class SystemStateHelper implements UiModeManager.OnProjectionStateChangeL
    @Override
    public void onProjectionStateChanged(int activeProjectionTypes,
            @NonNull Set<String> projectingPackages) {
        Log.startSession("SSH.oPSC");
        try {
            synchronized (mLock) {
                if (projectingPackages.isEmpty()) {
                    onReleaseAutomotiveProjection();
                } else {
                    onSetAutomotiveProjection(projectingPackages.iterator().next());
                }
            }
        } finally {
            Log.endSession();
        }

    }

    private Set<SystemStateListener> mListeners = new CopyOnWriteArraySet<>();
    private boolean mIsCarModeOrProjectionActive;