Add TrafficStatsTag to ContactPhotoManager

Bug: 21423350
Change-Id: I50ee4993a95d7f81229dacd2ae0be4a5c16ce2cf
diff --git a/src/com/android/contacts/common/ContactPhotoManager.java b/src/com/android/contacts/common/ContactPhotoManager.java
index 7a8f138..fbdac5d 100644
--- a/src/com/android/contacts/common/ContactPhotoManager.java
+++ b/src/com/android/contacts/common/ContactPhotoManager.java
@@ -34,6 +34,7 @@
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.TransitionDrawable;
 import android.media.ThumbnailUtils;
+import android.net.TrafficStats;
 import android.net.Uri;
 import android.net.Uri.Builder;
 import android.os.Handler;
@@ -57,6 +58,7 @@
 import com.android.contacts.common.lettertiles.LetterTileDrawable;
 import com.android.contacts.common.util.BitmapUtil;
 import com.android.contacts.common.util.PermissionsUtil;
+import com.android.contacts.common.util.TrafficStatsTags;
 import com.android.contacts.common.util.UriUtils;
 import com.android.contacts.commonbind.util.UserAgentGenerator;
 
@@ -1559,6 +1561,7 @@
                     final String scheme = uri.getScheme();
                     InputStream is = null;
                     if (scheme.equals("http") || scheme.equals("https")) {
+                        TrafficStats.setThreadStatsTag(TrafficStatsTags.CONTACT_PHOTO_DOWNLOAD_TAG);
                         final HttpURLConnection connection =
                                 (HttpURLConnection) new URL(uri.toString()).openConnection();
 
@@ -1572,6 +1575,7 @@
                             connection.disconnect();
                             is = null;
                         }
+                        TrafficStats.clearThreadStatsTag();
                     } else {
                         is = mResolver.openInputStream(uri);
                     }
diff --git a/src/com/android/contacts/common/util/TrafficStatsTags.java b/src/com/android/contacts/common/util/TrafficStatsTags.java
new file mode 100644
index 0000000..78faa94
--- /dev/null
+++ b/src/com/android/contacts/common/util/TrafficStatsTags.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.contacts.common.util;
+
+public class TrafficStatsTags {
+    public static final int CONTACT_PHOTO_DOWNLOAD_TAG = 0x0001;
+    public static final int TAG_MAX = 0x9999;
+}