Suppress the logging of URLs when in incognito mode.

Change-Id: Ib951b495eae15669e160ef54686eab0eeb9b366a
related-to-bug: 3336575
This commit is contained in:
Andreas Huber
2011-02-24 14:42:48 -08:00
parent 7b76c8d3fc
commit 53182c439c
10 changed files with 77 additions and 15 deletions

View File

@@ -33,7 +33,6 @@ status_t StagefrightPlayer::initCheck() {
status_t StagefrightPlayer::setDataSource(
const char *url, const KeyedVector<String8, String8> *headers) {
LOGI("setDataSource('%s')", url);
return mPlayer->setDataSource(url, headers);
}

View File

@@ -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 @@ void NuPlayer::HTTPLiveSource::start() {
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());

View File

@@ -27,7 +27,11 @@ struct ATSParser;
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 @@ protected:
private:
AString mURL;
uint32_t mFlags;
bool mEOS;
off64_t mOffset;
sp<ALooper> mLiveLooper;

View File

@@ -71,7 +71,17 @@ void NuPlayer::setDataSource(
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();
}

View File

@@ -245,6 +245,22 @@ status_t AwesomePlayer::setDataSource_l(
if (headers) {
mUriHeaders = *headers;
ssize_t index = mUriHeaders.indexOfKey(String8("x-hide-urls-from-log"));
if (index >= 0) {
// Browser is in "incognito" mode, suppress logging URLs.
// This isn't something that should be passed to the server.
mUriHeaders.removeItemsAt(index);
mFlags |= INCOGNITO;
}
}
if (!(mFlags & INCOGNITO)) {
LOGI("setDataSource_l('%s')", mUri.string());
} else {
LOGI("setDataSource_l(URL suppressed)");
}
// The actual work will be done during preparation in the call to
@@ -1525,7 +1541,8 @@ status_t AwesomePlayer::finishSetDataSource_l() {
if (!strncasecmp("http://", mUri.string(), 7)
|| !strncasecmp("https://", mUri.string(), 8)) {
mConnectingDataSource = new NuHTTPDataSource;
mConnectingDataSource = new NuHTTPDataSource(
(mFlags & INCOGNITO) ? NuHTTPDataSource::kFlagIncognito : 0);
mLock.unlock();
status_t err = mConnectingDataSource->connect(mUri, &mUriHeaders);

View File

@@ -71,8 +71,9 @@ static bool ParseURL(
return true;
}
NuHTTPDataSource::NuHTTPDataSource()
: mState(DISCONNECTED),
NuHTTPDataSource::NuHTTPDataSource(uint32_t flags)
: mFlags(flags),
mState(DISCONNECTED),
mPort(0),
mHTTPS(false),
mOffset(0),
@@ -138,7 +139,11 @@ status_t NuHTTPDataSource::connect(
bool https,
const String8 &headers,
off64_t offset) {
LOGI("connect to %s:%u%s @%lld", host, port, path, offset);
if (!(mFlags & kFlagIncognito)) {
LOGI("connect to %s:%u%s @%lld", host, port, path, offset);
} else {
LOGI("connect to <URL suppressed> @%lld", offset);
}
bool needsToReconnect = true;

View File

@@ -41,9 +41,14 @@ namespace android {
const int64_t LiveSession::kMaxPlaylistAgeUs = 15000000ll;
LiveSession::LiveSession()
: mDataSource(new LiveDataSource),
mHTTPDataSource(new NuHTTPDataSource),
LiveSession::LiveSession(uint32_t flags)
: mFlags(flags),
mDataSource(new LiveDataSource),
mHTTPDataSource(
new NuHTTPDataSource(
(mFlags & kFlagIncognito)
? NuHTTPDataSource::kFlagIncognito
: 0)),
mPrevBandwidthIndex(-1),
mLastPlaylistFetchTimeUs(-1),
mSeqNumber(-1),
@@ -139,7 +144,11 @@ void LiveSession::onConnect(const sp<AMessage> &msg) {
AString url;
CHECK(msg->findString("url", &url));
LOGI("onConnect '%s'", url.c_str());
if (!(mFlags & kFlagIncognito)) {
LOGI("onConnect '%s'", url.c_str());
} else {
LOGI("onConnect <URL suppressed>");
}
mMasterURL = url;

View File

@@ -122,6 +122,8 @@ private:
AUDIO_RUNNING = 8192,
AUDIOPLAYER_STARTED = 16384,
INCOGNITO = 32768,
};
mutable Mutex mLock;

View File

@@ -29,7 +29,11 @@ struct M3UParser;
struct NuHTTPDataSource;
struct LiveSession : public AHandler {
LiveSession();
enum Flags {
// Don't log any URLs.
kFlagIncognito = 1,
};
LiveSession(uint32_t flags = 0);
sp<DataSource> getDataSource();
@@ -67,6 +71,8 @@ private:
unsigned long mBandwidth;
};
uint32_t mFlags;
sp<LiveDataSource> mDataSource;
sp<NuHTTPDataSource> mHTTPDataSource;

View File

@@ -12,7 +12,11 @@
namespace android {
struct NuHTTPDataSource : public DataSource {
NuHTTPDataSource();
enum Flags {
// Don't log any URLs.
kFlagIncognito = 1
};
NuHTTPDataSource(uint32_t flags = 0);
status_t connect(
const char *uri,
@@ -52,6 +56,8 @@ private:
Mutex mLock;
uint32_t mFlags;
State mState;
String8 mHost;