title: How to get the phone number and SIM card slot for the current device, on the callback of onCallAdded?
body: <h2>Background</h2>
  <p>I'm working on an app that implements <a href="https://developer.android.com/reference/android/telecom/InCallService" rel="nofollow noreferrer"><strong>InCallService</strong></a>, so it can handle phone calls</p>
  <h2>The problem</h2>
  <p>On devices with multi-SIM, I need to show information of which SIM and associated phone number is used (of the current device).</p>
  <p>Thing is, I can't find where to get this information.</p>
  <h2>What I've found</h2>
  <ol>
  <li><p>Given that I reach a function like <a href="https://developer.android.com/reference/android/telecom/InCallService#onCallAdded(android.telecom.Call)" rel="nofollow noreferrer"><strong>onCallAdded</strong></a>, I get an instance of <a href="https://developer.android.com/reference/android/telecom/Call" rel="nofollow noreferrer"><strong>Call</strong></a> class, so I need to associate something I get from there, to a sim slot and phone number.</p>
  </li>
  <li><p>Using <code>call.getDetails().getHandle()</code> , I can get a Uri consisting only the phone number of the other person that called (who called the current user, or who the current user has called).</p>
  </li>
  <li><p>I can iterate over all SIM cards, but can't find what I can use to map between them and the current call:</p>
  </li>
  </ol>
  <pre><code>final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
  for (final SubscriptionInfo subscriptionInfo : subscriptionManager.getActiveSubscriptionInfoList()) {
      final TelephonyManager subscriptionId = telephonyManager.createForSubscriptionId(subscriptionInfo.getSubscriptionId());
  }
  </code></pre>
  <ol start="4">
  <li><p>There was an old code that doesn't work anymore that uses <code>call.getDetails().getAccountHandle().getId()</code> and <code>SubscriptionManager.from(context)getActiveSubscriptionInfoList().getActiveSubscriptionInfoList()</code> .</p>
  </li>
  <li><p>I think I can use <code>telephonyManager.getSubscriptionId(callDetails.getAccountHandle())</code> , but it requires API 30, which is quite new...</p>
  </li>
  </ol>
  <h2>The questions</h2>
  <p>Given a phone call that I get from this callback (and probably others), how can I get the associated SIM slot and phone number of it?</p>
  <p>I prefer to know how to do it for as wide range of Android versions as possible, because InCallService is from API 23... It should be possible before API 30, right?</p>