Fix a native crash
-1 & 0xFFFF is 65536 :p Change-Id: I8ecb882b6d6c5bcc91b52e23eb9cc02b04fcdd34
This commit is contained in:
parent
acb6c5445f
commit
b0b89c87f6
2 changed files with 12 additions and 2 deletions
|
@ -574,7 +574,12 @@ public class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
// The getXYForCodePointAndScript method returns (Y << 16) + X
|
// The getXYForCodePointAndScript method returns (Y << 16) + X
|
||||||
final int xy = SpellCheckerProximityInfo.getXYForCodePointAndScript(
|
final int xy = SpellCheckerProximityInfo.getXYForCodePointAndScript(
|
||||||
codePoint, mScript);
|
codePoint, mScript);
|
||||||
composer.add(codePoint, xy & 0xFFFF, xy >> 16, null);
|
if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
|
||||||
|
composer.add(codePoint, WordComposer.NOT_A_COORDINATE,
|
||||||
|
WordComposer.NOT_A_COORDINATE, null);
|
||||||
|
} else {
|
||||||
|
composer.add(codePoint, xy & 0xFFFF, xy >> 16, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final int capitalizeType = getCapitalizationType(text);
|
final int capitalizeType = getCapitalizationType(text);
|
||||||
|
|
|
@ -35,6 +35,9 @@ public class SpellCheckerProximityInfo {
|
||||||
// The number of rows in the grid used by the spell checker.
|
// The number of rows in the grid used by the spell checker.
|
||||||
final public static int PROXIMITY_GRID_HEIGHT = 3;
|
final public static int PROXIMITY_GRID_HEIGHT = 3;
|
||||||
|
|
||||||
|
final private static int NOT_AN_INDEX = -1;
|
||||||
|
final public static int NOT_A_COORDINATE_PAIR = -1;
|
||||||
|
|
||||||
// Helper methods
|
// Helper methods
|
||||||
final protected static void buildProximityIndices(final int[] proximity,
|
final protected static void buildProximityIndices(final int[] proximity,
|
||||||
final TreeMap<Integer, Integer> indices) {
|
final TreeMap<Integer, Integer> indices) {
|
||||||
|
@ -45,7 +48,7 @@ public class SpellCheckerProximityInfo {
|
||||||
final protected static int computeIndex(final int characterCode,
|
final protected static int computeIndex(final int characterCode,
|
||||||
final TreeMap<Integer, Integer> indices) {
|
final TreeMap<Integer, Integer> indices) {
|
||||||
final Integer result = indices.get(characterCode);
|
final Integer result = indices.get(characterCode);
|
||||||
if (null == result) return -1;
|
if (null == result) return NOT_AN_INDEX;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,8 +199,10 @@ public class SpellCheckerProximityInfo {
|
||||||
// Returns (Y << 16) + X to avoid creating a temporary object. This is okay because
|
// Returns (Y << 16) + X to avoid creating a temporary object. This is okay because
|
||||||
// X and Y are limited to PROXIMITY_GRID_WIDTH resp. PROXIMITY_GRID_HEIGHT which is very
|
// X and Y are limited to PROXIMITY_GRID_WIDTH resp. PROXIMITY_GRID_HEIGHT which is very
|
||||||
// inferior to 1 << 16
|
// inferior to 1 << 16
|
||||||
|
// As an exception, this returns NOT_A_COORDINATE_PAIR if the key is not on the grid
|
||||||
public static int getXYForCodePointAndScript(final int codePoint, final int script) {
|
public static int getXYForCodePointAndScript(final int codePoint, final int script) {
|
||||||
final int index = getIndexOfCodeForScript(codePoint, script);
|
final int index = getIndexOfCodeForScript(codePoint, script);
|
||||||
|
if (NOT_AN_INDEX == index) return NOT_A_COORDINATE_PAIR;
|
||||||
final int y = index / PROXIMITY_GRID_WIDTH;
|
final int y = index / PROXIMITY_GRID_WIDTH;
|
||||||
final int x = index % PROXIMITY_GRID_WIDTH;
|
final int x = index % PROXIMITY_GRID_WIDTH;
|
||||||
if (y > PROXIMITY_GRID_HEIGHT) {
|
if (y > PROXIMITY_GRID_HEIGHT) {
|
||||||
|
|
Loading…
Reference in a new issue