The App That Kept Registering Itself — Java Bug Hunt

Modelled on the Microsoft Teams / Android emergency-call issue of January 2022.

  • Language: Java
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Idempotency, State
  • Modelled on: Microsoft Teams · 2022
  • Visible tests: the SIM handles emergency calls on a fresh registry; re-registering on every launch keeps one entry
  • Reward: 50 XP for a complete fix

Briefing

Modelled on the Microsoft Teams / Android emergency-call issue of January 2022. Google and Microsoft reported that on some Android phones with the Teams app installed but not signed in, certain 911 calls could fail. Teams was repeatedly registering calling accounts with the Android platform, and the way the platform then chose between registered accounts could leave an emergency call without the right one. Microsoft shipped a Teams update and Google an Android platform fix.

This project is a simplified reconstruction: PhoneAccountRegistry records every registration, and the locked EmergencyRouter only ranks the most recently registered accounts, so a flood of duplicates pushes the SIM out of consideration.

Make registration idempotent.

Bug report

BUG-E911-TEAMS · Priority: Critical (emergency calling) · Reported by: carrier escalation

PhoneAccountRegistry.register(app, handle, simBacked):

  • the registry holds at most ONE account per (app, handle) pair
  • registering a pair that is already present updates that entry's simBacked flag in place — its position in the list does not change
  • a new pair is appended at the end
  • different handles from the same app are different accounts

emergencyAccount() must keep returning the SIM account however many times an app re-registers itself.

Observed: an app that re-registers on every launch while signed out fills the registry, and emergencyAccount() returns null.

Logs

[telecom] registerPhoneAccount com.microsoft.teams/teams (count=19)
[telecom] registerPhoneAccount com.microsoft.teams/teams (count=20)
[telecom] emergency call: no SIM-backed account in ranking window

The code as shipped

src/telecom/PhoneAccountRegistry.java (editable)

class PhoneAccountRegistry {
    final List<PhoneAccount> accounts = new ArrayList<>();

    // Called by apps whenever they (re)initialise their calling integration.
    void register(String app, String handle, boolean simBacked) {
        accounts.add(new PhoneAccount(app, handle, simBacked));
    }

    int size() {
        return accounts.size();
    }

    PhoneAccount emergencyAccount() {
        return EmergencyRouter.pick(accounts);
    }
}

Read-only context: src/telecom/PhoneAccount.java.

Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More Java bug hunts.