Fix a bug that force closing happens even when SUPPRESS_EXCEPTION flag is on.

Change-Id: I927b11da1e62b147813fbbf01e2afce5915aed73
main
satok 2010-06-03 14:54:35 +09:00
parent 219d9d52e5
commit 4ff7bbcb97
3 changed files with 21 additions and 12 deletions

View File

@ -197,8 +197,14 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
void setKeyboardMode(int mode, int imeOptions, boolean enableVoice) {
mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
mPreferSymbols = mode == MODE_SYMBOLS;
setKeyboardMode(mode == MODE_SYMBOLS ? MODE_TEXT : mode, imeOptions, enableVoice,
mPreferSymbols);
if (mode == MODE_SYMBOLS) {
mode = MODE_TEXT;
}
try {
setKeyboardMode(mode, imeOptions, enableVoice, mPreferSymbols);
} catch (RuntimeException e) {
LatinImeLogger.logOnException(mode + "," + imeOptions + "," + mPreferSymbols, e);
}
}
void setKeyboardMode(int mode, int imeOptions, boolean enableVoice, boolean isSymbols) {
@ -213,11 +219,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mInputView.setPreviewEnabled(true);
KeyboardId id = getKeyboardId(mode, imeOptions, isSymbols);
LatinKeyboard keyboard = null;
try {
keyboard = getKeyboard(id);
} catch (RuntimeException e) {
LatinImeLogger.logOnException(mode + "," + imeOptions + "," + isSymbols, e);
}
keyboard = getKeyboard(id);
if (mode == MODE_PHONE) {
mInputView.setPhoneKeyboard(keyboard);

View File

@ -275,6 +275,7 @@ public class LatinIME extends InputMethodService
};
@Override public void onCreate() {
LatinImeLogger.init(this);
super.onCreate();
//setStatusIcon(R.drawable.ime_qwerty);
mResources = getResources();
@ -311,7 +312,6 @@ public class LatinIME extends InputMethodService
});
}
prefs.registerOnSharedPreferenceChangeListener(this);
LatinImeLogger.init(this);
}
private void initSuggest(String locale) {

View File

@ -39,7 +39,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
private static final boolean DBG = true;
private static boolean sLOGPRINT = false;
// SUPPRESS_EXCEPTION should be true when released to public.
private static final boolean SUPPRESS_EXCEPTION = false;
private static final boolean SUPPRESS_EXCEPTION = true;
// DEFAULT_LOG_ENABLED should be false when released to public.
private static final boolean DEFAULT_LOG_ENABLED = true;
@ -48,6 +48,8 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
private static final long MINIMUMSENDSIZE = 40;
private static final char SEPARATER = ';';
private static final char NULL_CHAR = '\uFFFC';
private static final int EXCEPTION_MAX_LENGTH = 400;
private static final int ID_MANUALSUGGESTION = 0;
private static final int ID_AUTOSUGGESTIONCANCELLED = 1;
private static final int ID_AUTOSUGGESTION = 2;
@ -368,7 +370,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
}
private void commitInternalAndStopSelf() {
Log.e(TAG, "Exception was caused and let's die.");
if (DBG) {
Log.e(TAG, "Exception was thrown and let's die.");
}
commitInternal();
LatinIME ime = ((LatinIME) mContext);
ime.hideWindow();
@ -539,10 +543,13 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
e.printStackTrace(ps);
String exceptionString = new String(baos.toByteArray());
String exceptionString = new String(baos.toByteArray(), 0,
Math.min(EXCEPTION_MAX_LENGTH, baos.size()));
sLatinImeLogger.sendLogToDropBox(
ID_EXCEPTION, new String[] {metaData, exceptionString});
Log.e(TAG, "Exception: " + exceptionString);
if (DBG) {
Log.e(TAG, "Exception: " + new String(baos.toByteArray()));
}
if (SUPPRESS_EXCEPTION) {
sLatinImeLogger.commitInternalAndStopSelf();
} else {