Search in sources :

Example 1 with ImsMmTelManager

use of android.telephony.ims.ImsMmTelManager in project robolectric by robolectric.

the class ShadowImsMmTelManagerTest method createForSubscriptionId_multipleValidSubscriptionIds_sharesInstances.

@Test
@SuppressLint("NewApi")
public void createForSubscriptionId_multipleValidSubscriptionIds_sharesInstances() {
    ImsMmTelManager imsMmTelManager1 = ShadowImsMmTelManager.createForSubscriptionId(1);
    ImsMmTelManager imsMmTelManager2 = ShadowImsMmTelManager.createForSubscriptionId(2);
    assertThat(imsMmTelManager1).isNotEqualTo(imsMmTelManager2);
    assertThat(imsMmTelManager1).isEqualTo(ShadowImsMmTelManager.createForSubscriptionId(1));
    assertThat(imsMmTelManager2).isEqualTo(ShadowImsMmTelManager.createForSubscriptionId(2));
    ShadowImsMmTelManager.clearExistingInstances();
    assertThat(imsMmTelManager1).isNotEqualTo(ShadowImsMmTelManager.createForSubscriptionId(1));
    assertThat(imsMmTelManager2).isNotEqualTo(ShadowImsMmTelManager.createForSubscriptionId(2));
}
Also used : ImsMmTelManager(android.telephony.ims.ImsMmTelManager) Test(org.junit.Test) SuppressLint(android.annotation.SuppressLint)

Example 2 with ImsMmTelManager

use of android.telephony.ims.ImsMmTelManager in project android_packages_apps_Settings by omnirom.

the class ImsQueryController method isEnabledByPlatform.

@VisibleForTesting
boolean isEnabledByPlatform(int subId) throws InterruptedException, ImsException, IllegalArgumentException {
    if (!SubscriptionManager.isValidSubscriptionId(subId)) {
        return false;
    }
    final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(subId);
    // TODO: have a shared thread pool instead of create ExecutorService
    // everytime to improve performance.
    final ExecutorService executor = Executors.newSingleThreadExecutor();
    final BooleanConsumer booleanResult = new BooleanConsumer();
    imsMmTelManager.isSupported(mCapability, mTransportType, executor, booleanResult);
    // or timeout after TIMEOUT_MILLIS milliseconds
    return booleanResult.get(TIMEOUT_MILLIS);
}
Also used : ImsMmTelManager(android.telephony.ims.ImsMmTelManager) ExecutorService(java.util.concurrent.ExecutorService) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 3 with ImsMmTelManager

use of android.telephony.ims.ImsMmTelManager in project robolectric by robolectric.

the class ShadowImsMmTelManager method createForSubscriptionId.

/**
 * Returns only one instance per subscription id.
 */
@RequiresApi(api = VERSION_CODES.Q)
@Implementation
protected static ImsMmTelManager createForSubscriptionId(int subId) {
    if (!SubscriptionManager.isValidSubscriptionId(subId)) {
        throw new IllegalArgumentException("Invalid subscription ID");
    }
    if (existingInstances.containsKey(subId)) {
        return existingInstances.get(subId);
    }
    ImsMmTelManager imsMmTelManager = reflector(ImsMmTelManagerReflector.class).createForSubscriptionId(subId);
    existingInstances.put(subId, imsMmTelManager);
    return imsMmTelManager;
}
Also used : ImsMmTelManager(android.telephony.ims.ImsMmTelManager) RequiresApi(androidx.annotation.RequiresApi) Implementation(org.robolectric.annotation.Implementation)

Example 4 with ImsMmTelManager

use of android.telephony.ims.ImsMmTelManager in project android_packages_apps_Settings by omnirom.

the class SimStatusDialogController method registerImsRegistrationCallback.

private void registerImsRegistrationCallback(int subId) {
    if (!isImsRegistrationStateShowUp()) {
        return;
    }
    try {
        final ImsMmTelManager imsMmTelMgr = ImsMmTelManager.createForSubscriptionId(subId);
        imsMmTelMgr.registerImsRegistrationCallback(mDialog.getContext().getMainExecutor(), mImsRegStateCallback);
    } catch (ImsException exception) {
        Log.w(TAG, "fail to register IMS status for subId=" + subId, exception);
    }
}
Also used : ImsMmTelManager(android.telephony.ims.ImsMmTelManager) ImsException(android.telephony.ims.ImsException)

Example 5 with ImsMmTelManager

use of android.telephony.ims.ImsMmTelManager in project android_packages_apps_Settings by omnirom.

the class SimStatusDialogController method unregisterImsRegistrationCallback.

private void unregisterImsRegistrationCallback(int subId) {
    if (!isImsRegistrationStateShowUp()) {
        return;
    }
    final ImsMmTelManager imsMmTelMgr = ImsMmTelManager.createForSubscriptionId(subId);
    imsMmTelMgr.unregisterImsRegistrationCallback(mImsRegStateCallback);
}
Also used : ImsMmTelManager(android.telephony.ims.ImsMmTelManager)

Aggregations

ImsMmTelManager (android.telephony.ims.ImsMmTelManager)9 VisibleForTesting (androidx.annotation.VisibleForTesting)2 WifiCallingQueryImsState (com.android.settings.network.ims.WifiCallingQueryImsState)2 ExecutorService (java.util.concurrent.ExecutorService)2 SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 ImsException (android.telephony.ims.ImsException)1 RequiresApi (androidx.annotation.RequiresApi)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Test (org.junit.Test)1 Implementation (org.robolectric.annotation.Implementation)1