Fix Smart dialing OOM for extremely long contacts

Names with an extremely large number of name tokens were
using exponentially increasing amounts of memory since we have
to insert entries for all possible initial name combinations.

Added a check in the trie insertion algorithm to only add initial
matches for the 1st 2, and the last 2 name tokens.

This change only affects search by initial matches for names exceeding
4 name tokens. Full token search for names of all lengths should still
work. E.g. "frank", "enstein" would still match "Dr Frank En Stein DDS".
However initial matching would be limited to the first 2 and last 2 tokens.
So "dfsd" or "fsd" would work, but "fes" or "fed" would not.

Also fixes a bug caused by integer overflow when calculating thresholds
for bucketing frequently used contacts

Bug 8737986

Change-Id: I804184368b78fe2fa407667ed83874d839c28115
3 files changed
tree: d9bdc299d89d60364954e50bcebba85e75f33344
  1. res/
  2. src/
  3. tests/
  4. Android.mk
  5. AndroidManifest.xml
  6. proguard.flags