package androidx.loader.content; import android.content.Context; import android.database.Cursor; import android.net.Uri; import androidx.core.content.ContentResolverCompat; import androidx.core.os.CancellationSignal; import androidx.core.os.OperationCanceledException; import androidx.loader.content.Loader; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.Arrays; /* loaded from: classes2.dex */ public class CursorLoader extends AsyncTaskLoader { CancellationSignal mCancellationSignal; Cursor mCursor; final Loader.ForceLoadContentObserver mObserver; String[] mProjection; String mSelection; String[] mSelectionArgs; String mSortOrder; Uri mUri; public String[] getProjection() { return this.mProjection; } public String getSelection() { return this.mSelection; } public String[] getSelectionArgs() { return this.mSelectionArgs; } public String getSortOrder() { return this.mSortOrder; } public Uri getUri() { return this.mUri; } public void setProjection(String[] strArr) { this.mProjection = strArr; } public void setSelection(String str) { this.mSelection = str; } public void setSelectionArgs(String[] strArr) { this.mSelectionArgs = strArr; } public void setSortOrder(String str) { this.mSortOrder = str; } public void setUri(Uri uri) { this.mUri = uri; } /* JADX WARN: Can't rename method to resolve collision */ @Override // androidx.loader.content.AsyncTaskLoader public Cursor loadInBackground() { synchronized (this) { if (isLoadInBackgroundCanceled()) { throw new OperationCanceledException(); } this.mCancellationSignal = new CancellationSignal(); } try { Cursor query = ContentResolverCompat.query(getContext().getContentResolver(), this.mUri, this.mProjection, this.mSelection, this.mSelectionArgs, this.mSortOrder, this.mCancellationSignal); if (query != null) { try { query.getCount(); query.registerContentObserver(this.mObserver); } catch (RuntimeException e) { query.close(); throw e; } } synchronized (this) { this.mCancellationSignal = null; } return query; } catch (Throwable th) { synchronized (this) { this.mCancellationSignal = null; throw th; } } } @Override // androidx.loader.content.AsyncTaskLoader public void cancelLoadInBackground() { super.cancelLoadInBackground(); synchronized (this) { CancellationSignal cancellationSignal = this.mCancellationSignal; if (cancellationSignal != null) { cancellationSignal.cancel(); } } } @Override // androidx.loader.content.Loader public void deliverResult(Cursor cursor) { if (isReset()) { if (cursor != null) { cursor.close(); return; } return; } Cursor cursor2 = this.mCursor; this.mCursor = cursor; if (isStarted()) { super.deliverResult((CursorLoader) cursor); } if (cursor2 == null || cursor2 == cursor || cursor2.isClosed()) { return; } cursor2.close(); } public CursorLoader(Context context) { super(context); this.mObserver = new Loader.ForceLoadContentObserver(); } public CursorLoader(Context context, Uri uri, String[] strArr, String str, String[] strArr2, String str2) { super(context); this.mObserver = new Loader.ForceLoadContentObserver(); this.mUri = uri; this.mProjection = strArr; this.mSelection = str; this.mSelectionArgs = strArr2; this.mSortOrder = str2; } @Override // androidx.loader.content.Loader protected void onStartLoading() { Cursor cursor = this.mCursor; if (cursor != null) { deliverResult(cursor); } if (takeContentChanged() || this.mCursor == null) { forceLoad(); } } @Override // androidx.loader.content.Loader protected void onStopLoading() { cancelLoad(); } @Override // androidx.loader.content.AsyncTaskLoader public void onCanceled(Cursor cursor) { if (cursor == null || cursor.isClosed()) { return; } cursor.close(); } /* JADX INFO: Access modifiers changed from: protected */ @Override // androidx.loader.content.Loader public void onReset() { super.onReset(); onStopLoading(); Cursor cursor = this.mCursor; if (cursor != null && !cursor.isClosed()) { this.mCursor.close(); } this.mCursor = null; } @Override // androidx.loader.content.AsyncTaskLoader, androidx.loader.content.Loader @Deprecated public void dump(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) { super.dump(str, fileDescriptor, printWriter, strArr); printWriter.print(str); printWriter.print("mUri="); printWriter.println(this.mUri); printWriter.print(str); printWriter.print("mProjection="); printWriter.println(Arrays.toString(this.mProjection)); printWriter.print(str); printWriter.print("mSelection="); printWriter.println(this.mSelection); printWriter.print(str); printWriter.print("mSelectionArgs="); printWriter.println(Arrays.toString(this.mSelectionArgs)); printWriter.print(str); printWriter.print("mSortOrder="); printWriter.println(this.mSortOrder); printWriter.print(str); printWriter.print("mCursor="); printWriter.println(this.mCursor); printWriter.print(str); printWriter.print("mContentChanged="); printWriter.println(this.mContentChanged); } }