Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3bdef09 authored by Stanley Wang's avatar Stanley Wang
Browse files

Add error handling for SearchIndexablesProvider.

Catch exception to avoid the client process killed.

Bug: 127906747
Test: rebuild

Change-Id: I595b0ed9ca62579f0b5f90d8e85adffbaa3bd611
parent 418358a0
Loading
Loading
Loading
Loading
+21 −13
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.UriMatcher;
import android.content.pm.ProviderInfo;
import android.database.Cursor;
import android.net.Uri;
import android.util.Log;

/**
 * Base class for a search indexable provider. Such provider offers data to be indexed either
@@ -112,6 +113,7 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
                        String sortOrder) {
        try {
            switch (mMatcher.match(uri)) {
                case MATCH_RES_CODE:
                    return queryXmlResources(null);
@@ -126,6 +128,12 @@ public abstract class SearchIndexablesProvider extends ContentProvider {
                default:
                    throw new UnsupportedOperationException("Unknown Uri " + uri);
            }
        } catch (UnsupportedOperationException e) {
            throw e;
        } catch (Exception e) {
            Log.e(TAG, "Provider querying exception:", e);
            return null;
        }
    }

    /**