Created
May 7, 2014 08:45
-
-
Save yonekawa/57d44a440b798b25b32d to your computer and use it in GitHub Desktop.
Revisions
-
yonekawa created this gist
May 7, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ diff --git a/facebook/src/com/facebook/internal/AttributionIdentifiers.java b/facebook/src/com/facebook/internal/AttributionIdentifiers.java index 1c8f630..f142f25 100644 --- a/facebook/src/com/facebook/internal/AttributionIdentifiers.java +++ b/facebook/src/com/facebook/internal/AttributionIdentifiers.java @@ -104,25 +104,23 @@ public class AttributionIdentifiers { try { String [] projection = {ATTRIBUTION_ID_COLUMN_NAME, ANDROID_ID_COLUMN_NAME, LIMIT_TRACKING_COLUMN_NAME}; Cursor c = context.getContentResolver().query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null); - if (c == null || !c.moveToFirst()) { - return null; + if (c != null && c.moveToFirst()) { + int attributionColumnIndex = c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME); + int androidIdColumnIndex = c.getColumnIndex(ANDROID_ID_COLUMN_NAME); + int limitTrackingColumnIndex = c.getColumnIndex(LIMIT_TRACKING_COLUMN_NAME); + + identifiers.attributionId = c.getString(attributionColumnIndex); + + // if we failed to call Google's APIs directly (due to improper integration by the client), it may be + // possible for the local facebook application to relay it to us. + if (androidIdColumnIndex > 0 && limitTrackingColumnIndex > 0 && identifiers.getAndroidAdvertiserId() == null) { + identifiers.androidAdvertiserId = c.getString(androidIdColumnIndex); + identifiers.limitTracking = Boolean.parseBoolean(c.getString(limitTrackingColumnIndex)); + } + c.close(); } - int attributionColumnIndex = c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME); - int androidIdColumnIndex = c.getColumnIndex(ANDROID_ID_COLUMN_NAME); - int limitTrackingColumnIndex = c.getColumnIndex(LIMIT_TRACKING_COLUMN_NAME); - - identifiers.attributionId = c.getString(attributionColumnIndex); - - // if we failed to call Google's APIs directly (due to improper integration by the client), it may be - // possible for the local facebook application to relay it to us. - if (androidIdColumnIndex > 0 && limitTrackingColumnIndex > 0 && identifiers.getAndroidAdvertiserId() == null) { - identifiers.androidAdvertiserId = c.getString(androidIdColumnIndex); - identifiers.limitTracking = Boolean.parseBoolean(c.getString(limitTrackingColumnIndex)); - } - c.close(); } catch (Exception e) { Log.d(TAG, "Caught unexpected exception in getAttributionId(): " + e.toString()); - return null; } identifiers.fetchTime = System.currentTimeMillis(); @@ -141,4 +139,4 @@ public class AttributionIdentifiers { public boolean isTrackingLimited() { return limitTracking; } -} \ No newline at end of file +}