Tabnine Logo
TelecomManager
Code IndexAdd Tabnine to your IDE (free)

How to use
TelecomManager
in
android.telecom

Best Java code snippets using android.telecom.TelecomManager (Showing top 20 results out of 315)

origin: robolectric/robolectric

private boolean isPackageDefaultDialer(String packageName) {
 TelecomManager telecomManager =
   (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
 return packageName.equals(telecomManager.getDefaultDialerPackage());
}
origin: robolectric/robolectric

@Test
@Config(minSdk = M)
public void getCallCapablePhoneAccounts() {
 PhoneAccountHandle callCapableHandle = createHandle("id1");
 telecomService.registerPhoneAccount(PhoneAccount.builder(callCapableHandle, "enabled")
   .setIsEnabled(true)
   .build());
 PhoneAccountHandle notCallCapableHandler = createHandle("id2");
 telecomService.registerPhoneAccount(PhoneAccount.builder(notCallCapableHandler, "disabled")
   .setIsEnabled(false)
   .build());
 List<PhoneAccountHandle> callCapablePhoneAccounts = telecomService.getCallCapablePhoneAccounts();
 assertThat(callCapablePhoneAccounts).contains(callCapableHandle);
 assertThat(callCapablePhoneAccounts).doesNotContain(notCallCapableHandler);
}
origin: robolectric/robolectric

@Test
public void registerAndUnRegister() {
 assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(0);
 assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(0);
 PhoneAccountHandle handler = createHandle("id");
 PhoneAccount phoneAccount = PhoneAccount.builder(handler, "main_account").build();
 telecomService.registerPhoneAccount(phoneAccount);
 assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(1);
 assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(1);
 assertThat(telecomService.getAllPhoneAccountHandles()).hasSize(1);
 assertThat(telecomService.getAllPhoneAccountHandles()).contains(handler);
 assertThat(telecomService.getPhoneAccount(handler).getLabel()).isEqualTo(phoneAccount.getLabel());
 telecomService.unregisterPhoneAccount(handler);
 assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(0);
 assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(0);
 assertThat(telecomService.getAllPhoneAccountHandles()).hasSize(0);
}
origin: robolectric/robolectric

@Test
@Config(minSdk = LOLLIPOP_MR1)
public void clearAccountsForPackage() {
 PhoneAccountHandle accountHandle1 = createHandle("a.package", "id1");
 telecomService.registerPhoneAccount(PhoneAccount.builder(accountHandle1, "another_package")
   .build());
 PhoneAccountHandle accountHandle2 = createHandle("some.other.package", "id2");
 telecomService.registerPhoneAccount(PhoneAccount.builder(accountHandle2, "another_package")
   .build());
 telecomService.clearAccountsForPackage(accountHandle1.getComponentName().getPackageName());
 assertThat(telecomService.getPhoneAccount(accountHandle1)).isNull();
 assertThat(telecomService.getPhoneAccount(accountHandle2)).isNotNull();
}
origin: robolectric/robolectric

@Test
public void testIsRinging_incomingCallAdded_thenRingerSilenced_shouldBeFalse() {
 telecomService.addNewIncomingCall(createHandle("id"), null);
 telecomService.silenceRinger();
 assertThat(shadowOf(telecomService).isRinging()).isFalse();
}
origin: geniusgithub/AndroidDialer

  /**
   * Determines if one of the call capable phone accounts defined supports calling with a subject
   * specified.
   *
   * @param context The context.
   * @return {@code true} if one of the call capable phone accounts supports calling with a
   *      subject specified, {@code false} otherwise.
   */
  public static boolean isCallWithSubjectSupported(Context context) {
    if (!PermissionsUtil.hasPermission(context, android.Manifest.permission.READ_PHONE_STATE)
        || !CompatUtils.isCallSubjectCompatible()) {
      return false;
    }
    TelecomManager telecommMgr = (TelecomManager)
        context.getSystemService(Context.TELECOM_SERVICE);
    if (telecommMgr == null) {
      return false;
    }

    List<PhoneAccountHandle> accountHandles = telecommMgr.getCallCapablePhoneAccounts();
    for (PhoneAccountHandle accountHandle : accountHandles) {
      PhoneAccount account = telecommMgr.getPhoneAccount(accountHandle);
      if (account != null && account.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT)) {
        return true;
      }
    }
    return false;
  }
}
origin: robolectric/robolectric

@Test
public void testIsRinging_ringerSilenced_thenUnknownCallAdded_shouldBeTrue() {
 telecomService.silenceRinger();
 shadowOf(telecomService).addNewUnknownCall(createHandle("id"), null);
 assertThat(shadowOf(telecomService).isRinging()).isTrue();
}
origin: robolectric/robolectric

@Test
public void isInCall_setIsInCallNotCalled_shouldReturnFalse() throws Exception {
 assertThat(telecomService.isInCall()).isFalse();
}
origin: geniusgithub/AndroidDialer

/**
 * Return the {@link PhoneAccount} for a specified {@link PhoneAccountHandle}. Object includes
 * resources which can be used in a user interface.
 *
 * @param telecomManager the {@link TelecomManager} used for method calls, if possible.
 * @param account The {@link PhoneAccountHandle}.
 * @return The {@link PhoneAccount} object or null if it doesn't exist.
 */
@Nullable
public static PhoneAccount getPhoneAccount(@Nullable TelecomManager telecomManager,
    @Nullable PhoneAccountHandle accountHandle) {
  if (telecomManager != null && (CompatUtils.isMethodAvailable(
      TELECOM_MANAGER_CLASS, "getPhoneAccount", PhoneAccountHandle.class))) {
    return telecomManager.getPhoneAccount(accountHandle);
  }
  return null;
}
origin: geniusgithub/AndroidDialer

/**
 * Returns a list of {@link PhoneAccountHandle}s which can be used to make and receive phone
 * calls. The returned list includes only those accounts which have been explicitly enabled
 * by the user.
 *
 * @param telecomManager the {@link TelecomManager} used for method calls, if possible.
 * @return A list of PhoneAccountHandle objects.
 */
public static List<PhoneAccountHandle> getCallCapablePhoneAccounts(
    @Nullable TelecomManager telecomManager) {
  if (telecomManager != null && (CompatUtils.isMarshmallowCompatible()
      || CompatUtils.isMethodAvailable(TELECOM_MANAGER_CLASS,
          "getCallCapablePhoneAccounts"))) {
    return telecomManager.getCallCapablePhoneAccounts();
  }
  return new ArrayList<>();
}
origin: robolectric/robolectric

@Test
public void testAddNewIncomingCall() {
 telecomService.addNewIncomingCall(createHandle("id"), null);
 assertThat(shadowOf(telecomService).getAllIncomingCalls()).hasSize(1);
}
origin: robolectric/robolectric

@Test
public void testAddUnknownCall() {
 telecomService.addNewUnknownCall(createHandle("id"), null);
 assertThat(shadowOf(telecomService).getAllUnknownCalls()).hasSize(1);
}
origin: geniusgithub/AndroidDialer

List<PhoneAccountHandle> accountHandles = telecommMgr.getCallCapablePhoneAccounts();
for (PhoneAccountHandle accountHandle : accountHandles) {
  PhoneAccount account = telecommMgr.getPhoneAccount(accountHandle);
  if (account != null) {
    if (account.hasCapabilities(PhoneAccount.CAPABILITY_VIDEO_CALLING)) {
origin: robolectric/robolectric

@Test
public void testIsRinging_ringerSilenced_thenIncomingCallAdded_shouldBeTrue() {
 telecomService.silenceRinger();
 telecomService.addNewIncomingCall(createHandle("id"), null);
 assertThat(shadowOf(telecomService).isRinging()).isTrue();
}
origin: robolectric/robolectric

@Test
public void testIsRinging_unknownCallAdded_thenRingerSilenced_shouldBeFalse() {
 shadowOf(telecomService).addNewUnknownCall(createHandle("id"), null);
 telecomService.silenceRinger();
 assertThat(shadowOf(telecomService).isRinging()).isFalse();
}
origin: robolectric/robolectric

@Test
public void canSetAndGetIsInCall() throws Exception {
 shadowOf(telecomService).setIsInCall(true);
 assertThat(telecomService.isInCall()).isTrue();
}
origin: geniusgithub/AndroidDialer

final PhoneAccount account = telecomManager.getPhoneAccount(mPhoneAccountHandle);
origin: robolectric/robolectric

@Test
public void testIsRinging_incomingCallAdded_shouldBeTrue() {
 telecomService.addNewIncomingCall(createHandle("id"), null);
 assertThat(shadowOf(telecomService).isRinging()).isTrue();
}
origin: robolectric/robolectric

@Test
@Config(minSdk = M)
public void setDefaultDialerPackage() {
 shadowOf(telecomService).setDefaultDialer("some.package");
 assertThat(telecomService.getDefaultDialerPackage()).isEqualTo("some.package");
}
origin: geniusgithub/AndroidDialer

/**
 * Silences the ringer if a ringing call exists. Noop if {@link TelecomManager#silenceRinger()}
 * is unavailable.
 *
 * @param telecomManager the TelecomManager to use to silence the ringer.
 */
public static void silenceRinger(@Nullable TelecomManager telecomManager) {
  if (telecomManager != null && (CompatUtils.isMarshmallowCompatible() || CompatUtils
      .isMethodAvailable(TELECOM_MANAGER_CLASS, "silenceRinger"))) {
    telecomManager.silenceRinger();
  }
}
android.telecomTelecomManager

Most used methods

  • getDefaultDialerPackage
  • getCallCapablePhoneAccounts
  • getPhoneAccount
  • isInCall
  • silenceRinger
  • addNewIncomingCall
  • addNewUnknownCall
  • cancelMissedCallsNotification
  • clearAccountsForPackage
  • createManageBlockedNumbersIntent
  • getAdnUriForPhoneAccount
  • getAllPhoneAccountHandles
  • getAdnUriForPhoneAccount,
  • getAllPhoneAccountHandles,
  • getConnectionManager,
  • getDefaultOutgoingPhoneAccount,
  • getLine1Number,
  • getPhoneAccountsForPackage,
  • getPhoneAccountsSupportingScheme,
  • getSimCallManager,
  • getVoiceMailNumber,
  • handleMmi

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSystemService (Context)
  • onRequestPermissionsResult (Fragment)
  • putExtra (Intent)
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now