diff options
author | Eric Erfanian <erfanian@google.com> | 2017-05-16 00:09:31 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-16 00:09:31 +0000 |
commit | c57430a61eab62e88372f386c75989dab6332608 (patch) | |
tree | b606f1899f80fcd0ea3ee753ce799883d5a673ab /java/com/android/contacts/common/list/DirectoryListLoader.java | |
parent | 9842b4a7fd1d852b1353af806da4913b4298d516 (diff) | |
parent | 0c9dbf507b53a12bdf577ff3e55c1686a2e089de (diff) |
Merge "Update Dialer to v10 RC32" into oc-dev
am: 0c9dbf507b
Change-Id: I5f90090090c6e430d83fcdd294082c1f5237ade8
Diffstat (limited to 'java/com/android/contacts/common/list/DirectoryListLoader.java')
-rw-r--r-- | java/com/android/contacts/common/list/DirectoryListLoader.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/java/com/android/contacts/common/list/DirectoryListLoader.java b/java/com/android/contacts/common/list/DirectoryListLoader.java index 48b098c07..be62cc7a8 100644 --- a/java/com/android/contacts/common/list/DirectoryListLoader.java +++ b/java/com/android/contacts/common/list/DirectoryListLoader.java @@ -25,9 +25,10 @@ import android.net.Uri; import android.os.Handler; import android.provider.ContactsContract.Directory; import android.text.TextUtils; -import android.util.Log; import com.android.contacts.common.R; import com.android.contacts.common.compat.DirectoryCompat; +import com.android.dialer.common.LogUtil; +import com.android.dialer.util.PermissionsUtil; /** A specialized loader for the list of directories, see {@link Directory}. */ public class DirectoryListLoader extends AsyncTaskLoader<Cursor> { @@ -38,7 +39,6 @@ public class DirectoryListLoader extends AsyncTaskLoader<Cursor> { public static final int SEARCH_MODE_DATA_SHORTCUT = 3; // This is a virtual column created for a MatrixCursor. public static final String DIRECTORY_TYPE = "directoryType"; - private static final String TAG = "ContactEntryListAdapter"; private static final String[] RESULT_PROJECTION = { Directory._ID, DIRECTORY_TYPE, Directory.DISPLAY_NAME, Directory.PHOTO_SUPPORT, }; @@ -71,7 +71,13 @@ public class DirectoryListLoader extends AsyncTaskLoader<Cursor> { @Override protected void onStartLoading() { - getContext().getContentResolver().registerContentObserver(DirectoryQuery.URI, false, mObserver); + if (PermissionsUtil.hasContactsReadPermissions(getContext())) { + getContext() + .getContentResolver() + .registerContentObserver(DirectoryQuery.URI, false, mObserver); + } else { + LogUtil.w("DirectoryListLoader.onStartLoading", "contacts permission not available."); + } forceLoad(); } @@ -141,7 +147,9 @@ public class DirectoryListLoader extends AsyncTaskLoader<Cursor> { try { directoryType = pm.getResourcesForApplication(packageName).getString(typeResourceId); } catch (Exception e) { - Log.e(TAG, "Cannot obtain directory type from package: " + packageName); + LogUtil.e( + "ContactEntryListAdapter.loadInBackground", + "cannot obtain directory type from package: " + packageName); } } String displayName = cursor.getString(DirectoryQuery.DISPLAY_NAME); @@ -149,7 +157,8 @@ public class DirectoryListLoader extends AsyncTaskLoader<Cursor> { result.addRow(new Object[] {directoryId, directoryType, displayName, photoSupport}); } } catch (RuntimeException e) { - Log.w(TAG, "Runtime Exception when querying directory"); + LogUtil.w( + "ContactEntryListAdapter.loadInBackground", "runtime exception when querying directory"); } finally { if (cursor != null) { cursor.close(); |