Merge "Make user and contacts dict use ver3 format."
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index 1eff2f9..aae5b0b 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -388,7 +388,7 @@
 be a QWERTY, or AZERTY, or any other disposition that only offers Latin characters, so
 you wouldn't be able to type, say, Arabic on it. Please translate it in a way that "alphabet"
 would be understood to mean specifically the Latin alphabet, rather than any other
-alphabet. [CHAR LIMIT=25] -->
+alphabet. [CHAR LIMIT=29] -->
     <string name="subtype_no_language">No language (Alphabet)</string>
     <!-- This string is displayed in the description for a keyboard type. It refers specifically to
 the Latin alphabet, as opposed to Cyrillic, Arabic, Hebrew or other scripts.
diff --git a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.cpp b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.cpp
index 20cda91..7ac635a 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.cpp
+++ b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.cpp
@@ -27,7 +27,9 @@
     const uint8_t *const dictRoot = mBinaryDictionaryInfo->getDictRoot();
     int pos = nodePos;
     mFlags = PatriciaTrieReadingUtils::getFlagsAndAdvancePosition(dictRoot, &pos);
-    mParentPos = DynamicPatriciaTrieReadingUtils::getParentPosAndAdvancePosition(dictRoot, &pos);
+    const int parentPos =
+            DynamicPatriciaTrieReadingUtils::getParentPosAndAdvancePosition(dictRoot, &pos);
+    mParentPos = (parentPos != 0) ? mNodePos + parentPos : NOT_A_DICT_POS;
     if (outCodePoints != 0) {
         mCodePointCount = PatriciaTrieReadingUtils::getCharsAndAdvancePosition(
                 dictRoot, mFlags, maxCodePointCount, outCodePoints, &pos);
diff --git a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp
index 0b73efa..3df5056 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp
+++ b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp
@@ -94,7 +94,7 @@
         reverseCodePoints[codePointCount++] = mergedNodeCodePoints[i];
     }
     // Then, follow parent pos toward the root node.
-    while (nodeReader.getParentPos() != getRootPosition()) {
+    while (nodeReader.getParentPos() != NOT_A_DICT_POS) {
         // codePointCount must be incremented at least once in each iteration to ensure preventing
         // infinite loop.
         if (nodeReader.isDeleted() || codePointCount > maxCodePointCount
diff --git a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_reading_utils.h b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_reading_utils.h
index f44c265..5398d7e 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_reading_utils.h
+++ b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_reading_utils.h
@@ -39,8 +39,7 @@
 
     static AK_FORCE_INLINE int getParentPosAndAdvancePosition(const uint8_t *const buffer,
             int *const pos) {
-        const int base = *pos;
-        return base + ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
+        return ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
     }
 
     static int readChildrenPositionAndAdvancePosition(const uint8_t *const buffer,