[IL133] Avoid calling a dangerous method from outside.

We want to remove all calls to this as it lets internal values
escape, but there is some refactoring to do to finish this.

Bug: 8636060
Change-Id: Iedba6afe4719bc0add868714a1ee5a04b7ead33e
main
Jean Chalard 2014-03-27 18:37:16 +09:00
parent 9320553ab9
commit 8ab4ae4377
3 changed files with 23 additions and 8 deletions

View File

@ -297,12 +297,19 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
} }
// Implements {@link KeyboardState.SwitchActions}. // Implements {@link KeyboardState.SwitchActions}.
// TODO[IL]: merge the two following methods; remove the one without args.
@Override @Override
public void requestUpdatingShiftState() { public void requestUpdatingShiftState() {
mState.onUpdateShiftState(mLatinIME.getCurrentAutoCapsState(), mState.onUpdateShiftState(mLatinIME.getCurrentAutoCapsState(),
mLatinIME.getCurrentRecapitalizeState()); mLatinIME.getCurrentRecapitalizeState());
} }
// Future method for requesting an updating to the shift state.
public void requestUpdatingShiftState(final int currentAutoCapsState,
final int currentRecapitalizeState) {
mState.onUpdateShiftState(currentAutoCapsState, currentRecapitalizeState);
}
// Implements {@link KeyboardState.SwitchActions}. // Implements {@link KeyboardState.SwitchActions}.
@Override @Override
public void startDoubleTapShiftKeyTimer() { public void startDoubleTapShiftKeyTimer() {

View File

@ -197,7 +197,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
latinIme.mSettings.getCurrent()); latinIme.mSettings.getCurrent());
break; break;
case MSG_UPDATE_SHIFT_STATE: case MSG_UPDATE_SHIFT_STATE:
switcher.requestUpdatingShiftState(); switcher.requestUpdatingShiftState(latinIme.getCurrentAutoCapsState(),
latinIme.getCurrentRecapitalizeState());
break; break;
case MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP: case MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP:
if (msg.arg1 == ARG1_NOT_GESTURE_INPUT) { if (msg.arg1 == ARG1_NOT_GESTURE_INPUT) {
@ -833,7 +834,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// we need to re-evaluate the shift state, but not the whole layout which would be // we need to re-evaluate the shift state, but not the whole layout which would be
// disruptive. // disruptive.
// Space state must be updated before calling updateShiftState // Space state must be updated before calling updateShiftState
switcher.requestUpdatingShiftState(); switcher.requestUpdatingShiftState(getCurrentAutoCapsState(),
getCurrentRecapitalizeState());
} }
// This will set the punctuation suggestions if next word suggestion is off; // This will set the punctuation suggestions if next word suggestion is off;
// otherwise it will clear the suggestion strip. // otherwise it will clear the suggestion strip.
@ -912,7 +914,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO: find a better way to simulate actual execution. // TODO: find a better way to simulate actual execution.
if (isInputViewShown() && if (isInputViewShown() &&
mInputLogic.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd)) { mInputLogic.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd)) {
mKeyboardSwitcher.requestUpdatingShiftState(); mKeyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(),
getCurrentRecapitalizeState());
} }
mSubtypeState.currentSubtypeUsed(); mSubtypeState.currentSubtypeUsed();
@ -1256,7 +1259,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO: have the keyboard pass the correct key code when we need it. // TODO: have the keyboard pass the correct key code when we need it.
final Event event = Event.createSoftwareTextEvent(rawText, Event.NOT_A_KEY_CODE); final Event event = Event.createSoftwareTextEvent(rawText, Event.NOT_A_KEY_CODE);
mInputLogic.onTextInput(mSettings.getCurrent(), event, mHandler); mInputLogic.onTextInput(mSettings.getCurrent(), event, mHandler);
mKeyboardSwitcher.requestUpdatingShiftState(); mKeyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(),
getCurrentRecapitalizeState());
mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT, getCurrentAutoCapsState()); mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT, getCurrentAutoCapsState());
} }
@ -1500,7 +1504,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mHandler.postUpdateShiftState(); mHandler.postUpdateShiftState();
break; break;
case InputTransaction.SHIFT_UPDATE_NOW: case InputTransaction.SHIFT_UPDATE_NOW:
mKeyboardSwitcher.requestUpdatingShiftState(); mKeyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(),
getCurrentRecapitalizeState());
break; break;
default: // SHIFT_NO_UPDATE default: // SHIFT_NO_UPDATE
} }

View File

@ -537,7 +537,8 @@ public final class InputLogic {
// after typing some letters and a period, then gesturing; the keyboard is not in // after typing some letters and a period, then gesturing; the keyboard is not in
// caps mode yet, but since a gesture is starting, it should go in caps mode, // caps mode yet, but since a gesture is starting, it should go in caps mode,
// unless the user explictly said it should not. // unless the user explictly said it should not.
keyboardSwitcher.requestUpdatingShiftState(); keyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(settingsValues),
getCurrentRecapitalizeState());
} }
} }
mConnection.endBatchEdit(); mConnection.endBatchEdit();
@ -579,7 +580,8 @@ public final class InputLogic {
promotePhantomSpace(settingsValues); promotePhantomSpace(settingsValues);
mConnection.commitText(commitParts[0], 0); mConnection.commitText(commitParts[0], 0);
mSpaceState = SpaceState.PHANTOM; mSpaceState = SpaceState.PHANTOM;
keyboardSwitcher.requestUpdatingShiftState(); keyboardSwitcher.requestUpdatingShiftState(
getCurrentAutoCapsState(settingsValues), getCurrentRecapitalizeState());
mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime( mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime(
getActualCapsMode(settingsValues, getActualCapsMode(settingsValues,
keyboardSwitcher.getKeyboardShiftMode()), commitParts[0]); keyboardSwitcher.getKeyboardShiftMode()), commitParts[0]);
@ -1821,7 +1823,8 @@ public final class InputLogic {
} }
// Space state must be updated before calling updateShiftState // Space state must be updated before calling updateShiftState
mSpaceState = SpaceState.PHANTOM; mSpaceState = SpaceState.PHANTOM;
keyboardSwitcher.requestUpdatingShiftState(); keyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(settingsValues),
getCurrentRecapitalizeState());
} }
/** /**