Catch inflate exception

Change-Id: Ia5a384f5cbd2d0063904c2959ccbeb987198616b
main
satok 2010-06-09 00:49:44 +09:00
parent acbe38f3e1
commit d5d61c3485
2 changed files with 9 additions and 5 deletions

View File

@ -25,6 +25,7 @@ import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.preference.PreferenceManager;
import android.view.InflateException;
public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -400,6 +401,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} catch (OutOfMemoryError e) {
tryGC = LatinIMEUtil.GCUtils.getInstance().tryGCOrWait(
mLayoutId + "," + newLayout, e);
} catch (InflateException e) {
tryGC = LatinIMEUtil.GCUtils.getInstance().tryGCOrWait(
mLayoutId + "," + newLayout, e);
}
}
mInputView.setExtentionLayoutResId(LAYOUTS[newLayout]);

View File

@ -24,7 +24,7 @@ public class LatinIMEUtil {
private static final String TAG = "GCUtils";
public static final int GC_TRY_COUNT = 2;
// GC_TRY_LOOP_MAX is used for the hard limit of GC wait,
// GC_TRY_LOOP_MAX should be GC_TRY_COUNT.
// GC_TRY_LOOP_MAX should be greater than GC_TRY_COUNT.
public static final int GC_TRY_LOOP_MAX = 5;
private static final long GC_INTERVAL = DateUtils.SECOND_IN_MILLIS;
private static GCUtils sInstance = new GCUtils();
@ -38,15 +38,15 @@ public class LatinIMEUtil {
mGCTryCount = 0;
}
public boolean tryGCOrWait(String metaData, OutOfMemoryError oome) {
public boolean tryGCOrWait(String metaData, Throwable t) {
if (LatinImeLogger.sDBG) {
Log.d(TAG, "Encountered Out of memory Error. Try GC.");
Log.d(TAG, "Encountered Exception or Error. Try GC.");
}
if (mGCTryCount == 0) {
System.gc();
}
if (++mGCTryCount > GC_TRY_COUNT) {
LatinImeLogger.logOnException(metaData, oome);
LatinImeLogger.logOnException(metaData, t);
return false;
} else {
try {
@ -54,7 +54,7 @@ public class LatinIMEUtil {
return true;
} catch (InterruptedException e) {
Log.e(TAG, "Sleep was interrupted.");
LatinImeLogger.logOnException(metaData, oome);
LatinImeLogger.logOnException(metaData, t);
return false;
}
}