Bug 1073081 - Fix warnings about macro redefinitions by renaming macros. r=ehsan

--HG--
extra : source : 18294144de5ff84e3a88945f7222e6eb8bbfcb34
This commit is contained in:
Botond Ballo 2014-12-10 18:20:10 -05:00
parent 81a74c44a2
commit b273018bde
7 changed files with 90 additions and 95 deletions

View File

@ -20,9 +20,8 @@
#include <stagefright/foundation/ALooper.h>
#include "media/openmax/OMX_Audio.h"
#define LOG_TAG "GonkAudioDecoderManager"
#include <android/log.h>
#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define GADM_LOG(...) __android_log_print(ANDROID_LOG_DEBUG, "GonkAudioDecoderManager", __VA_ARGS__)
#ifdef PR_LOGGING
PRLogModuleInfo* GetDemuxerLog();
@ -77,7 +76,7 @@ GonkAudioDecoderManager::Init(MediaDataDecoderCallback* aCallback)
}
sp<AMessage> format = new AMessage;
// Fixed values
ALOG("Init Audio channel no:%d, sample-rate:%d", mAudioChannels, mAudioRate);
GADM_LOG("Init Audio channel no:%d, sample-rate:%d", mAudioChannels, mAudioRate);
format->setString("mime", "audio/mp4a-latm");
format->setInt32("channel-count", mAudioChannels);
format->setInt32("sample-rate", mAudioRate);
@ -93,7 +92,7 @@ GonkAudioDecoderManager::Init(MediaDataDecoderCallback* aCallback)
if (rv == OK) {
return mDecoder;
} else {
ALOG("Failed to input codec specific data!");
GADM_LOG("Failed to input codec specific data!");
return nullptr;
}
}
@ -101,7 +100,7 @@ GonkAudioDecoderManager::Init(MediaDataDecoderCallback* aCallback)
nsresult
GonkAudioDecoderManager::CreateAudioData(int64_t aStreamOffset, AudioData **v) {
if (!(mAudioBuffer != nullptr && mAudioBuffer->data() != nullptr)) {
ALOG("Audio Buffer is not valid!");
GADM_LOG("Audio Buffer is not valid!");
return NS_ERROR_UNEXPECTED;
}
@ -167,7 +166,7 @@ GonkAudioDecoderManager::Output(int64_t aStreamOffset,
case android::INFO_OUTPUT_BUFFERS_CHANGED:
{
// If the format changed, update our cached info.
ALOG("Decoder format changed");
GADM_LOG("Decoder format changed");
return Output(aStreamOffset, aOutData);
}
case -EAGAIN:
@ -176,14 +175,14 @@ GonkAudioDecoderManager::Output(int64_t aStreamOffset,
}
case android::ERROR_END_OF_STREAM:
{
ALOG("Got EOS frame!");
GADM_LOG("Got EOS frame!");
nsRefPtr<AudioData> data;
nsresult rv = CreateAudioData(aStreamOffset, getter_AddRefs(data));
if (rv == NS_ERROR_NOT_AVAILABLE) {
// For EOS, no need to do any thing.
return NS_ERROR_ABORT;
} else if (rv != NS_OK || data == nullptr) {
ALOG("Failed to create audio data!");
GADM_LOG("Failed to create audio data!");
return NS_ERROR_UNEXPECTED;
}
aOutData = data;
@ -191,12 +190,12 @@ GonkAudioDecoderManager::Output(int64_t aStreamOffset,
}
case -ETIMEDOUT:
{
ALOG("Timeout. can try again next time");
GADM_LOG("Timeout. can try again next time");
return NS_ERROR_UNEXPECTED;
}
default:
{
ALOG("Decoder failed, err=%d", err);
GADM_LOG("Decoder failed, err=%d", err);
return NS_ERROR_UNEXPECTED;
}
}
@ -221,7 +220,7 @@ nsresult
GonkAudioDecoderManager::Input(mp4_demuxer::MP4Sample* aSample)
{
if (mDecoder == nullptr) {
ALOG("Decoder is not inited");
GADM_LOG("Decoder is not inited");
return NS_ERROR_UNEXPECTED;
}
if (aSample && mUseAdts) {
@ -232,7 +231,7 @@ GonkAudioDecoderManager::Input(mp4_demuxer::MP4Sample* aSample)
mAudioProfile,
aSample);
if (!rv) {
ALOG("Failed to apply ADTS header");
GADM_LOG("Failed to apply ADTS header");
return NS_ERROR_FAILURE;
}
}

View File

@ -10,9 +10,8 @@
#include "MediaCodecProxy.h"
#include "prlog.h"
#define LOG_TAG "GonkMediaDataDecoder(blake)"
#include <android/log.h>
#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define GMDD_LOG(...) __android_log_print(ANDROID_LOG_DEBUG, "GonkMediaDataDecoder(blake)", __VA_ARGS__)
#ifdef PR_LOGGING
PRLogModuleInfo* GetDemuxerLog();
@ -76,7 +75,7 @@ GonkMediaDataDecoder::ProcessDecode(mp4_demuxer::MP4Sample* aSample)
nsresult rv = mManager->Input(aSample);
if (rv != NS_OK) {
NS_WARNING("GonkAudioDecoder failed to input data");
ALOG("Failed to input data err: %d",rv);
GMDD_LOG("Failed to input data err: %d",rv);
mCallback->Error();
return;
}
@ -111,7 +110,7 @@ GonkMediaDataDecoder::ProcessOutput()
}
if (rv != NS_OK) {
NS_WARNING("GonkMediaDataDecoder failed to output data");
ALOG("Failed to output data");
GMDD_LOG("Failed to output data");
// GonkDecoderManangers report NS_ERROR_ABORT when EOS is reached.
if (rv == NS_ERROR_ABORT) {
if (output) {

View File

@ -29,9 +29,8 @@
#define READ_OUTPUT_BUFFER_TIMEOUT_US 3000
#define LOG_TAG "GonkVideoDecoderManager"
#include <android/log.h>
#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define GVDM_LOG(...) __android_log_print(ANDROID_LOG_DEBUG, "GonkVideoDecoderManager", __VA_ARGS__)
#ifdef PR_LOGGING
PRLogModuleInfo* GetDemuxerLog();
@ -93,7 +92,7 @@ GonkVideoDecoderManager::Init(MediaDataDecoderCallback* aCallback)
// that our video frame creation code doesn't overflow.
nsIntSize frameSize(mVideoWidth, mVideoHeight);
if (!IsValidVideoRegion(frameSize, pictureRect, displaySize)) {
ALOG("It is not a valid region");
GVDM_LOG("It is not a valid region");
return nullptr;
}
@ -175,12 +174,12 @@ GonkVideoDecoderManager::CreateVideoData(int64_t aStreamOffset, VideoData **v)
int32_t keyFrame;
if (mVideoBuffer == nullptr) {
ALOG("Video Buffer is not valid!");
GVDM_LOG("Video Buffer is not valid!");
return NS_ERROR_UNEXPECTED;
}
if (!mVideoBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
ALOG("Decoder did not return frame time");
GVDM_LOG("Decoder did not return frame time");
return NS_ERROR_UNEXPECTED;
}
@ -234,7 +233,7 @@ GonkVideoDecoderManager::CreateVideoData(int64_t aStreamOffset, VideoData **v)
picture);
} else {
if (!mVideoBuffer->data()) {
ALOG("No data in Video Buffer!");
GVDM_LOG("No data in Video Buffer!");
return NS_ERROR_UNEXPECTED;
}
uint8_t *yuv420p_buffer = (uint8_t *)mVideoBuffer->data();
@ -252,7 +251,7 @@ GonkVideoDecoderManager::CreateVideoData(int64_t aStreamOffset, VideoData **v)
if (mColorConverter.convertDecoderOutputToI420(mVideoBuffer->data(),
mFrameInfo.mWidth, mFrameInfo.mHeight, crop, yuv420p_buffer) != OK) {
ReleaseVideoBuffer();
ALOG("Color conversion failed!");
GVDM_LOG("Color conversion failed!");
return NS_ERROR_UNEXPECTED;
}
stride = mFrameInfo.mWidth;
@ -330,7 +329,7 @@ GonkVideoDecoderManager::SetVideoFormat()
!codecFormat->findInt32("slice-height", &slice_height) ||
!codecFormat->findInt32("color-format", &color_format) ||
!codecFormat->findRect("crop", &crop_left, &crop_top, &crop_right, &crop_bottom)) {
ALOG("Failed to find values");
GVDM_LOG("Failed to find values");
return false;
}
mFrameInfo.mWidth = width;
@ -341,12 +340,12 @@ GonkVideoDecoderManager::SetVideoFormat()
nsIntSize displaySize(width, height);
if (!IsValidVideoRegion(mInitialFrame, mPicture, displaySize)) {
ALOG("It is not a valid region");
GVDM_LOG("It is not a valid region");
return false;
}
return true;
}
ALOG("Fail to get output format");
GVDM_LOG("Fail to get output format");
return false;
}
@ -358,7 +357,7 @@ GonkVideoDecoderManager::Output(int64_t aStreamOffset,
aOutData = nullptr;
status_t err;
if (mDecoder == nullptr) {
ALOG("Decoder is not inited");
GVDM_LOG("Decoder is not inited");
return NS_ERROR_UNEXPECTED;
}
err = mDecoder->Output(&mVideoBuffer, READ_OUTPUT_BUFFER_TIMEOUT_US);
@ -372,7 +371,7 @@ GonkVideoDecoderManager::Output(int64_t aStreamOffset,
// Decoder outputs a empty video buffer, try again
return NS_ERROR_NOT_AVAILABLE;
} else if (rv != NS_OK || data == nullptr) {
ALOG("Failed to create VideoData");
GVDM_LOG("Failed to create VideoData");
return NS_ERROR_UNEXPECTED;
}
aOutData = data;
@ -381,7 +380,7 @@ GonkVideoDecoderManager::Output(int64_t aStreamOffset,
case android::INFO_FORMAT_CHANGED:
{
// If the format changed, update our cached info.
ALOG("Decoder format changed");
GVDM_LOG("Decoder format changed");
if (!SetVideoFormat()) {
return NS_ERROR_UNEXPECTED;
}
@ -400,7 +399,7 @@ GonkVideoDecoderManager::Output(int64_t aStreamOffset,
}
case android::ERROR_END_OF_STREAM:
{
ALOG("Got the EOS frame!");
GVDM_LOG("Got the EOS frame!");
nsRefPtr<VideoData> data;
nsresult rv = CreateVideoData(aStreamOffset, getter_AddRefs(data));
if (rv == NS_ERROR_NOT_AVAILABLE) {
@ -408,7 +407,7 @@ GonkVideoDecoderManager::Output(int64_t aStreamOffset,
return NS_ERROR_ABORT;
}
if (rv != NS_OK || data == nullptr) {
ALOG("Failed to create video data");
GVDM_LOG("Failed to create video data");
return NS_ERROR_UNEXPECTED;
}
aOutData = data;
@ -416,12 +415,12 @@ GonkVideoDecoderManager::Output(int64_t aStreamOffset,
}
case -ETIMEDOUT:
{
ALOG("Timeout. can try again next time");
GVDM_LOG("Timeout. can try again next time");
return NS_ERROR_UNEXPECTED;
}
default:
{
ALOG("Decoder failed, err=%d", err);
GVDM_LOG("Decoder failed, err=%d", err);
return NS_ERROR_UNEXPECTED;
}
}
@ -440,7 +439,7 @@ nsresult
GonkVideoDecoderManager::Input(mp4_demuxer::MP4Sample* aSample)
{
if (mDecoder == nullptr) {
ALOG("Decoder is not inited");
GVDM_LOG("Decoder is not inited");
return NS_ERROR_UNEXPECTED;
}
status_t rv;
@ -519,7 +518,7 @@ GonkVideoDecoderManager::onMessageReceived(const sp<AMessage> &aMessage)
{
// Our decode may have acquired the hardware resource that it needs
// to start. Notify the state machine to resume loading metadata.
ALOG("CodecReserved!");
GVDM_LOG("CodecReserved!");
mReaderCallback->NotifyResourcesStatusChanged();
break;
}
@ -650,7 +649,7 @@ void GonkVideoDecoderManager::ReleaseAllPendingVideoBuffers()
}
void GonkVideoDecoderManager::ReleaseMediaResources() {
ALOG("ReleseMediaResources");
GVDM_LOG("ReleseMediaResources");
ReleaseAllPendingVideoBuffers();
mDecoder->ReleaseMediaResources();
}

View File

@ -11,7 +11,7 @@
#include "mozilla/unused.h"
#include <android/log.h>
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "NfcMessageHandler", args)
#define NMH_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "NfcMessageHandler", args)
using namespace android;
using namespace mozilla;
@ -133,7 +133,7 @@ NfcMessageHandler::GeneralResponse(const Parcel& aParcel, EventOptions& aOptions
type = kCloseResponse;
break;
default:
CHROMIUM_LOG("Nfcd, unknown general response %d", pendingReq);
NMH_LOG("Nfcd, unknown general response %d", pendingReq);
return false;
}
@ -254,7 +254,7 @@ NfcMessageHandler::InitializeNotification(const Parcel& aParcel, EventOptions& a
if (aOptions.mMajorVersion != NFCD_MAJOR_VERSION ||
aOptions.mMinorVersion != NFCD_MINOR_VERSION) {
CHROMIUM_LOG("NFCD version mismatched. majorVersion: %d, minorVersion: %d",
NMH_LOG("NFCD version mismatched. majorVersion: %d, minorVersion: %d",
aOptions.mMajorVersion, aOptions.mMinorVersion);
}

View File

@ -33,9 +33,9 @@
#define ERROR(args...) __android_log_print(ANDROID_LOG_ERROR, "NetworkUtils", ## args)
#if _DEBUG
#define DEBUG(args...) __android_log_print(ANDROID_LOG_DEBUG, "NetworkUtils" , ## args)
#define NU_DBG(args...) __android_log_print(ANDROID_LOG_DEBUG, "NetworkUtils" , ## args)
#else
#define DEBUG(args...)
#define NU_DBG(args...)
#endif
using namespace mozilla::dom;
@ -452,7 +452,7 @@ void NetworkUtils::nextNetdCommand()
gCurrentCommand.callback = GET_CURRENT_CALLBACK;
snprintf(gCurrentCommand.command, MAX_COMMAND_SIZE - 1, "%s", GET_CURRENT_COMMAND);
DEBUG("Sending \'%s\' command to netd.", gCurrentCommand.command);
NU_DBG("Sending \'%s\' command to netd.", gCurrentCommand.command);
SendNetdCommand(GET_CURRENT_NETD_COMMAND);
gCommandQueue.RemoveElementAt(0);
@ -469,7 +469,7 @@ void NetworkUtils::nextNetdCommand()
*/
void NetworkUtils::doCommand(const char* aCommand, CommandChain* aChain, CommandCallback aCallback)
{
DEBUG("Preparing to send \'%s\' command...", aCommand);
NU_DBG("Preparing to send \'%s\' command...", aCommand);
NetdCommand* netdCommand = new NetdCommand();
@ -1175,8 +1175,8 @@ void NetworkUtils::onNetdMessage(NetdCommand* aCommand)
char* reason = strtok(nullptr, "\0");
if (isBroadcastMessage(code)) {
DEBUG("Receiving broadcast message from netd.");
DEBUG(" ==> Code: %d Reason: %s", code, reason);
NU_DBG("Receiving broadcast message from netd.");
NU_DBG(" ==> Code: %d Reason: %s", code, reason);
sendBroadcastMessage(code, reason);
if (code == NETD_COMMAND_INTERFACE_CHANGE) {
@ -1187,7 +1187,7 @@ void NetworkUtils::onNetdMessage(NetdCommand* aCommand)
NS_ConvertUTF16toUTF8(gWifiTetheringParms->mIfname).get());
if (!strcmp(reason, linkdownReason)) {
DEBUG("Wifi link down, restarting tethering.");
NU_DBG("Wifi link down, restarting tethering.");
RUN_CHAIN(*gWifiTetheringParms, sWifiRetryChain, wifiTetheringFail)
}
}
@ -1198,8 +1198,8 @@ void NetworkUtils::onNetdMessage(NetdCommand* aCommand)
}
// Set pending to false before we handle next command.
DEBUG("Receiving \"%s\" command response from netd.", gCurrentCommand.command);
DEBUG(" ==> Code: %d Reason: %s", code, reason);
NU_DBG("Receiving \"%s\" command response from netd.", gCurrentCommand.command);
NU_DBG(" ==> Code: %d Reason: %s", code, reason);
gReason.AppendElement(nsCString(reason));
@ -1599,21 +1599,21 @@ CommandResult NetworkUtils::removeSecondaryRoute(NetworkParams& aOptions)
CommandResult NetworkUtils::setNetworkInterfaceAlarm(NetworkParams& aOptions)
{
DEBUG("setNetworkInterfaceAlarms: %s", GET_CHAR(mIfname));
NU_DBG("setNetworkInterfaceAlarms: %s", GET_CHAR(mIfname));
RUN_CHAIN(aOptions, sNetworkInterfaceSetAlarmChain, networkInterfaceAlarmFail);
return CommandResult::Pending();
}
CommandResult NetworkUtils::enableNetworkInterfaceAlarm(NetworkParams& aOptions)
{
DEBUG("enableNetworkInterfaceAlarm: %s", GET_CHAR(mIfname));
NU_DBG("enableNetworkInterfaceAlarm: %s", GET_CHAR(mIfname));
RUN_CHAIN(aOptions, sNetworkInterfaceEnableAlarmChain, networkInterfaceAlarmFail);
return CommandResult::Pending();
}
CommandResult NetworkUtils::disableNetworkInterfaceAlarm(NetworkParams& aOptions)
{
DEBUG("disableNetworkInterfaceAlarms: %s", GET_CHAR(mIfname));
NU_DBG("disableNetworkInterfaceAlarms: %s", GET_CHAR(mIfname));
RUN_CHAIN(aOptions, sNetworkInterfaceDisableAlarmChain, networkInterfaceAlarmFail);
return CommandResult::Pending();
}
@ -1623,7 +1623,7 @@ CommandResult NetworkUtils::disableNetworkInterfaceAlarm(NetworkParams& aOptions
*/
CommandResult NetworkUtils::setWifiOperationMode(NetworkParams& aOptions)
{
DEBUG("setWifiOperationMode: %s %s", GET_CHAR(mIfname), GET_CHAR(mMode));
NU_DBG("setWifiOperationMode: %s %s", GET_CHAR(mIfname), GET_CHAR(mMode));
RUN_CHAIN(aOptions, sWifiOperationModeChain, wifiOperationModeFail);
return CommandResult::Pending();
}
@ -1652,11 +1652,11 @@ CommandResult NetworkUtils::setWifiTethering(NetworkParams& aOptions)
dumpParams(aOptions, "WIFI");
if (enable) {
DEBUG("Starting Wifi Tethering on %s <-> %s",
NU_DBG("Starting Wifi Tethering on %s <-> %s",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
RUN_CHAIN(aOptions, sWifiEnableChain, wifiTetheringFail)
} else {
DEBUG("Stopping Wifi Tethering on %s <-> %s",
NU_DBG("Stopping Wifi Tethering on %s <-> %s",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
RUN_CHAIN(aOptions, sWifiDisableChain, wifiTetheringFail)
}
@ -1684,11 +1684,11 @@ CommandResult NetworkUtils::setUSBTethering(NetworkParams& aOptions)
dumpParams(aOptions, "USB");
if (enable) {
DEBUG("Starting USB Tethering on %s <-> %s",
NU_DBG("Starting USB Tethering on %s <-> %s",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
RUN_CHAIN(aOptions, sUSBEnableChain, usbTetheringFail)
} else {
DEBUG("Stopping USB Tethering on %s <-> %s",
NU_DBG("Stopping USB Tethering on %s <-> %s",
GET_CHAR(mInternalIfname), GET_CHAR(mExternalIfname));
RUN_CHAIN(aOptions, sUSBDisableChain, usbTetheringFail)
}
@ -1855,24 +1855,24 @@ inline bool NetworkUtils::isProceeding(uint32_t code)
void NetworkUtils::dumpParams(NetworkParams& aOptions, const char* aType)
{
#ifdef _DEBUG
DEBUG("Dump params:");
DEBUG(" ifname: %s", GET_CHAR(mIfname));
DEBUG(" ip: %s", GET_CHAR(mIp));
DEBUG(" link: %s", GET_CHAR(mLink));
DEBUG(" prefix: %s", GET_CHAR(mPrefix));
DEBUG(" wifiStartIp: %s", GET_CHAR(mWifiStartIp));
DEBUG(" wifiEndIp: %s", GET_CHAR(mWifiEndIp));
DEBUG(" usbStartIp: %s", GET_CHAR(mUsbStartIp));
DEBUG(" usbEndIp: %s", GET_CHAR(mUsbEndIp));
DEBUG(" dnsserver1: %s", GET_CHAR(mDns1));
DEBUG(" dnsserver2: %s", GET_CHAR(mDns2));
DEBUG(" internalIfname: %s", GET_CHAR(mInternalIfname));
DEBUG(" externalIfname: %s", GET_CHAR(mExternalIfname));
NU_DBG("Dump params:");
NU_DBG(" ifname: %s", GET_CHAR(mIfname));
NU_DBG(" ip: %s", GET_CHAR(mIp));
NU_DBG(" link: %s", GET_CHAR(mLink));
NU_DBG(" prefix: %s", GET_CHAR(mPrefix));
NU_DBG(" wifiStartIp: %s", GET_CHAR(mWifiStartIp));
NU_DBG(" wifiEndIp: %s", GET_CHAR(mWifiEndIp));
NU_DBG(" usbStartIp: %s", GET_CHAR(mUsbStartIp));
NU_DBG(" usbEndIp: %s", GET_CHAR(mUsbEndIp));
NU_DBG(" dnsserver1: %s", GET_CHAR(mDns1));
NU_DBG(" dnsserver2: %s", GET_CHAR(mDns2));
NU_DBG(" internalIfname: %s", GET_CHAR(mInternalIfname));
NU_DBG(" externalIfname: %s", GET_CHAR(mExternalIfname));
if (!strcmp(aType, "WIFI")) {
DEBUG(" wifictrlinterfacename: %s", GET_CHAR(mWifictrlinterfacename));
DEBUG(" ssid: %s", GET_CHAR(mSsid));
DEBUG(" security: %s", GET_CHAR(mSecurity));
DEBUG(" key: %s", GET_CHAR(mKey));
NU_DBG(" wifictrlinterfacename: %s", GET_CHAR(mWifictrlinterfacename));
NU_DBG(" ssid: %s", GET_CHAR(mSsid));
NU_DBG(" security: %s", GET_CHAR(mSecurity));
NU_DBG(" key: %s", GET_CHAR(mKey));
}
#endif
}

View File

@ -10,12 +10,11 @@
#include <sys/stat.h>
#include <sys/types.h>
#undef CHROMIUM_LOG
#if defined(MOZ_WIDGET_GONK)
#include <android/log.h>
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
#define KEYSTORE_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
#else
#define CHROMIUM_LOG(args...) printf(args);
#define KEYSTORE_LOG(args...) printf(args);
#endif
#include "KeyStore.h"

View File

@ -18,8 +18,7 @@
#include "nsThreadUtils.h"
#include "mozilla/RefPtr.h"
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
#define NETD_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
#define ICS_SYS_USB_RNDIS_MAC "/sys/class/android_usb/android0/f_rndis/ethaddr"
#define INVALID_SOCKET -1
#define MAX_RECONNECT_TIMES 10
@ -54,7 +53,7 @@ InitRndisAddress()
fd.rwget() = open(ICS_SYS_USB_RNDIS_MAC, O_WRONLY);
if (fd.rwget() == -1) {
CHROMIUM_LOG("Unable to open file %s.", ICS_SYS_USB_RNDIS_MAC);
NETD_LOG("Unable to open file %s.", ICS_SYS_USB_RNDIS_MAC);
return false;
}
@ -74,7 +73,7 @@ InitRndisAddress()
length = strlen(mac);
ret = write(fd.get(), mac, length);
if (ret != length) {
CHROMIUM_LOG("Fail to write file %s.", ICS_SYS_USB_RNDIS_MAC);
NETD_LOG("Fail to write file %s.", ICS_SYS_USB_RNDIS_MAC);
return false;
}
return true;
@ -107,23 +106,23 @@ NetdClient::OpenSocket()
ANDROID_SOCKET_NAMESPACE_RESERVED,
SOCK_STREAM);
if (mSocket.rwget() < 0) {
CHROMIUM_LOG("Error connecting to : netd (%s) - will retry", strerror(errno));
NETD_LOG("Error connecting to : netd (%s) - will retry", strerror(errno));
return false;
}
// Add FD_CLOEXEC flag.
int flags = fcntl(mSocket.get(), F_GETFD);
if (flags == -1) {
CHROMIUM_LOG("Error doing fcntl with F_GETFD command(%s)", strerror(errno));
NETD_LOG("Error doing fcntl with F_GETFD command(%s)", strerror(errno));
return false;
}
flags |= FD_CLOEXEC;
if (fcntl(mSocket.get(), F_SETFD, flags) == -1) {
CHROMIUM_LOG("Error doing fcntl with F_SETFD command(%s)", strerror(errno));
NETD_LOG("Error doing fcntl with F_SETFD command(%s)", strerror(errno));
return false;
}
// Set non-blocking.
if (fcntl(mSocket.get(), F_SETFL, O_NONBLOCK) == -1) {
CHROMIUM_LOG("Error set non-blocking socket(%s)", strerror(errno));
NETD_LOG("Error set non-blocking socket(%s)", strerror(errno));
return false;
}
if (!MessageLoopForIO::current()->
@ -132,7 +131,7 @@ NetdClient::OpenSocket()
MessageLoopForIO::WATCH_READ,
&mReadWatcher,
this)) {
CHROMIUM_LOG("Error set socket read watcher(%s)", strerror(errno));
NETD_LOG("Error set socket read watcher(%s)", strerror(errno));
return false;
}
@ -145,7 +144,7 @@ NetdClient::OpenSocket()
this);
}
CHROMIUM_LOG("Connected to netd");
NETD_LOG("Connected to netd");
return true;
}
@ -166,7 +165,7 @@ void NetdClient::OnLineRead(int aFd, nsDependentCSubstring& aMessage)
}
if (!responseCode) {
CHROMIUM_LOG("Can't parse netd's response");
NETD_LOG("Can't parse netd's response");
}
}
@ -202,15 +201,15 @@ NetdClient::Start()
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
if (!gNetdClient) {
CHROMIUM_LOG("Netd Client is not initialized");
NETD_LOG("Netd Client is not initialized");
return;
}
if (!gNetdClient->OpenSocket()) {
// Socket open failed, try again in a second.
CHROMIUM_LOG("Fail to connect to Netd");
NETD_LOG("Fail to connect to Netd");
if (++gNetdClient->mReConnectTimes > MAX_RECONNECT_TIMES) {
CHROMIUM_LOG("Fail to connect to Netd after retry %d times", MAX_RECONNECT_TIMES);
NETD_LOG("Fail to connect to Netd after retry %d times", MAX_RECONNECT_TIMES);
return;
}
@ -231,14 +230,14 @@ NetdClient::SendNetdCommandIOThread(NetdCommand* aMessage)
MOZ_ASSERT(aMessage);
if (!gNetdClient) {
CHROMIUM_LOG("Netd Client is not initialized");
NETD_LOG("Netd Client is not initialized");
return;
}
gNetdClient->mOutgoingQ.push(aMessage);
if (gNetdClient->mSocket.get() == INVALID_SOCKET) {
CHROMIUM_LOG("Netd connection is not established, push the message to queue");
NETD_LOG("Netd connection is not established, push the message to queue");
return;
}
@ -260,7 +259,7 @@ NetdClient::WriteNetdCommand()
mCurrentNetdCommand->mData + mCurrentWriteOffset,
write_amount);
if (written < 0) {
CHROMIUM_LOG("Cannot write to network, error %d\n", (int) written);
NETD_LOG("Cannot write to network, error %d\n", (int) written);
OnError();
return;
}
@ -270,7 +269,7 @@ NetdClient::WriteNetdCommand()
}
if (written != write_amount) {
CHROMIUM_LOG("WriteNetdCommand fail !!! Write is not completed");
NETD_LOG("WriteNetdCommand fail !!! Write is not completed");
break;
}
}
@ -305,7 +304,7 @@ InitNetdIOThread()
// usb tethering only. Others service such as wifi tethering still need
// to use ipc to communicate with netd.
if (!result) {
CHROMIUM_LOG("fail to give rndis interface an address");
NETD_LOG("fail to give rndis interface an address");
}
}
gNetdClient = new NetdClient();