Improve the robustness of updateNonIndexableKeys
- Isolate preference controller crash in the same page Current if one search item throw exception, entire page's search will broken, can isolate issue by controller to improve. - Expose preference controller crash in debuggable build Current the search index exception is silently ignored, expose the exception in debuggable builds to expose issue earlier. - Change default to hide items instead of shown when crash Fix: 352455031 Fix: 352455432 Fix: 352455540 Flag: EXEMPT bug fix Test: manual - Settings Search Change-Id: I2cdbd58543be8fe6617e42d9c02789791186f53b
This commit is contained in:
@@ -50,6 +50,7 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.SearchIndexablesContract;
|
||||
import android.provider.SearchIndexablesProvider;
|
||||
@@ -283,17 +284,16 @@ public class SettingsSearchIndexablesProvider extends SearchIndexablesProvider {
|
||||
try {
|
||||
providerNonIndexableKeys = provider.getNonIndexableKeys(context);
|
||||
} catch (Exception e) {
|
||||
String msg = "Error trying to get non-indexable keys from: "
|
||||
+ bundle.getTargetClass().getName();
|
||||
// Catch a generic crash. In the absence of the catch, the background thread will
|
||||
// silently fail anyway, so we aren't losing information by catching the exception.
|
||||
// We crash when the system property exists so that we can test if crashes need to
|
||||
// be fixed.
|
||||
// The gain is that if there is a crash in a specific controller, we don't lose all
|
||||
// non-indexable keys, but we can still find specific crashes in development.
|
||||
if (System.getProperty(SYSPROP_CRASH_ON_ERROR) != null) {
|
||||
throw new RuntimeException(e);
|
||||
// We crash on debuggable build or when the system property exists, so that we can
|
||||
// test if crashes need to be fixed.
|
||||
if (Build.IS_DEBUGGABLE || System.getProperty(SYSPROP_CRASH_ON_ERROR) != null) {
|
||||
throw new RuntimeException(msg, e);
|
||||
}
|
||||
Log.e(TAG, "Error trying to get non-indexable keys from: "
|
||||
+ bundle.getTargetClass().getName(), e);
|
||||
Log.e(TAG, msg, e);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user