Search in sources :

Example 1 with BarringServiceInfo

use of android.telephony.BarringInfo.BarringServiceInfo in project android_frameworks_opt_telephony by LineageOS.

the class BarringInfoTest method testBarringService.

/**
 * Test that barring service info is stored properly by the constructor
 */
@Test
public void testBarringService() {
    BarringInfo b = new BarringInfo(null, getBarringServiceInfos());
    // Check that the MO data barring info matches the info provided in getBarringServiceInfos()
    BarringServiceInfo bsi = b.getBarringServiceInfo(BarringInfo.BARRING_SERVICE_TYPE_MO_DATA);
    assertEquals(bsi.getBarringType(), BarringServiceInfo.BARRING_TYPE_UNCONDITIONAL);
    // Check that the MMTEL barring info matches the info provided in getBarringServiceInfos()
    bsi = b.getBarringServiceInfo(BarringInfo.BARRING_SERVICE_TYPE_MMTEL_VIDEO);
    assertEquals(bsi.getBarringType(), BarringServiceInfo.BARRING_TYPE_CONDITIONAL);
    assertFalse(bsi.isConditionallyBarred());
    assertEquals(bsi.getConditionalBarringFactor(), CONDITIONAL_BARRING_FACTOR_PERCENT);
    assertEquals(bsi.getConditionalBarringTimeSeconds(), CONDITIONAL_BARRING_TIME_SECONDS);
    // Because BarringInfo is available, services that aren't reported as barred are
    // automatically reported as unbarred.
    bsi = b.getBarringServiceInfo(BarringInfo.BARRING_SERVICE_TYPE_SMS);
    assertEquals(bsi.getBarringType(), BarringServiceInfo.BARRING_TYPE_NONE);
    assertFalse(bsi.isConditionallyBarred());
    assertEquals(bsi.getConditionalBarringFactor(), 0);
    assertEquals(bsi.getConditionalBarringTimeSeconds(), 0);
}
Also used : BarringServiceInfo(android.telephony.BarringInfo.BarringServiceInfo) BarringInfo(android.telephony.BarringInfo) Test(org.junit.Test)

Example 2 with BarringServiceInfo

use of android.telephony.BarringInfo.BarringServiceInfo in project android_frameworks_opt_telephony by LineageOS.

the class BarringInfoTest method testEmptyConstructor.

/**
 * Test that an empty constructor returns valid barring service info that's all not barred
 */
@Test
public void testEmptyConstructor() {
    BarringInfo b = new BarringInfo();
    for (int service : sServices) {
        BarringServiceInfo bsi = b.getBarringServiceInfo(service);
        assertNotNull(bsi);
        assertEquals(bsi.getBarringType(), BarringServiceInfo.BARRING_TYPE_UNKNOWN);
        assertFalse(bsi.isBarred());
    }
}
Also used : BarringServiceInfo(android.telephony.BarringInfo.BarringServiceInfo) BarringInfo(android.telephony.BarringInfo) Test(org.junit.Test)

Example 3 with BarringServiceInfo

use of android.telephony.BarringInfo.BarringServiceInfo in project android_frameworks_opt_telephony by LineageOS.

the class BarringInfoTest method getBarringServiceInfos.

/**
 * Return a dummy set of barring info
 *
 * @param isConditionallyBarred set the flag for whether the conditionally barred service has
 *        been evaluated and is actually barred based on the conditional barring parameters.
 */
private static SparseArray<BarringServiceInfo> getBarringServiceInfos(boolean isConditionallyBarred) {
    SparseArray<BarringServiceInfo> serviceInfos = new SparseArray<>();
    serviceInfos.put(BarringInfo.BARRING_SERVICE_TYPE_MO_DATA, new BarringServiceInfo(BarringServiceInfo.BARRING_TYPE_UNCONDITIONAL, false, 0, 0));
    serviceInfos.put(BarringInfo.BARRING_SERVICE_TYPE_MMTEL_VIDEO, new BarringServiceInfo(BarringServiceInfo.BARRING_TYPE_CONDITIONAL, isConditionallyBarred, CONDITIONAL_BARRING_FACTOR_PERCENT, CONDITIONAL_BARRING_TIME_SECONDS));
    return serviceInfos;
}
Also used : SparseArray(android.util.SparseArray) BarringServiceInfo(android.telephony.BarringInfo.BarringServiceInfo)

Aggregations

BarringServiceInfo (android.telephony.BarringInfo.BarringServiceInfo)3 BarringInfo (android.telephony.BarringInfo)2 Test (org.junit.Test)2 SparseArray (android.util.SparseArray)1