mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Issue 311: Don't reuse the SQLiteQueryBuilder on Cupcake or Donut
due to Android issue 1587
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import com.google.android.apps.mytracks.MyTracksConstants;
|
||||
import com.google.android.apps.mytracks.util.ApiFeatures;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentUris;
|
||||
@@ -371,8 +372,11 @@ public class MyTracksProvider extends ContentProvider {
|
||||
throw new IllegalArgumentException("Unknown URL " + url);
|
||||
}
|
||||
|
||||
Log.i(MyTracksConstants.TAG,
|
||||
"Build query: " + qb.buildQuery(projection, selection, selectionArgs, null, null, sortOrder, null));
|
||||
if (ApiFeatures.getInstance().canUseSQLiteQueryBuilderTwice()) {
|
||||
Log.i(MyTracksConstants.TAG,
|
||||
"Build query: " + qb.buildQuery(projection, selection, selectionArgs,
|
||||
null, null, sortOrder, null));
|
||||
}
|
||||
Cursor c = qb.query(db, projection, selection, selectionArgs, null, null,
|
||||
sortOrder);
|
||||
c.setNotificationUri(getContext().getContentResolver(), url);
|
||||
|
||||
@@ -106,6 +106,18 @@ public class ApiFeatures {
|
||||
public boolean hasStrictMode() {
|
||||
return getApiLevel() >= 9;
|
||||
}
|
||||
|
||||
/**
|
||||
* There's a bug (#1587) in Cupcake and Donut which prevents you from
|
||||
* using a SQLiteQueryBuilder twice. That is, if you call buildQuery
|
||||
* on a given instance (to log the statement for debugging), and then
|
||||
* call query on the same instance to make it actually do the query,
|
||||
* it'll regenerate the query for the second call, and will screw it
|
||||
* up. Specifically, it'll add extra parens which don't belong.
|
||||
*/
|
||||
public boolean canUseSQLiteQueryBuilderTwice() {
|
||||
return getApiLevel() > 4;
|
||||
}
|
||||
|
||||
// Visible for testing.
|
||||
protected int getApiLevel() {
|
||||
|
||||
Reference in New Issue
Block a user