Update Settings search result unique ids

- SearchResult stableIds are now DocIds from the database
- DocIds are data reference key's hash, when the key is not
empty or null
- Otherwise, DocIds are a hashcode from a set of fields.

Change-Id: Id36f7bf4ceaaa3a2bd326ecafbfe97fd0b247df2
Fixes: 37327194
Test: make RunSettingsRoboTest
This commit is contained in:
Matthew Fritze
2017-05-12 15:59:19 -07:00
parent 7f2d779e15
commit 6efea1e624
12 changed files with 347 additions and 499 deletions

View File

@@ -1061,10 +1061,11 @@ public class DatabaseIndexingManager {
* Returns the doc id for this row.
*/
public int getDocId() {
// The DocID should contains more than the title string itself (you may have two
// settings with the same title). So we need to use a combination of multiple
// attributes from this row.
return Objects.hash(updatedTitle, screenTitle, key, payloadType);
// Eventually we want all DocIds to be the data_reference key. For settings values,
// this will be preference keys, and for non-settings they should be unique.
return TextUtils.isEmpty(key)
? Objects.hash(updatedTitle, className, screenTitle, intentTargetClass)
: key.hashCode();
}
public static class Builder {