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

Commit 5027df06 authored by Jayachandran C's avatar Jayachandran C Committed by Steve Statia
Browse files

Trigger notifyOpportunisticSubscriptionInfoChanged upon group disabled flag...

Trigger notifyOpportunisticSubscriptionInfoChanged upon group disabled flag for opportunistic subscription

There is a bug where groupDisabled flag maintained at cache was updated
but the callers were never notified using Telephony callback. This fix
trigger the callback when there is a change in the groupDisabled flag.

Bug: 305286720
Test: TBD
Change-Id: I4c5921048772cec42f4ed6c7f957ba9197d91a6f
parent a92dca74
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -2062,7 +2062,7 @@ public class SubscriptionDatabaseManager extends Handler {
     */
    public void setGroupDisabled(int subId, boolean isGroupDisabled) {
        // group disabled does not have a corresponding SimInfo column. So we only update the cache.

        boolean isChanged = false;
        // Grab the write lock so no other threads can read or write the cache.
        mReadWriteLock.writeLock().lock();
        try {
@@ -2071,12 +2071,18 @@ public class SubscriptionDatabaseManager extends Handler {
                throw new IllegalArgumentException("setGroupDisabled: Subscription doesn't exist. "
                        + "subId=" + subId);
            }
            isChanged = subInfoCache.isGroupDisabled() != isGroupDisabled;
            mAllSubscriptionInfoInternalCache.put(subId,
                    new SubscriptionInfoInternal.Builder(subInfoCache)
                            .setGroupDisabled(isGroupDisabled).build());
        } finally {
            mReadWriteLock.writeLock().unlock();
        }

        if (isChanged) {
            log("setGroupDisabled value changed, firing the callback");
            mCallback.invokeFromExecutor(() -> mCallback.onSubscriptionChanged(subId));
        }
    }

    /**
+30 −0
Original line number Diff line number Diff line
@@ -2017,6 +2017,36 @@ public class SubscriptionDatabaseManagerTest extends TelephonyTest {
                .isEqualTo(FAKE_SATELLITE_IS_NTN_DISABLED);
    }

    @Test
    public void testSetGroupDisabled() throws Exception {
        assertThrows(IllegalArgumentException.class,
                () -> mDatabaseManagerUT.setGroupDisabled(
                        FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(), true));

        insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
        mDatabaseManagerUT.setGroupDisabled(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(), true);
        processAllMessages();

        assertThat(mDatabaseManagerUT.getSubscriptionInfoInternal(
            FAKE_SUBSCRIPTION_INFO1.getSubscriptionId()).isGroupDisabled()).isTrue();

        verify(mSubscriptionDatabaseManagerCallback, times(2)).onSubscriptionChanged(eq(1));
        Mockito.clearInvocations(mSubscriptionDatabaseManagerCallback);

        mDatabaseManagerUT.setGroupDisabled(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(), true);
        processAllMessages();
        verify(mSubscriptionDatabaseManagerCallback, never()).onSubscriptionChanged(eq(1));

        assertThat(mDatabaseManagerUT.getSubscriptionInfoInternal(
            FAKE_SUBSCRIPTION_INFO1.getSubscriptionId()).isGroupDisabled()).isTrue();

        mDatabaseManagerUT.setGroupDisabled(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(), false);
        processAllMessages();
        verify(mSubscriptionDatabaseManagerCallback, times(1)).onSubscriptionChanged(eq(1));
        assertThat(mDatabaseManagerUT.getSubscriptionInfoInternal(
                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId()).isGroupDisabled()).isFalse();
    }

    @Test
    public void testUpdateSatelliteNtnWithFeatureDisabled() throws Exception {
        assertThrows(IllegalArgumentException.class,