Example usage for android.util Config LOGD

List of usage examples for android.util Config LOGD

Introduction

In this page you can find the example usage for android.util Config LOGD.

Prototype

boolean LOGD

To view the source code for android.util Config LOGD.

Click Source Link

Usage

From source file:com.android.providers.contacts.ContactsSyncAdapter.java

private void getServerPhotos(SyncContext context, String feedUrl, int maxDownloads, GDataSyncData syncData,
        SyncResult syncResult) {// ww  w .j  a  v  a 2 s.c om
    final ContentResolver cr = getContext().getContentResolver();
    Cursor cursor = cr.query(Photos.CONTENT_URI,
            new String[] { Photos._SYNC_ID, Photos._SYNC_VERSION, Photos.PERSON_ID, Photos.DOWNLOAD_REQUIRED,
                    Photos._ID },
            "" + "_sync_account=? AND download_required != 0", new String[] { getAccount() }, null);
    try {
        int numFetched = 0;
        while (cursor.moveToNext()) {
            if (numFetched >= maxDownloads) {
                break;
            }
            String photoSyncId = cursor.getString(0);
            String photoVersion = cursor.getString(1);
            long person = cursor.getLong(2);
            String photoUrl = feedUrl + "/" + photoSyncId;
            long photoId = cursor.getLong(4);

            try {
                context.setStatusText("Downloading photo " + photoSyncId);
                ++numFetched;
                ++mPhotoDownloads;
                InputStream inputStream = mContactsClient.getMediaEntryAsStream(photoUrl, getAuthToken());
                savePhoto(person, inputStream, photoVersion);
                syncResult.stats.numUpdates++;
            } catch (IOException e) {
                if (Log.isLoggable(TAG, Log.VERBOSE)) {
                    Log.d(TAG, "error downloading " + photoUrl, e);
                }
                syncResult.stats.numIoExceptions++;
                return;
            } catch (HttpException e) {
                switch (e.getStatusCode()) {
                case HttpException.SC_UNAUTHORIZED:
                    if (Config.LOGD) {
                        Log.d(TAG, "not authorized to download " + photoUrl, e);
                    }
                    syncResult.stats.numAuthExceptions++;
                    return;
                case HttpException.SC_FORBIDDEN:
                case HttpException.SC_NOT_FOUND:
                    final String exceptionMessage = e.getMessage();
                    if (Config.LOGD) {
                        Log.d(TAG, "unable to download photo " + photoUrl + ", " + exceptionMessage
                                + ", ignoring");
                    }
                    ContentValues values = new ContentValues();
                    values.put(Photos.SYNC_ERROR, exceptionMessage);
                    Uri photoUri = Uri.withAppendedPath(ContentUris.withAppendedId(People.CONTENT_URI, photoId),
                            Photos.CONTENT_DIRECTORY);
                    cr.update(photoUri, values, null /* where */, null /* where args */);
                    break;
                default:
                    if (Config.LOGD) {
                        Log.d(TAG, "error downloading " + photoUrl, e);
                    }
                    syncResult.stats.numIoExceptions++;
                    return;
                }
            }
        }
        final boolean hasMoreToSync = numFetched < cursor.getCount();
        GDataSyncData.FeedData feedData = new GDataSyncData.FeedData(0 /* no update time */, numFetched,
                hasMoreToSync, null /* no lastId */, 0 /* no feed index */);
        syncData.feedData.put(feedUrl, feedData);
    } finally {
        cursor.close();
    }
}

From source file:com.googlecode.talkingrssreader.talkingrss.ReaderHttp.java

public void tagFeed(String feedId, String tag, boolean add) throws ReaderException {
    if (Config.LOGD)
        Log.d(TAG, String.format("%s feed %s as %s", (add ? "tagging" : "untagging"), feedId, tag));
    ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("s", feedId));
    params.add(new BasicNameValuePair(add ? "a" : "r", tag));
    params.add(new BasicNameValuePair("ac", "edit"));
    doApiPost(SUBSCRIPTION_URL, params);
}

From source file:com.googlecode.talkingrssreader.talkingrss.ReaderHttp.java

public void disableTag(String tag) throws ReaderException {
    if (Config.LOGD)
        Log.d(TAG, "Disabling tag: " + tag);
    ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("s", tag));
    params.add(new BasicNameValuePair("ac", "disable-tags"));
    doApiPost(DISABLE_TAG_URL, params);
}

From source file:com.android.providers.contacts.ContactsSyncAdapter.java

protected void sendClientPhotos(SyncContext context, ContentProvider clientDiffs, Object syncInfo,
        SyncResult syncResult) {/*from  w  ww .  j  av a2s. c  o m*/
    Entry entry = new MediaEntry();

    GDataServiceClient client = getGDataServiceClient();
    String authToken = getAuthToken();
    ContentResolver cr = getContext().getContentResolver();
    final String account = getAccount();

    Cursor c = clientDiffs.query(Photos.CONTENT_URI, null /* all columns */, null /* no where */,
            null /* no where args */, null /* default sort order */);
    try {
        int personColumn = c.getColumnIndexOrThrow(Photos.PERSON_ID);
        int dataColumn = c.getColumnIndexOrThrow(Photos.DATA);
        int numRows = c.getCount();
        while (c.moveToNext()) {
            if (mSyncCanceled) {
                if (Config.LOGD)
                    Log.d(TAG, "stopping since the sync was canceled");
                break;
            }

            entry.clear();
            context.setStatusText("Updating, " + (numRows - 1) + " to go");

            cursorToBaseEntry(entry, account, c);
            String editUrl = entry.getEditUri();

            if (TextUtils.isEmpty(editUrl)) {
                if (Config.LOGD) {
                    Log.d(TAG, "skipping photo edit for unsynced contact");
                }
                continue;
            }

            // Send the request and receive the response
            InputStream inputStream = null;
            byte[] imageData = c.getBlob(dataColumn);
            if (imageData != null) {
                inputStream = new ByteArrayInputStream(imageData);
            }
            Uri photoUri = Uri.withAppendedPath(People.CONTENT_URI,
                    c.getString(personColumn) + "/" + Photos.CONTENT_DIRECTORY);
            try {
                if (inputStream != null) {
                    if (Log.isLoggable(TAG, Log.VERBOSE)) {
                        Log.v(TAG, "Updating photo " + entry.toString());
                    }
                    ++mPhotoUploads;
                    client.updateMediaEntry(editUrl, inputStream, IMAGE_MIME_TYPE, authToken);
                } else {
                    if (Log.isLoggable(TAG, Log.VERBOSE)) {
                        Log.v(TAG, "Deleting photo " + entry.toString());
                    }
                    client.deleteEntry(editUrl, authToken);
                }

                // Mark that this photo is no longer dirty. The next time we sync (which
                // should be soon), we will get the new version of the photo and whether
                // or not there is a new one to download (e.g. if we deleted our version
                // yet there is an evergreen version present).
                ContentValues values = new ContentValues();
                values.put(Photos.EXISTS_ON_SERVER, inputStream == null ? 0 : 1);
                values.put(Photos._SYNC_DIRTY, 0);
                if (cr.update(photoUri, values, null /* no where */, null /* no where args */) != 1) {
                    Log.e(TAG, "error updating photo " + photoUri + " with values " + values);
                    syncResult.stats.numParseExceptions++;
                } else {
                    syncResult.stats.numUpdates++;
                }
                continue;
            } catch (ParseException e) {
                Log.e(TAG, "parse error during update of " + ", skipping");
                syncResult.stats.numParseExceptions++;
            } catch (IOException e) {
                if (Config.LOGD) {
                    Log.d(TAG, "io error during update of " + entry.toString() + ", skipping");
                }
                syncResult.stats.numIoExceptions++;
            } catch (HttpException e) {
                switch (e.getStatusCode()) {
                case HttpException.SC_UNAUTHORIZED:
                    if (syncResult.stats.numAuthExceptions == 0) {
                        if (Config.LOGD) {
                            Log.d(TAG, "auth error during update of " + entry + ", skipping");
                        }
                    }
                    syncResult.stats.numAuthExceptions++;
                    try {
                        GoogleLoginServiceBlockingHelper.invalidateAuthToken(getContext(), authToken);
                    } catch (GoogleLoginServiceNotFoundException e1) {
                        if (Config.LOGD) {
                            Log.d(TAG, "could not invalidate auth token", e1);
                        }
                    }
                    return;

                case HttpException.SC_CONFLICT:
                    if (Config.LOGD) {
                        Log.d(TAG, "conflict detected during update of " + entry + ", skipping");
                    }
                    syncResult.stats.numConflictDetectedExceptions++;
                    break;
                case HttpException.SC_BAD_REQUEST:
                case HttpException.SC_FORBIDDEN:
                case HttpException.SC_NOT_FOUND:
                case HttpException.SC_INTERNAL_SERVER_ERROR:
                default:
                    if (Config.LOGD) {
                        Log.d(TAG, "error " + e.getMessage() + " during update of " + entry.toString()
                                + ", skipping");
                    }
                    syncResult.stats.numIoExceptions++;
                }
            }
        }
    } finally {
        c.close();
    }
}