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

Commit dfc3d4f4 authored by Jack Yu's avatar Jack Yu
Browse files

Fixed internal service state exposed to clients

This is another fix on top of aosp/1807858. Since service state
is not a immutable object, the instance notified to the client
should be a new copy, otherwise the exposed one can get modified
when SST internally modifies it.

Fix: 174306612
Test: Manual
Merged-In: I08311c01a841fee70f82a0a1809a8e13829447ce
Change-Id: I08311c01a841fee70f82a0a1809a8e13829447ce
(cherry picked from commit 91af5cac)
parent 28c37928
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1722,7 +1722,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * version scoped to their packages
     */
    protected void notifyServiceStateChangedP(ServiceState ss) {
        AsyncResult ar = new AsyncResult(null, ss, null);
        AsyncResult ar = new AsyncResult(null, new ServiceState(ss), null);
        mServiceStateRegistrants.notifyRegistrants(ar);

        mNotifier.notifyServiceState(this);
+3 −8
Original line number Diff line number Diff line
@@ -439,7 +439,7 @@ public class ServiceStateTracker extends Handler {
                // just went from invalid to valid subId, so notify with current service
                // state in case our service state was never broadcasted (we don't notify
                // service states when the subId is invalid)
                mPhone.notifyServiceStateChanged(mSS);
                mPhone.notifyServiceStateChanged(mPhone.getServiceState());
            }

            boolean restoreSelection = !context.getResources().getBoolean(
@@ -1731,7 +1731,7 @@ public class ServiceStateTracker extends Handler {
                    mPhone.notifyPhysicalChannelConfig(list);
                    // Notify NR frequency, NR connection status or bandwidths changed.
                    if (hasChanged) {
                        mPhone.notifyServiceStateChanged(mSS);
                        mPhone.notifyServiceStateChanged(mPhone.getServiceState());
                        TelephonyMetrics.getInstance().writeServiceStateChanged(
                                mPhone.getPhoneId(), mSS);
                        mPhone.getVoiceCallSessionStats().onServiceStateChanged(mSS);
@@ -3679,12 +3679,7 @@ public class ServiceStateTracker extends Handler {
        }

        ServiceState oldMergedSS = new ServiceState(mPhone.getServiceState());

        // swap mSS and mNewSS to put new state in mSS
        ServiceState tss = mSS;
        mSS = mNewSS;
        mNewSS = tss;
        // clean slate for next time
        mSS = new ServiceState(mNewSS);
        mNewSS.setStateOutOfService();

        mCellIdentity = primaryCellIdentity;
+1 −1
Original line number Diff line number Diff line
@@ -2360,7 +2360,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
                ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION,
                new AsyncResult(sst.mPollingContext, voiceResult, null)));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
        assertTrue(Arrays.equals(new int[0], sst.mSS.getCellBandwidths()));
        assertEquals(0, sst.mSS.getCellBandwidths().length);
    }

    @Test