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

Commit e8d0137a authored by Rambo Wang's avatar Rambo Wang
Browse files

ServiceStateTracker: remove synchronization from mSignalRequestRecords

With all access pathes of mSignalRequestRecords in the same thread now,
the synchronization with lock hold on itself can be removed. This
will bring better readability and performance.

Bug: 179077640
Test: atest com.android.internal.telephony.ServiceStateTrackerTest
Test: Manual feature test
Change-Id: Ice391f48c16e3233fb1628093e469345a900bf5a
parent c60a4447
Loading
Loading
Loading
Loading
+20 −28
Original line number Diff line number Diff line
@@ -651,7 +651,6 @@ public class ServiceStateTracker extends Handler {
    private final Object mLteRsrpBoostLock = new Object();
    private static final int INVALID_LTE_EARFCN = -1;

    // @GuardedBy("mSignalRequestRecords")
    private final List<SignalRequestRecord> mSignalRequestRecords = new ArrayList<>();

    public ServiceStateTracker(GsmCdmaPhone phone, CommandsInterface ci) {
@@ -1790,10 +1789,7 @@ public class ServiceStateTracker extends Handler {
                    break;
                }

                synchronized (mSignalRequestRecords) {
                mSignalRequestRecords.add(record);
                }

                updateAlwaysReportSignalStrength();
                updateReportingCriteria(getCarrierConfig());

@@ -1807,7 +1803,6 @@ public class ServiceStateTracker extends Handler {
                SignalRequestRecord record = pair.first;
                Message onCompleted = pair.second;

                synchronized (mSignalRequestRecords) {
                // for loop with removal may cause ConcurrentModificationException
                Iterator<SignalRequestRecord> it = mSignalRequestRecords.iterator();
                while (it.hasNext()) {
@@ -1816,7 +1811,6 @@ public class ServiceStateTracker extends Handler {
                        it.remove();
                    }
                }
                }

                updateAlwaysReportSignalStrength();
                updateReportingCriteria(getCarrierConfig());
@@ -6083,7 +6077,6 @@ public class ServiceStateTracker extends Handler {

        final boolean isDeviceIdle = mPhone.isDeviceIdle();
        final int curSubId = mPhone.getSubId();
        synchronized (mSignalRequestRecords) {
        // The total number of record is small (10~15 tops). With each request has at most 5
        // SignalThresholdInfo which has at most 8 thresholds arrays. So the nested loop should
        // not be a concern here.
@@ -6101,7 +6094,6 @@ public class ServiceStateTracker extends Handler {
                }
            }
        }
        }

        int[] targetArray = new int[target.size()];
        int i = 0;