Fix sorting issue during emergency call attempt.

Fix the integer overflow/underflow caused by sorting of duplicate phoneaccounts during emergency call attempt. 

Bug: 208267659
Original change: https://android-review.googlesource.com/c/platform/packages/services/Telecomm/+/1903050
Merged-In: I3529e4f86ba5690a8c2e72d6103a84c00bf3f358
Change-Id: I3529e4f86ba5690a8c2e72d6103a84c00bf3f358
Test: Added unit test (see https://googleplex-android-review.git.corp.google.com/c/platform/packages/services/Telecomm/+/16372187)
Test: Manual testing performed to confirm that this corrects repro.
(cherry picked from commit e20b83ec9b3dc2bc5a49a666bd057cf45ce99f15)
(cherry picked from commit 4f64285184fbad85a0a554f3cefa821846be8002)
Merged-In:I3529e4f86ba5690a8c2e72d6103a84c00bf3f358
1 file changed