mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Backout 789f244f34f8, 1bea53f2d067, 577cba6021d2, 4191fe602648 (bug 697641) for win build bustage
This commit is contained in:
parent
9311df1d8e
commit
2b20126f0a
@ -665,42 +665,6 @@ public class GeckoAppShell
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Keep these values consistent with |SensorType| in Hal.h
|
||||
*/
|
||||
private static final int SENSOR_ORIENTATION = 1;
|
||||
private static final int SENSOR_ACCELERATION = 2;
|
||||
private static final int SENSOR_PROXIMITY = 3;
|
||||
|
||||
private static Sensor gProximitySensor = null;
|
||||
|
||||
public static void enableSensor(int aSensortype) {
|
||||
SensorManager sm = (SensorManager)
|
||||
GeckoApp.surfaceView.getContext().
|
||||
getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
switch(aSensortype) {
|
||||
case SENSOR_PROXIMITY:
|
||||
if(gProximitySensor == null)
|
||||
gProximitySensor = sm.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||
sm.registerListener(GeckoApp.surfaceView, gProximitySensor,
|
||||
SensorManager.SENSOR_DELAY_GAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void disableSensor(int aSensortype) {
|
||||
SensorManager sm = (SensorManager)
|
||||
GeckoApp.surfaceView.getContext().
|
||||
getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
switch(aSensortype) {
|
||||
case SENSOR_PROXIMITY:
|
||||
sm.unregisterListener(GeckoApp.surfaceView, gProximitySensor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void moveTaskToBack() {
|
||||
GeckoApp.mAppContext.moveTaskToBack(true);
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ public class GeckoEvent {
|
||||
public static final int ACTIVITY_START = 17;
|
||||
public static final int SAVE_STATE = 18;
|
||||
public static final int BROADCAST = 19;
|
||||
public static final int PROXIMITY_EVENT = 20;
|
||||
|
||||
public static final int IME_COMPOSITION_END = 0;
|
||||
public static final int IME_COMPOSITION_BEGIN = 1;
|
||||
@ -103,7 +102,6 @@ public class GeckoEvent {
|
||||
public Rect mRect;
|
||||
public double mX, mY, mZ;
|
||||
public double mAlpha, mBeta, mGamma;
|
||||
public double mDistance;
|
||||
|
||||
public int mMetaState, mFlags;
|
||||
public int mKeyCode, mUnicodeChar;
|
||||
@ -147,30 +145,19 @@ public class GeckoEvent {
|
||||
}
|
||||
|
||||
public GeckoEvent(SensorEvent s) {
|
||||
int sensor_type = s.sensor.getType();
|
||||
|
||||
switch(sensor_type) {
|
||||
case Sensor.TYPE_ACCELEROMETER:
|
||||
|
||||
if (s.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
|
||||
mType = ACCELERATION_EVENT;
|
||||
mX = s.values[0];
|
||||
mY = s.values[1];
|
||||
mZ = s.values[2];
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_ORIENTATION:
|
||||
}
|
||||
else {
|
||||
mType = ORIENTATION_EVENT;
|
||||
mAlpha = -s.values[0];
|
||||
mBeta = -s.values[1];
|
||||
mGamma = -s.values[2];
|
||||
Log.i("GeckoEvent", "SensorEvent type = " + s.sensor.getType() + " " + s.sensor.getName() + " " + mAlpha + " " + mBeta + " " + mGamma );
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_PROXIMITY:
|
||||
mType = PROXIMITY_EVENT;
|
||||
mDistance = s.values[0];
|
||||
Log.i("GeckoEvent", "SensorEvent type = " + s.sensor.getType() +
|
||||
" " + s.sensor.getName() + " " + mDistance);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
58
hal/Hal.cpp
58
hal/Hal.cpp
@ -326,63 +326,5 @@ void SetScreenBrightness(double brightness)
|
||||
PROXY_IF_SANDBOXED(SetScreenBrightness(clamped(brightness, 0.0, 1.0)));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EnableSensorNotifications(SensorType aSensor) {
|
||||
AssertMainThread();
|
||||
PROXY_IF_SANDBOXED(EnableSensorNotifications(aSensor));
|
||||
}
|
||||
|
||||
void
|
||||
DisableSensorNotifications(SensorType aSensor) {
|
||||
AssertMainThread();
|
||||
PROXY_IF_SANDBOXED(DisableSensorNotifications(aSensor));
|
||||
}
|
||||
|
||||
typedef ObserverList<SensorData> SensorObserverList;
|
||||
static SensorObserverList *gSensorObservers = NULL;
|
||||
|
||||
static SensorObserverList &
|
||||
GetSensorObservers(SensorType sensor_type) {
|
||||
MOZ_ASSERT(sensor_type < NUM_SENSOR_TYPE);
|
||||
|
||||
if(gSensorObservers == NULL)
|
||||
gSensorObservers = new SensorObserverList[NUM_SENSOR_TYPE];
|
||||
return gSensorObservers[sensor_type];
|
||||
}
|
||||
|
||||
void
|
||||
RegisterSensorObserver(SensorType aSensor, ISensorObserver *aObserver) {
|
||||
SensorObserverList &observers = GetSensorObservers(aSensor);
|
||||
|
||||
AssertMainThread();
|
||||
|
||||
observers.AddObserver(aObserver);
|
||||
if(observers.Length() == 1) {
|
||||
EnableSensorNotifications(aSensor);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UnregisterSensorObserver(SensorType aSensor, ISensorObserver *aObserver) {
|
||||
SensorObserverList &observers = GetSensorObservers(aSensor);
|
||||
|
||||
AssertMainThread();
|
||||
|
||||
observers.RemoveObserver(aObserver);
|
||||
if(observers.Length() == 0) {
|
||||
DisableSensorNotifications(aSensor);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NotifySensorChange(const SensorData &aSensorData) {
|
||||
SensorObserverList &observers = GetSensorObservers(aSensorData.sensor());
|
||||
|
||||
AssertMainThread();
|
||||
|
||||
observers.Broadcast(aSensorData);
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
} // namespace mozilla
|
||||
|
40
hal/Hal.h
40
hal/Hal.h
@ -46,7 +46,6 @@
|
||||
#include "nsTArray.h"
|
||||
#include "prlog.h"
|
||||
#include "mozilla/dom/battery/Types.h"
|
||||
#include "mozilla/hal_sandbox/PHal.h"
|
||||
|
||||
/*
|
||||
* Hal.h contains the public Hal API.
|
||||
@ -169,45 +168,6 @@ double GetScreenBrightness();
|
||||
*/
|
||||
void SetScreenBrightness(double brightness);
|
||||
|
||||
|
||||
/**
|
||||
* Register an observer for the sensor of given type.
|
||||
*
|
||||
* The observer will receive data whenever the data generated by the
|
||||
* sensor is avaiable.
|
||||
*/
|
||||
void RegisterSensorObserver(hal::SensorType aSensor,
|
||||
hal::ISensorObserver *aObserver);
|
||||
|
||||
/**
|
||||
* Unregister an observer for the sensor of given type.
|
||||
*/
|
||||
void UnregisterSensorObserver(hal::SensorType aSensor,
|
||||
hal::ISensorObserver *aObserver);
|
||||
|
||||
/**
|
||||
* Post a value generated by a sensor.
|
||||
*
|
||||
* This API is internal to hal; clients shouldn't call it directly.
|
||||
*/
|
||||
void NotifySensorChange(const hal::SensorData &aSensorData);
|
||||
|
||||
/**
|
||||
* Enable sensor notifications from the backend
|
||||
*
|
||||
* This method is only visible from implementation of sensor manager.
|
||||
* Rest of the system should not try this.
|
||||
*/
|
||||
void EnableSensorNotifications(hal::SensorType aSensor);
|
||||
|
||||
/**
|
||||
* Disable sensor notifications from the backend
|
||||
*
|
||||
* This method is only visible from implementation of sensor manager.
|
||||
* Rest of the system should not try this.
|
||||
*/
|
||||
void DisableSensorNotifications(hal::SensorType aSensor);
|
||||
|
||||
} // namespace MOZ_HAL_NAMESPACE
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -1,83 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: sw=2 ts=8 et ft=cpp : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sinker Li <thinker@codemud.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __HAL_SENSOR_H_
|
||||
#define __HAL_SENSOR_H_
|
||||
|
||||
#include "mozilla/Observer.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal {
|
||||
|
||||
/**
|
||||
* Enumeration of sensor types. They are used to specify type while
|
||||
* register or unregister an observer for a sensor of given type.
|
||||
*/
|
||||
enum SensorType {
|
||||
SENSOR_UNKNOWN = -1,
|
||||
SENSOR_ORIENTATION,
|
||||
SENSOR_ACCELERATION,
|
||||
SENSOR_PROXIMITY,
|
||||
NUM_SENSOR_TYPE
|
||||
};
|
||||
|
||||
class SensorData;
|
||||
|
||||
typedef Observer<SensorData> ISensorObserver;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "IPC/IPCMessageUtils.h"
|
||||
|
||||
namespace IPC {
|
||||
/**
|
||||
* Serializer for SensorType
|
||||
*/
|
||||
template <>
|
||||
struct ParamTraits<mozilla::hal::SensorType>:
|
||||
public EnumSerializer<mozilla::hal::SensorType,
|
||||
mozilla::hal::SENSOR_UNKNOWN,
|
||||
mozilla::hal::NUM_SENSOR_TYPE> {
|
||||
};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
#endif /* __HAL_SENSOR_H_ */
|
@ -61,7 +61,6 @@ EXPORTS_mozilla = \
|
||||
Hal.h \
|
||||
HalImpl.h \
|
||||
HalSandbox.h \
|
||||
HalSensor.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
@ -71,27 +70,18 @@ CPPSRCS = \
|
||||
$(NULL)
|
||||
|
||||
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += \
|
||||
AndroidHal.cpp \
|
||||
AndroidSensor.cpp \
|
||||
$(NULL)
|
||||
CPPSRCS += AndroidHal.cpp
|
||||
else ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += GonkHal.cpp
|
||||
else ifeq (Linux,$(OS_TARGET))
|
||||
CPPSRCS += \
|
||||
LinuxHal.cpp \
|
||||
FallbackSensor.cpp \
|
||||
$(NULL)
|
||||
CPPSRCS += LinuxHal.cpp
|
||||
ifdef MOZ_ENABLE_DBUS
|
||||
CPPSRCS += UPowerClient.cpp
|
||||
endif
|
||||
else ifeq (WINNT,$(OS_TARGET))
|
||||
CPPSRCS += WindowsHal.cpp WindowsBattery.cpp
|
||||
else
|
||||
CPPSRCS += \
|
||||
FallbackHal.cpp \
|
||||
FallbackSensor.cpp \
|
||||
$(NULL)
|
||||
CPPSRCS += FallbackHal.cpp
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
@ -1,75 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sinker Li <thinker@codemud.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "Hal.h"
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
using namespace mozilla::hal;
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
/**
|
||||
* Translate ID of sensor type from Sensor service to Android.
|
||||
*
|
||||
* Must be consistent with the definition of sensor types in
|
||||
* embedding/android/GeckoAppShell.java
|
||||
*/
|
||||
static int
|
||||
MapSensorType(SensorType aSensorType) {
|
||||
return (SENSOR_UNKNOWN <= aSensorType && aSensorType < NUM_SENSOR_TYPE) ?
|
||||
aSensorType + 1 : -1;
|
||||
}
|
||||
|
||||
void
|
||||
EnableSensorNotifications(SensorType aSensor) {
|
||||
int androidSensor = MapSensorType(aSensor);
|
||||
|
||||
MOZ_ASSERT(androidSensor != -1);
|
||||
AndroidBridge::Bridge()->EnableSensor(androidSensor);
|
||||
}
|
||||
|
||||
void
|
||||
DisableSensorNotifications(SensorType aSensor) {
|
||||
int androidSensor = MapSensorType(aSensor);
|
||||
|
||||
MOZ_ASSERT(androidSensor != -1);
|
||||
AndroidBridge::Bridge()->DisableSensor(androidSensor);
|
||||
}
|
||||
|
||||
} // hal_impl
|
||||
} // mozilla
|
@ -1,56 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: sw=4 ts=8 et ft=cpp : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sinker Li <thinker@codemud.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "mozilla/Hal.h"
|
||||
|
||||
using namespace mozilla::hal;
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
void
|
||||
EnableSensorNotifications(SensorType aSensor) {
|
||||
}
|
||||
|
||||
void
|
||||
DisableSensorNotifications(SensorType aSensor) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -39,11 +39,6 @@
|
||||
|
||||
include protocol PContent;
|
||||
include protocol PBrowser;
|
||||
include "nspr/prtime.h";
|
||||
include "mozilla/HalSensor.h";
|
||||
|
||||
using PRTime;
|
||||
using mozilla::hal::SensorType;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -53,12 +48,6 @@ namespace hal {
|
||||
bool charging;
|
||||
double remainingTime;
|
||||
};
|
||||
|
||||
struct SensorData {
|
||||
SensorType sensor;
|
||||
PRTime timestamp;
|
||||
float[] values;
|
||||
};
|
||||
}
|
||||
|
||||
namespace hal_sandbox {
|
||||
@ -84,13 +73,6 @@ parent:
|
||||
sync GetScreenBrightness() returns (double brightness);
|
||||
SetScreenBrightness(double brightness);
|
||||
|
||||
child:
|
||||
NotifySensorChange(SensorData aSensorData);
|
||||
|
||||
parent:
|
||||
EnableSensorNotifications(SensorType aSensor);
|
||||
DisableSensorNotifications(SensorType aSensor);
|
||||
|
||||
__delete__();
|
||||
};
|
||||
|
||||
|
@ -133,21 +133,8 @@ SetScreenBrightness(double brightness)
|
||||
Hal()->SendSetScreenBrightness(brightness);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EnableSensorNotifications(SensorType aSensor) {
|
||||
Hal()->SendEnableSensorNotifications(aSensor);
|
||||
}
|
||||
|
||||
void
|
||||
DisableSensorNotifications(SensorType aSensor) {
|
||||
Hal()->SendDisableSensorNotifications(aSensor);
|
||||
}
|
||||
|
||||
|
||||
class HalParent : public PHalParent
|
||||
, public BatteryObserver
|
||||
, public ISensorObserver {
|
||||
, public BatteryObserver {
|
||||
public:
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvVibrate(const InfallibleTArray<unsigned int>& pattern,
|
||||
@ -237,23 +224,6 @@ public:
|
||||
hal::SetScreenBrightness(brightness);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvEnableSensorNotifications(const SensorType &aSensor) {
|
||||
hal::RegisterSensorObserver(aSensor, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvDisableSensorNotifications(const SensorType &aSensor) {
|
||||
hal::UnregisterSensorObserver(aSensor, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Notify(const SensorData& aSensorData) {
|
||||
unused << SendNotifySensorChange(aSensorData);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class HalChild : public PHalChild {
|
||||
@ -263,19 +233,8 @@ public:
|
||||
hal::NotifyBatteryChange(aBatteryInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvNotifySensorChange(const hal::SensorData &aSensorData);
|
||||
};
|
||||
|
||||
bool
|
||||
HalChild::RecvNotifySensorChange(const hal::SensorData &aSensorData) {
|
||||
hal::NotifySensorChange(aSensorData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
PHalChild* CreateHalChild() {
|
||||
return new HalChild();
|
||||
}
|
||||
|
@ -98,33 +98,17 @@ namespace IPC {
|
||||
|
||||
/**
|
||||
* Generic enum serializer.
|
||||
*
|
||||
* This is a generic serializer for any enum type used in IPDL.
|
||||
* Programmers can define ParamTraits<E> for enum type E by deriving
|
||||
* EnumSerializer<E, smallestLegal, highGuard>.
|
||||
*
|
||||
* The serializer would check value againts a range specified by
|
||||
* smallestLegal and highGuard. Only values from smallestLegal to
|
||||
* highGuard are valid, include smallestLegal but highGuard.
|
||||
*
|
||||
* For example, following is definition of serializer for enum type FOO.
|
||||
* \code
|
||||
* enum FOO { FOO_FIRST, FOO_SECOND, FOO_LAST, NUM_FOO };
|
||||
*
|
||||
* template <>
|
||||
* struct ParamTraits<FOO>:
|
||||
* public EnumSerializer<FOO, FOO_FIRST, NUM_FOO> {};
|
||||
* \endcode
|
||||
* FOO_FIRST, FOO_SECOND, and FOO_LAST are valid value.
|
||||
*
|
||||
* \sa https://developer.mozilla.org/en/IPDL/Type_Serialization
|
||||
* E is the enum type.
|
||||
* lowBound is the lowest allowed value of the enum.
|
||||
* highBound is the value higher than highest allowed value of the enum.
|
||||
* In other words, it's the lowest unallowed value.
|
||||
*/
|
||||
template <typename E, E smallestLegal, E highBound>
|
||||
template <typename E, E lowBound, E highBound>
|
||||
struct EnumSerializer {
|
||||
typedef E paramType;
|
||||
|
||||
static bool IsLegalValue(const paramType &aValue) {
|
||||
return smallestLegal <= aValue && aValue < highBound;
|
||||
return lowBound <= aValue && aValue < highBound;
|
||||
}
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aValue) {
|
||||
|
@ -120,12 +120,6 @@ AndroidBridge::Init(JNIEnv *jEnv,
|
||||
|
||||
jEnableDeviceMotion = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableDeviceMotion", "(Z)V");
|
||||
jEnableLocation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableLocation", "(Z)V");
|
||||
jEnableSensor =
|
||||
(jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass,
|
||||
"enableSensor", "(I)V");
|
||||
jDisableSensor =
|
||||
(jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass,
|
||||
"disableSensor", "(I)V");
|
||||
jReturnIMEQueryResult = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "returnIMEQueryResult", "(Ljava/lang/String;II)V");
|
||||
jScheduleRestart = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "scheduleRestart", "()V");
|
||||
jNotifyXreExit = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "onXreExit", "()V");
|
||||
@ -354,20 +348,6 @@ AndroidBridge::EnableLocation(bool aEnable)
|
||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jEnableLocation, aEnable);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::EnableSensor(int aSensorType) {
|
||||
ALOG_BRIDGE("AndroidBridge::EnableSensor");
|
||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jEnableSensor,
|
||||
aSensorType);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::DisableSensor(int aSensorType) {
|
||||
ALOG_BRIDGE("AndroidBridge::DisableSensor");
|
||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jDisableSensor,
|
||||
aSensorType);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::ReturnIMEQueryResult(const PRUnichar *aResult, PRUint32 aLen,
|
||||
int aSelStart, int aSelLen)
|
||||
|
@ -142,10 +142,6 @@ public:
|
||||
|
||||
void EnableLocation(bool aEnable);
|
||||
|
||||
void EnableSensor(int aSensorType);
|
||||
|
||||
void DisableSensor(int aSensorType);
|
||||
|
||||
void ReturnIMEQueryResult(const PRUnichar *aResult, PRUint32 aLen, int aSelStart, int aSelLen);
|
||||
|
||||
void NotifyXreExit();
|
||||
@ -379,8 +375,6 @@ protected:
|
||||
jmethodID jAcknowledgeEventSync;
|
||||
jmethodID jEnableDeviceMotion;
|
||||
jmethodID jEnableLocation;
|
||||
jmethodID jEnableSensor;
|
||||
jmethodID jDisableSensor;
|
||||
jmethodID jReturnIMEQueryResult;
|
||||
jmethodID jNotifyAppShellReady;
|
||||
jmethodID jNotifyXreExit;
|
||||
|
@ -52,7 +52,6 @@ jfieldID AndroidGeckoEvent::jGammaField = 0;
|
||||
jfieldID AndroidGeckoEvent::jXField = 0;
|
||||
jfieldID AndroidGeckoEvent::jYField = 0;
|
||||
jfieldID AndroidGeckoEvent::jZField = 0;
|
||||
jfieldID AndroidGeckoEvent::jDistanceField = 0;
|
||||
jfieldID AndroidGeckoEvent::jRectField = 0;
|
||||
jfieldID AndroidGeckoEvent::jNativeWindowField = 0;
|
||||
|
||||
@ -162,7 +161,6 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
|
||||
jXField = getField("mX", "D");
|
||||
jYField = getField("mY", "D");
|
||||
jZField = getField("mZ", "D");
|
||||
jDistanceField = getField("mDistance", "D");
|
||||
jRectField = getField("mRect", "Landroid/graphics/Rect;");
|
||||
|
||||
jCharactersField = getField("mCharacters", "Ljava/lang/String;");
|
||||
@ -493,11 +491,6 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
|
||||
break;
|
||||
}
|
||||
|
||||
case PROXIMITY_EVENT: {
|
||||
mDistance = jenv->GetDoubleField(jobj, jDistanceField);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -440,7 +440,6 @@ public:
|
||||
double X() { return mX; }
|
||||
double Y() { return mY; }
|
||||
double Z() { return mZ; }
|
||||
double Distance() { return mDistance; }
|
||||
const nsIntRect& Rect() { return mRect; }
|
||||
nsAString& Characters() { return mCharacters; }
|
||||
nsAString& CharactersExtra() { return mCharactersExtra; }
|
||||
@ -471,7 +470,6 @@ protected:
|
||||
int mRangeForeColor, mRangeBackColor;
|
||||
double mAlpha, mBeta, mGamma;
|
||||
double mX, mY, mZ;
|
||||
double mDistance;
|
||||
nsString mCharacters, mCharactersExtra;
|
||||
nsRefPtr<nsGeoPosition> mGeoPosition;
|
||||
nsRefPtr<nsGeoPositionAddress> mGeoAddress;
|
||||
@ -494,7 +492,6 @@ protected:
|
||||
static jfieldID jXField;
|
||||
static jfieldID jYField;
|
||||
static jfieldID jZField;
|
||||
static jfieldID jDistanceField;
|
||||
static jfieldID jRectField;
|
||||
static jfieldID jNativeWindowField;
|
||||
|
||||
@ -537,7 +534,6 @@ public:
|
||||
VIEWPORT = 20,
|
||||
TILE_SIZE = 21,
|
||||
VISITED = 22,
|
||||
PROXIMITY_EVENT = 23,
|
||||
dummy_java_enum_list_end
|
||||
};
|
||||
|
||||
|
@ -36,10 +36,6 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Make sure the order of included headers
|
||||
#include "base/basictypes.h"
|
||||
#include "nspr/prtypes.h"
|
||||
|
||||
#include "nsAppShell.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsThreadUtils.h"
|
||||
@ -51,7 +47,6 @@
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Hal.h"
|
||||
#include "prenv.h"
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
@ -359,15 +354,6 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
||||
break;
|
||||
}
|
||||
|
||||
case AndroidGeckoEvent::PROXIMITY_EVENT: {
|
||||
InfallibleTArray<float> values;
|
||||
values.AppendElement(curEvent->Distance());
|
||||
|
||||
hal::SensorData sdata(hal::SENSOR_PROXIMITY, PR_Now(), values);
|
||||
hal::NotifySensorChange(sdata);
|
||||
break;
|
||||
}
|
||||
|
||||
case AndroidGeckoEvent::ACTIVITY_STOPPING: {
|
||||
nsCOMPtr<nsIObserverService> obsServ =
|
||||
mozilla::services::GetObserverService();
|
||||
|
Loading…
Reference in New Issue
Block a user