Merge b2g-inbound to m-c

This commit is contained in:
Wes Kocher 2013-10-21 20:30:58 -04:00
commit cac2099286
15 changed files with 84 additions and 55 deletions

View File

@ -1,4 +1,4 @@
{
"revision": "723401621af1bfabb671ec53ac7cafd62b700cb9",
"revision": "175b7a89aa5f39aa2b2263029ab086ac1833a636",
"repo_path": "/integration/gaia-central"
}

View File

@ -222,7 +222,6 @@ if test -n "$gonkdir" ; then
15)
GONK_INCLUDES="-I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/frameworks/base/include -I$gonkdir/frameworks/base/services/camera -I$gonkdir/frameworks/base/include/media/stagefright -I$gonkdir/frameworks/base/include/media/stagefright/openmax -I$gonkdir/frameworks/base/media/libstagefright/rtsp -I$gonkdir/frameworks/base/media/libstagefright/include -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib -I$gonkdir/dalvik/libnativehelper/include/nativehelper"
MOZ_B2G_BT=1
MOZ_B2G_BT_BLUEZ=1
MOZ_B2G_CAMERA=1
MOZ_OMX_DECODER=1
AC_SUBST(MOZ_OMX_DECODER)
@ -231,15 +230,9 @@ if test -n "$gonkdir" ; then
17|18)
GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include"
if test -d "$gonkdir/external/bluetooth/bluez"; then
GONK_INCLUDES="$GONK_INCLUDES -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"
GONK_INCLUDES+=" -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"
MOZ_B2G_BT=1
MOZ_B2G_BT_BLUEZ=1
fi
if test -d "$gonkdir/external/bluetooth/bluedroid"; then
MOZ_B2G_BT=1
MOZ_B2G_BT_BLUEDROID=1
fi
MOZ_B2G_CAMERA=1
MOZ_OMX_DECODER=1
AC_SUBST(MOZ_OMX_DECODER)
@ -7295,8 +7288,6 @@ if test -n "$MOZ_B2G_BT"; then
AC_DEFINE(MOZ_B2G_BT)
fi
AC_SUBST(MOZ_B2G_BT)
AC_SUBST(MOZ_B2G_BT_BLUEZ)
AC_SUBST(MOZ_B2G_BT_BLUEDROID)
dnl ========================================================
dnl = Enable Pico Speech Synthesis (Gonk usually)

View File

@ -44,9 +44,7 @@
#if defined(MOZ_B2G_BT)
# if defined(MOZ_BLUETOOTH_GONK)
#ifndef MOZ_B2G_BT_BLUEDROID
#include "BluetoothGonkService.h"
#endif
# include "BluetoothGonkService.h"
# elif defined(MOZ_BLUETOOTH_DBUS)
# include "BluetoothDBusService.h"
# else
@ -306,13 +304,9 @@ BluetoothService::Create()
#endif
#if defined(MOZ_BLUETOOTH_GONK)
#ifndef MOZ_B2G_BT_BLUEDROID
return new BluetoothGonkService();
#endif
#elif defined(MOZ_BLUETOOTH_DBUS)
#ifdef MOZ_B2G_BT_BLUEZ
return new BluetoothDBusService();
#endif
#endif
BT_WARNING("No platform support for bluetooth!");
return nullptr;

View File

@ -27,12 +27,11 @@
#include <errno.h>
#include <sys/socket.h>
#ifdef MOZ_B2G_BT_BLUEZ
#include <bluetooth/bluetooth.h>
#include <bluetooth/l2cap.h>
#include <bluetooth/rfcomm.h>
#include <bluetooth/sco.h>
#endif
#include "BluetoothUnixSocketConnector.h"
#include "nsThreadUtils.h"
@ -44,7 +43,6 @@ static const int L2CAP_SO_SNDBUF = 400 * 1024; // 400 KB send buffer
static const int L2CAP_SO_RCVBUF = 400 * 1024; // 400 KB receive buffer
static const int L2CAP_MAX_MTU = 65000;
#ifdef MOZ_B2G_BT_BLUEZ
static
int get_bdaddr(const char *str, bdaddr_t *ba)
{
@ -64,8 +62,6 @@ void get_bdaddr_as_string(const bdaddr_t *ba, char *str) {
b[5], b[4], b[3], b[2], b[1], b[0]);
}
#endif
BluetoothUnixSocketConnector::BluetoothUnixSocketConnector(
BluetoothSocketType aType,
int aChannel,
@ -80,7 +76,6 @@ BluetoothUnixSocketConnector::BluetoothUnixSocketConnector(
bool
BluetoothUnixSocketConnector::SetUp(int aFd)
{
#ifdef MOZ_B2G_BT_BLUEZ
int lm = 0;
int sndbuf, rcvbuf;
@ -162,7 +157,7 @@ BluetoothUnixSocketConnector::SetUp(int aFd)
}
}
}
#endif
return true;
}
@ -172,7 +167,6 @@ BluetoothUnixSocketConnector::Create()
MOZ_ASSERT(!NS_IsMainThread());
int fd = -1;
#ifdef MOZ_B2G_BT_BLUEZ
switch (mType) {
case BluetoothSocketType::RFCOMM:
fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
@ -199,7 +193,7 @@ BluetoothUnixSocketConnector::Create()
BT_WARNING("Could not set up socket!");
return -1;
}
#endif
return fd;
}
@ -209,7 +203,6 @@ BluetoothUnixSocketConnector::CreateAddr(bool aIsServer,
sockaddr_any& aAddr,
const char* aAddress)
{
#ifdef MOZ_B2G_BT_BLUEZ
// Set to BDADDR_ANY, if it's not a server, we'll reset.
bdaddr_t bd_address_obj = {{0, 0, 0, 0, 0, 0}};
@ -249,7 +242,6 @@ BluetoothUnixSocketConnector::CreateAddr(bool aIsServer,
BT_WARNING("Socket type unknown!");
return false;
}
#endif
return true;
}
@ -257,7 +249,6 @@ void
BluetoothUnixSocketConnector::GetSocketAddr(const sockaddr_any& aAddr,
nsAString& aAddrStr)
{
#ifdef MOZ_B2G_BT_BLUEZ
char addr[18];
switch (mType) {
case BluetoothSocketType::RFCOMM:
@ -274,5 +265,4 @@ BluetoothUnixSocketConnector::GetSocketAddr(const sockaddr_any& aAddr,
MOZ_CRASH("Socket should be either RFCOMM or SCO!");
}
aAddrStr.AssignASCII(addr);
#endif
}

View File

@ -36,14 +36,6 @@ DEFINES += -DMOZ_BLUETOOTH_DBUS
endif
endif
ifdef MOZ_B2G_BT_BLUEZ
DEFINES += -DMOZ_B2G_BT_BLUEZ
endif
ifdef MOZ_B2G_BT_BLUEDROID
DEFINES += -DMOZ_B2G_BT_BLUEDROID
endif
# Add VPATH to LOCAL_INCLUDES so we are going to include the correct backend
# subdirectory.
LOCAL_INCLUDES += $(VPATH:%=-I%)

View File

@ -24,9 +24,6 @@ BEGIN_BLUETOOTH_NAMESPACE
class BluetoothDBusService : public BluetoothService
{
public:
BluetoothDBusService();
~BluetoothDBusService();
bool IsReady();
virtual nsresult StartInternal() MOZ_OVERRIDE;
@ -171,6 +168,11 @@ public:
virtual nsresult
SendInputMessage(const nsAString& aDeviceAddresses,
const nsAString& aMessage) MOZ_OVERRIDE;
protected:
BluetoothDBusService();
~BluetoothDBusService();
private:
/**
* For DBus Control method of "UpdateNotification", event id should be

View File

@ -52,7 +52,7 @@ if CONFIG['MOZ_B2G_BT']:
'BluetoothRilListener.cpp',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_BT_BLUEZ']:
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
CPP_SOURCES += [
'linux/BluetoothDBusService.cpp',
'gonk/BluetoothGonkService.cpp',

View File

@ -316,11 +316,37 @@ AutoMounterResponseCallback::ResponseReceived(const VolumeCommand* aCommand)
}
}
class AutoBool {
public:
explicit AutoBool(bool &aBool) : mBool(aBool) {
mBool = true;
}
~AutoBool() {
mBool = false;
}
private:
bool &mBool;
};
/***************************************************************************/
void
AutoMounter::UpdateState()
{
static bool inUpdateState = false;
if (inUpdateState) {
// When UpdateState calls SetISharing, this causes a volume state
// change to occur, which would normally cause UpdateState to be called
// again. We want the volume state change to go out (so that device
// storage will see the change in sharing state), but since we're
// already in UpdateState we just want to prevent recursion from screwing
// things up.
return;
}
AutoBool inUpdateStateDetector(inUpdateState);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
// If the following preconditions are met:
@ -379,6 +405,7 @@ AutoMounter::UpdateState()
umsAvail, umsEnabled, mMode, usbCablePluggedIn, tryToShare);
bool filesOpen = false;
static unsigned filesOpenDelayCount = 0;
VolumeArray::index_type volIndex;
VolumeArray::size_type numVolumes = VolumeManager::NumVolumes();
for (volIndex = 0; volIndex < numVolumes; volIndex++) {
@ -413,6 +440,12 @@ AutoMounter::UpdateState()
break;
}
// Mark the volume as if we've started sharing. This will cause
// apps which watch device storage notifications to see the volume
// go into the shared state, and prompt them to close any open files
// that they might have.
vol->SetIsSharing(true);
// Check to see if there are any open files on the volume and
// don't initiate the unmount while there are open files.
OpenFileFinder::Info fileInfo;
@ -431,15 +464,26 @@ AutoMounter::UpdateState()
LOGW("UpdateState: Mounted volume %s has open files, not sharing",
vol->NameStr());
// Check again in 5 seconds to see if the files are closed. Since
// we're trying to share the volume, this implies that we're
// Check again in a few seconds to see if the files are closed.
// Since we're trying to share the volume, this implies that we're
// plugged into the PC via USB and this in turn implies that the
// battery is charging, so we don't need to be too concerned about
// wasting battery here.
//
// If we just detected that there were files open, then we use
// a short timer. We will have told the apps that we're trying
// trying to share, and they'll be closing their files. This makes
// the sharing more responsive. If after a few seconds, the apps
// haven't closed their files, then we back off.
int delay = 1000;
if (filesOpenDelayCount > 10) {
delay = 5000;
}
MessageLoopForIO::current()->
PostDelayedTask(FROM_HERE,
NewRunnableMethod(this, &AutoMounter::UpdateState),
5000);
delay);
filesOpen = true;
break;
}
@ -447,7 +491,6 @@ AutoMounter::UpdateState()
// Volume is mounted, we need to unmount before
// we can share.
LOG("UpdateState: Unmounting %s", vol->NameStr());
vol->SetIsSharing(true);
vol->StartUnmount(mResponseCallback);
return; // UpdateState will be called again when the Unmount command completes
}
@ -488,8 +531,10 @@ AutoMounter::UpdateState()
int32_t status = AUTOMOUNTER_STATUS_DISABLED;
if (filesOpen) {
filesOpenDelayCount++;
status = AUTOMOUNTER_STATUS_FILES_OPEN;
} else if (enabled) {
filesOpenDelayCount = 0;
status = AUTOMOUNTER_STATUS_ENABLED;
}
SetAutoMounterStatus(status);

View File

@ -68,7 +68,15 @@ Volume::Volume(const nsCSubstring& aName)
void
Volume::SetIsSharing(bool aIsSharing)
{
if (aIsSharing == mIsSharing) {
return;
}
mIsSharing = aIsSharing;
LOG("Volume %s: IsSharing set to %d state %s",
NameStr(), (int)mIsSharing, StateStr(mState));
if (mIsSharing) {
mEventObserverList.Broadcast(this);
}
}
void

View File

@ -95,6 +95,12 @@ bool nsVolume::Equals(nsIVolume* aVolume)
return false;
}
bool isSharing;
aVolume->GetIsSharing(&isSharing);
if (mIsSharing != isSharing) {
return false;
}
return true;
}

View File

@ -71,6 +71,10 @@ public:
int32_t State() const { return mState; }
const char* StateStr() const { return NS_VolumeStateStr(mState); }
bool IsFake() const { return mIsFake; }
bool IsMediaPresent() const { return mIsMediaPresent; }
bool IsSharing() const { return mIsSharing; }
typedef nsTArray<nsRefPtr<nsVolume> > Array;
private:
@ -80,9 +84,6 @@ private:
void UpdateMountLock(const nsAString& aMountLockState);
void UpdateMountLock(bool aMountLocked);
bool IsFake() const { return mIsFake; }
bool IsMediaPresent() const { return mIsMediaPresent; }
bool IsSharing() const { return mIsSharing; }
void SetIsFake(bool aIsFake);
void SetState(int32_t aState);

View File

@ -454,7 +454,7 @@ nsVolumeService::UpdateVolumeIOThread(const Volume* aVolume)
"media %d sharing %d",
aVolume->NameStr(), aVolume->StateStr(), aVolume->MountPoint().get(),
aVolume->MountGeneration(), (int)aVolume->IsMountLocked(),
(int)aVolume->IsMediaPresent(), (int)aVolume->IsSharing());
(int)aVolume->MediaPresent(), (int)aVolume->IsSharing());
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
NS_DispatchToMainThread(new UpdateVolumeRunnable(this, aVolume));
}

View File

@ -14,7 +14,7 @@ DIRS += [
if CONFIG['MOZ_B2G_RIL']:
DIRS += ['ril']
if CONFIG['MOZ_B2G_BT_BLUEZ']:
if CONFIG['MOZ_B2G_BT']:
DIRS += ['dbus']
if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT']:

View File

@ -12,7 +12,7 @@
#include <sys/types.h>
#include <sys/un.h>
#include <netinet/in.h>
#ifdef MOZ_B2G_BT_BLUEZ
#ifdef MOZ_B2G_BT
#include <bluetooth/bluetooth.h>
#include <bluetooth/sco.h>
#include <bluetooth/l2cap.h>
@ -31,7 +31,7 @@ union sockaddr_any {
sockaddr_un un;
sockaddr_in in;
sockaddr_in6 in6;
#ifdef MOZ_B2G_BT_BLUEZ
#ifdef MOZ_B2G_BT
sockaddr_sco sco;
sockaddr_rc rc;
sockaddr_l2 l2;

View File

@ -89,7 +89,7 @@ ifdef MOZ_B2G_RIL #{
STATIC_LIBS += mozril_s
endif #}
ifdef MOZ_B2G_BT_BLUEZ #{
ifdef MOZ_B2G_BT #{
STATIC_LIBS += mozdbus_s
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
OS_LIBS += -ldbus