mirror of https://github.com/M66B/FairEmail.git
Update ROOM and Biometrics libraries
This commit is contained in:
parent
679179b97a
commit
29f1ad6a8c
|
@ -175,12 +175,12 @@ dependencies {
|
|||
def material_version = "1.1.0-alpha09"
|
||||
def browser_version = "1.0.0"
|
||||
def lifecycle_version = "2.1.0-rc01"
|
||||
def room_version = "2.1.0"
|
||||
def room_version = "2.2.0-beta01"
|
||||
def paging_version = "2.1.0"
|
||||
def preference_version = "1.1.0-rc01"
|
||||
def work_version = "2.2.0"
|
||||
def exif_version = "1.1.0-beta01"
|
||||
def biometric_version = "1.0.0-alpha04"
|
||||
def biometric_version = "1.0.0-beta01"
|
||||
def billingclient_version = "2.0.3"
|
||||
def javamail_version = "1.6.3"
|
||||
def jsoup_version = "1.12.1"
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.app.ActivityManager;
|
|||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.os.Build;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
|
@ -294,7 +295,8 @@ public abstract class RoomDatabase {
|
|||
* @param args The bind arguments for the placeholders in the query
|
||||
* @return A Cursor obtained by running the given query in the Room database.
|
||||
*/
|
||||
public Cursor query(String query, @Nullable Object[] args) {
|
||||
@NonNull
|
||||
public Cursor query(@NonNull String query, @Nullable Object[] args) {
|
||||
return mOpenHelper.getWritableDatabase().query(new SimpleSQLiteQuery(query, args));
|
||||
}
|
||||
|
||||
|
@ -304,10 +306,27 @@ public abstract class RoomDatabase {
|
|||
* @param query The Query which includes the SQL and a bind callback for bind arguments.
|
||||
* @return Result of the query.
|
||||
*/
|
||||
public Cursor query(SupportSQLiteQuery query) {
|
||||
@NonNull
|
||||
public Cursor query(@NonNull SupportSQLiteQuery query) {
|
||||
return query(query, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for {@link SupportSQLiteDatabase#query(SupportSQLiteQuery)}.
|
||||
*
|
||||
* @param query The Query which includes the SQL and a bind callback for bind arguments.
|
||||
* @param signal The cancellation signal to be attached to the query.
|
||||
* @return Result of the query.
|
||||
*/
|
||||
@NonNull
|
||||
public Cursor query(@NonNull SupportSQLiteQuery query, @Nullable CancellationSignal signal) {
|
||||
assertNotMainThread();
|
||||
assertNotSuspendingTransaction();
|
||||
return mOpenHelper.getWritableDatabase().query(query);
|
||||
if (signal != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
return mOpenHelper.getWritableDatabase().query(query, signal);
|
||||
} else {
|
||||
return mOpenHelper.getWritableDatabase().query(query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,8 +19,10 @@ package androidx.room.util;
|
|||
import android.database.AbstractWindowedCursor;
|
||||
import android.database.Cursor;
|
||||
import android.os.Build;
|
||||
import android.os.CancellationSignal;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RestrictTo;
|
||||
import androidx.room.RoomDatabase;
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
|
@ -53,10 +55,32 @@ public class DBUtil {
|
|||
* @param sqLiteQuery The query to perform.
|
||||
* @param maybeCopy True if the result cursor should maybe be copied, false otherwise.
|
||||
* @return Result of the query.
|
||||
*
|
||||
* @deprecated This is only used in the generated code and shouldn't be called directly.
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
public static Cursor query(RoomDatabase db, SupportSQLiteQuery sqLiteQuery, boolean maybeCopy) {
|
||||
final Cursor cursor = db.query(sqLiteQuery);
|
||||
return query(db, sqLiteQuery, maybeCopy, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the SQLiteQuery on the given database.
|
||||
* <p>
|
||||
* This util method encapsulates copying the cursor if the {@code maybeCopy} parameter is
|
||||
* {@code true} and either the api level is below a certain threshold or the full result of the
|
||||
* query does not fit in a single window.
|
||||
*
|
||||
* @param db The database to perform the query on.
|
||||
* @param sqLiteQuery The query to perform.
|
||||
* @param maybeCopy True if the result cursor should maybe be copied, false otherwise.
|
||||
* @param signal The cancellation signal to be attached to the query.
|
||||
* @return Result of the query.
|
||||
*/
|
||||
@NonNull
|
||||
public static Cursor query(@NonNull RoomDatabase db, @NonNull SupportSQLiteQuery sqLiteQuery,
|
||||
boolean maybeCopy, @Nullable CancellationSignal signal) {
|
||||
final Cursor cursor = db.query(sqLiteQuery, signal);
|
||||
if (maybeCopy && cursor instanceof AbstractWindowedCursor) {
|
||||
AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor) cursor;
|
||||
int rowsInCursor = windowedCursor.getCount(); // Should fill the window.
|
||||
|
@ -132,6 +156,20 @@ public class DBUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CancellationSignal is only available from API 16 on. This function will create a new
|
||||
* instance of the Cancellation signal only if the current API > 16.
|
||||
*
|
||||
* @return A new instance of CancellationSignal or null.
|
||||
*/
|
||||
@Nullable
|
||||
public static CancellationSignal createCancellationSignal() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
return new CancellationSignal();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private DBUtil() {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue