forked from upstream-mirrors/OpenTracks
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;
|
package com.google.android.apps.mytracks.content;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.MyTracksConstants;
|
import com.google.android.apps.mytracks.MyTracksConstants;
|
||||||
|
import com.google.android.apps.mytracks.util.ApiFeatures;
|
||||||
|
|
||||||
import android.content.ContentProvider;
|
import android.content.ContentProvider;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
@@ -371,8 +372,11 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
throw new IllegalArgumentException("Unknown URL " + url);
|
throw new IllegalArgumentException("Unknown URL " + url);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(MyTracksConstants.TAG,
|
if (ApiFeatures.getInstance().canUseSQLiteQueryBuilderTwice()) {
|
||||||
"Build query: " + qb.buildQuery(projection, selection, selectionArgs, null, null, sortOrder, null));
|
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,
|
Cursor c = qb.query(db, projection, selection, selectionArgs, null, null,
|
||||||
sortOrder);
|
sortOrder);
|
||||||
c.setNotificationUri(getContext().getContentResolver(), url);
|
c.setNotificationUri(getContext().getContentResolver(), url);
|
||||||
|
|||||||
@@ -106,6 +106,18 @@ public class ApiFeatures {
|
|||||||
public boolean hasStrictMode() {
|
public boolean hasStrictMode() {
|
||||||
return getApiLevel() >= 9;
|
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.
|
// Visible for testing.
|
||||||
protected int getApiLevel() {
|
protected int getApiLevel() {
|
||||||
|
|||||||
Reference in New Issue
Block a user