Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86903bb8 authored by Wenyi Wang's avatar Wenyi Wang Committed by Android (Google) Code Review
Browse files

Merge "Add isLoggable checks to all verbose and debug log outputs (1/2)" into...

Merge "Add isLoggable checks to all verbose and debug log outputs (1/2)" into ub-contactsdialer-i-dev
parents 156fc9f6 57a0e98e
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -1425,8 +1425,10 @@ class ContactPhotoManagerImpl extends ContactPhotoManager implements Callback {
                mPreloadStatus = PRELOAD_STATUS_DONE;
            }

            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Preloaded " + count + " photos.  Cached bytes: "
                        + mBitmapHolderCache.size());
            }

            requestPreloading();
        }
@@ -1609,11 +1611,15 @@ class ContactPhotoManagerImpl extends ContactPhotoManager implements Callback {
                                uriRequest.getRequestedExtent());
                        mMainThreadHandler.sendEmptyMessage(MESSAGE_PHOTOS_LOADED);
                    } else {
                        if (Log.isLoggable(TAG, Log.VERBOSE)) {
                            Log.v(TAG, "Cannot load photo " + uri);
                        }
                        cacheBitmap(originalUri, null, false, uriRequest.getRequestedExtent());
                    }
                } catch (final Exception | OutOfMemoryError ex) {
                    if (Log.isLoggable(TAG, Log.VERBOSE)) {
                        Log.v(TAG, "Cannot load photo " + uri, ex);
                    }
                    cacheBitmap(originalUri, null, false, uriRequest.getRequestedExtent());
                }
            }
+4 −2
Original line number Diff line number Diff line
@@ -304,7 +304,9 @@ public class ContactSaveService extends IntentService {
    @Override
    protected void onHandleIntent(final Intent intent) {
        if (intent == null) {
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "onHandleIntent: could not handle null intent");
            }
            return;
        }
        if (!PermissionsUtil.hasPermission(this, WRITE_CONTACTS)) {
@@ -578,7 +580,7 @@ public class ContactSaveService extends IntentService {
                                    rawContactId);
                    lookupUri = RawContacts.getContactLookupUri(resolver, rawContactUri);
                }
                if (lookupUri != null) {
                if (lookupUri != null && Log.isLoggable(TAG, Log.VERBOSE)) {
                    Log.v(TAG, "Saved contact. New URI: " + lookupUri);
                }

+3 −1
Original line number Diff line number Diff line
@@ -337,7 +337,9 @@ public class AttachPhotoActivity extends ContactsActivity {
        values.setPhoto(compressed);

        // Finally, invoke the ContactSaveService.
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "all prerequisites met, about to save photo to contact");
        }
        Intent intent = ContactSaveService.createSaveContactIntent(
                this,
                deltaList,
+6 −2
Original line number Diff line number Diff line
@@ -227,7 +227,9 @@ public final class CompatUtils {
            Class.forName(className).getMethod(methodName, parameterTypes);
            return true;
        } catch (ClassNotFoundException | NoSuchMethodException e) {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Could not find method: " + className + "#" + methodName);
            }
            return false;
        } catch (Throwable t) {
            Log.e(TAG, "Unexpected exception when checking if method: " + className + "#"
@@ -260,7 +262,9 @@ public final class CompatUtils {
                    .invoke(instance, parameters);
        } catch (ClassNotFoundException | NoSuchMethodException | IllegalArgumentException
                | IllegalAccessException | InvocationTargetException e) {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Could not invoke method: " + className + "#" + methodName);
            }
            return null;
        } catch (Throwable t) {
            Log.e(TAG, "Unexpected exception when invoking method: " + className
+21 −7
Original line number Diff line number Diff line
@@ -255,11 +255,15 @@ public class ContactDisplayUtils {
            try {
                uri = Uri.parse(source);
            } catch (Throwable e) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Could not parse image source: " + source);
                }
                return null;
            }
            if (!RES_SCHEME.equals(uri.getScheme())) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Image source does not correspond to a resource: " + source);
                }
                return null;
            }
            // The URI authority represents the package name.
@@ -267,13 +271,17 @@ public class ContactDisplayUtils {

            Resources resources = getResourcesForResourceName(packageName);
            if (resources == null) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Could not parse image source: " + source);
                }
                return null;
            }

            List<String> pathSegments = uri.getPathSegments();
            if (pathSegments.size() != 1) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Could not parse image source: " + source);
                }
                return null;
            }

@@ -282,14 +290,18 @@ public class ContactDisplayUtils {

            if (resId == 0) {
                // Use the default image icon in this case.
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Cannot resolve resource identifier: " + source);
                }
                return null;
            }

            try {
                return getResourceDrawable(resources, resId);
            } catch (NotFoundException e) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Resource not found: " + source, e);
                }
                return null;
            }
        }
@@ -307,7 +319,9 @@ public class ContactDisplayUtils {
            try {
                return mPackageManager.getResourcesForApplication(packageName);
            } catch (NameNotFoundException e) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Could not find package: " + packageName);
                }
                return null;
            }
        }
Loading