Fix a bug that force closing happens even when SUPPRESS_EXCEPTION flag is on.
Change-Id: I927b11da1e62b147813fbbf01e2afce5915aed73
This commit is contained in:
parent
219d9d52e5
commit
4ff7bbcb97
3 changed files with 21 additions and 12 deletions
|
@ -197,8 +197,14 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
void setKeyboardMode(int mode, int imeOptions, boolean enableVoice) {
|
void setKeyboardMode(int mode, int imeOptions, boolean enableVoice) {
|
||||||
mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
|
mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
|
||||||
mPreferSymbols = mode == MODE_SYMBOLS;
|
mPreferSymbols = mode == MODE_SYMBOLS;
|
||||||
setKeyboardMode(mode == MODE_SYMBOLS ? MODE_TEXT : mode, imeOptions, enableVoice,
|
if (mode == MODE_SYMBOLS) {
|
||||||
mPreferSymbols);
|
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) {
|
void setKeyboardMode(int mode, int imeOptions, boolean enableVoice, boolean isSymbols) {
|
||||||
|
@ -213,11 +219,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
mInputView.setPreviewEnabled(true);
|
mInputView.setPreviewEnabled(true);
|
||||||
KeyboardId id = getKeyboardId(mode, imeOptions, isSymbols);
|
KeyboardId id = getKeyboardId(mode, imeOptions, isSymbols);
|
||||||
LatinKeyboard keyboard = null;
|
LatinKeyboard keyboard = null;
|
||||||
try {
|
keyboard = getKeyboard(id);
|
||||||
keyboard = getKeyboard(id);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
LatinImeLogger.logOnException(mode + "," + imeOptions + "," + isSymbols, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode == MODE_PHONE) {
|
if (mode == MODE_PHONE) {
|
||||||
mInputView.setPhoneKeyboard(keyboard);
|
mInputView.setPhoneKeyboard(keyboard);
|
||||||
|
|
|
@ -275,6 +275,7 @@ public class LatinIME extends InputMethodService
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override public void onCreate() {
|
@Override public void onCreate() {
|
||||||
|
LatinImeLogger.init(this);
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
//setStatusIcon(R.drawable.ime_qwerty);
|
//setStatusIcon(R.drawable.ime_qwerty);
|
||||||
mResources = getResources();
|
mResources = getResources();
|
||||||
|
@ -311,7 +312,6 @@ public class LatinIME extends InputMethodService
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
LatinImeLogger.init(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSuggest(String locale) {
|
private void initSuggest(String locale) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
private static final boolean DBG = true;
|
private static final boolean DBG = true;
|
||||||
private static boolean sLOGPRINT = false;
|
private static boolean sLOGPRINT = false;
|
||||||
// SUPPRESS_EXCEPTION should be true when released to public.
|
// 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.
|
// DEFAULT_LOG_ENABLED should be false when released to public.
|
||||||
private static final boolean DEFAULT_LOG_ENABLED = true;
|
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 long MINIMUMSENDSIZE = 40;
|
||||||
private static final char SEPARATER = ';';
|
private static final char SEPARATER = ';';
|
||||||
private static final char NULL_CHAR = '\uFFFC';
|
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_MANUALSUGGESTION = 0;
|
||||||
private static final int ID_AUTOSUGGESTIONCANCELLED = 1;
|
private static final int ID_AUTOSUGGESTIONCANCELLED = 1;
|
||||||
private static final int ID_AUTOSUGGESTION = 2;
|
private static final int ID_AUTOSUGGESTION = 2;
|
||||||
|
@ -368,7 +370,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
private void commitInternalAndStopSelf() {
|
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();
|
commitInternal();
|
||||||
LatinIME ime = ((LatinIME) mContext);
|
LatinIME ime = ((LatinIME) mContext);
|
||||||
ime.hideWindow();
|
ime.hideWindow();
|
||||||
|
@ -539,10 +543,13 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
PrintStream ps = new PrintStream(baos);
|
PrintStream ps = new PrintStream(baos);
|
||||||
e.printStackTrace(ps);
|
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(
|
sLatinImeLogger.sendLogToDropBox(
|
||||||
ID_EXCEPTION, new String[] {metaData, exceptionString});
|
ID_EXCEPTION, new String[] {metaData, exceptionString});
|
||||||
Log.e(TAG, "Exception: " + exceptionString);
|
if (DBG) {
|
||||||
|
Log.e(TAG, "Exception: " + new String(baos.toByteArray()));
|
||||||
|
}
|
||||||
if (SUPPRESS_EXCEPTION) {
|
if (SUPPRESS_EXCEPTION) {
|
||||||
sLatinImeLogger.commitInternalAndStopSelf();
|
sLatinImeLogger.commitInternalAndStopSelf();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue