Suppress the logging of URLs when in incognito mode.

Change-Id: Ib951b495eae15669e160ef54686eab0eeb9b366a
related-to-bug: 3336575
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
index 6bf6dd3..b3314be 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
@@ -33,8 +33,9 @@
 
 namespace android {
 
-NuPlayer::HTTPLiveSource::HTTPLiveSource(const char *url)
+NuPlayer::HTTPLiveSource::HTTPLiveSource(const char *url, uint32_t flags)
     : mURL(url),
+      mFlags(flags),
       mEOS(false),
       mOffset(0) {
 }
@@ -49,7 +50,9 @@
     mLiveLooper->setName("http live");
     mLiveLooper->start();
 
-    mLiveSession = new LiveSession;
+    mLiveSession = new LiveSession(
+            (mFlags & kFlagIncognito) ? LiveSession::kFlagIncognito : 0);
+
     mLiveLooper->registerHandler(mLiveSession);
 
     mLiveSession->connect(mURL.c_str());
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
index f3f539a..a8ce7f4 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
@@ -27,7 +27,11 @@
 struct LiveSession;
 
 struct NuPlayer::HTTPLiveSource : public NuPlayer::Source {
-    HTTPLiveSource(const char *url);
+    enum Flags {
+        // Don't log any URLs.
+        kFlagIncognito = 1,
+    };
+    HTTPLiveSource(const char *url, uint32_t flags = 0);
 
     virtual void start();
 
@@ -46,6 +50,7 @@
 
 private:
     AString mURL;
+    uint32_t mFlags;
     bool mEOS;
     off64_t mOffset;
     sp<ALooper> mLiveLooper;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 1fcf92b..fb87d82 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -71,7 +71,17 @@
         const char *url, const KeyedVector<String8, String8> *headers) {
     sp<AMessage> msg = new AMessage(kWhatSetDataSource, id());
 
-    msg->setObject("source", new HTTPLiveSource(url));
+    uint32_t flags = 0;
+
+    if (headers) {
+        ssize_t index = headers->indexOfKey(String8("x-hide-urls-from-log"));
+
+        if (index >= 0) {
+            flags |= HTTPLiveSource::kFlagIncognito;
+        }
+    }
+
+    msg->setObject("source", new HTTPLiveSource(url, flags));
     msg->post();
 }