The mystery of how Microsoft Teams broke 911 emergency dialing on Android phones is now clear. Esper’s Senior Technical Editor Mishaal Rahman has taken to Medium with a detailed, blow-by-blow account of how the interaction between Teams and Android manages to break one of the most critical things a phone can do.

If you missed it, last week, a Pixel owner took to Reddit to describe an actual nightmare: While their grandmother appeared to be having a stroke, attempts to dial 911 on a Pixel 3 failed. The phone was "stuck," preventing them from hanging up to dial again, and later recreations revealed the call may never have been connected, even though the phone reported sending the customer's location to emergency services. Thankfully, a landline was also available, and a second (successful) 911 call was placed.

Days later, Google revealed that an "unintended interaction" between Android and the Microsoft Teams app was to blame for the issue, affecting some customers who had the app installed but were not signed in. Customers were warned to uninstall and reinstall the app to mitigate the problem if they met those criteria in the meantime, and fixes from both Microsoft and Google were planned. Now, based on a detailed understanding of what went wrong, we know how these fixes will likely manifest at a code level. Working together with @linuxct, @Za_Raczke, Kieron Quinn, Luca Stefani, Matheus Kiser, and James Woglom, Rahman worked out the technical details behind the issues.

Essentially, phone apps on Android have to tell the system that they're able to make and place calls — on top of that, it has to tell the system that it can handle emergency calls. That ensures call functionality works correctly (and there are a few ways that apps can handle that). Unfortunately, when you actually try to place an emergency call, the system logic can break because of two separate issues.

When Android makes its list of things that can place emergency calls, it pulls from the list that can make any call, not just emergency ones. So Microsoft Teams app ends up being in consideration for emergency calls when it shouldn't be.

By itself, that actually isn't an issue, though. The subsequent logic in Android should always choose other options over it anyway; Teams can't place emergency calls, and the logic takes that into account even if the initial list-making doesn't. But there's another bug that can come up: If too many things are registered to place emergency calls, the logic that governs what is chosen can run into an integer overflow or underflow issue, breaking the sorting and somehow causing the emergency call to fail/lock up. (The precise mechanism here isn't certain because it bleeds over into other systems that are harder to analyze, but overflows can be messy and break things in unanticipated ways.)

The odds of that last bug being triggered are really low. Microsoft Teams would have to be registering itself on that list a ridiculous number of times to make it likely (and even then, it's not guaranteed, just a chance it will be triggered). Except, that's exactly what's happening. Whenever the Microsoft Teams app starts or your phone reboots and you aren't signed in, Teams registers itself onto this list again. (If you're signed in, that registration happens once — the logic behind that has to do with the app spinning up new unique identifiers if you aren't.)

Microsoft Teams can end up adding itself to this list so many times this low-percentage-chance issue becomes way more likely, increasing the odds that an emergency call might fail.

All of this still might sound like a corner case, but it actually isn't. If you're forcibly logged out due to something like an enterprise security policy or a bug with the app, this whole series of issues can be triggered. Samsung also spotted the problem four days before the original customer report that started this whole news cycle, submitting a fix for it on Android's end.

Since part of this issue ultimately resides in Android's telephony functionality, and since that isn't updatable as a mainline module, a fix for the problem on Google's end won't land until January 4th (presumably the date the January 2022 patches will land). Microsoft also said it would update Teams to reduce the odds that bug gets triggered, and that has started rolling out.

There are some other curious details in the full report, like the fact that this issue should only crop up on Android 10 and later. If you're curious as to why and have the technical chops to grok it (as many developers likely do), give the full report a glance — It's pretty fascinating.