From 2c68b301e026b08a86c93241da5d3592c714185f Mon Sep 17 00:00:00 2001 From: AShiningRay Date: Sun, 15 Dec 2024 01:18:35 -0300 Subject: [PATCH] microedition: sensor: Stub everything from the Mobile Sensor API A few things like SensorManager weren't even present, causing issues in games like EDGE (EDGE Extended doesn't require this API though), now, this doesn't means sensors work, classes are fully stubbed and littered with warning messages on all of its functions. --- .../sensor/ConditionListener.java | 2 - .../sensor/DataAndErrorListener.java | 24 +++++++++ .../microedition/sensor/LimitCondition.java | 42 ++++++++++++++++ .../microedition/sensor/ObjectCondition.java | 38 ++++++++++++++ .../microedition/sensor/RangeCondition.java | 50 +++++++++++++++++++ src/javax/microedition/sensor/SensorInfo.java | 3 ++ .../microedition/sensor/SensorManager.java | 50 +++++++++++++++++++ src/javax/microedition/sensor/Unit.java | 14 ++++-- .../microedition/sensor/control/Control.java | 24 +++++++++ .../sensor/control/Controllable.java | 24 +++++++++ .../control/MeasurementRangeControl.java | 27 ++++++++++ .../sensor/control/SampleRateControl.java | 26 ++++++++++ .../sensor/control/StartControl.java | 19 +++++++ .../sensor/control/StopControl.java | 19 +++++++ 14 files changed, 356 insertions(+), 6 deletions(-) create mode 100644 src/javax/microedition/sensor/DataAndErrorListener.java create mode 100644 src/javax/microedition/sensor/LimitCondition.java create mode 100644 src/javax/microedition/sensor/ObjectCondition.java create mode 100644 src/javax/microedition/sensor/RangeCondition.java create mode 100644 src/javax/microedition/sensor/SensorManager.java create mode 100644 src/javax/microedition/sensor/control/Control.java create mode 100644 src/javax/microedition/sensor/control/Controllable.java create mode 100644 src/javax/microedition/sensor/control/MeasurementRangeControl.java create mode 100644 src/javax/microedition/sensor/control/SampleRateControl.java create mode 100644 src/javax/microedition/sensor/control/StartControl.java create mode 100644 src/javax/microedition/sensor/control/StopControl.java diff --git a/src/javax/microedition/sensor/ConditionListener.java b/src/javax/microedition/sensor/ConditionListener.java index e30e4ede..dff73c68 100644 --- a/src/javax/microedition/sensor/ConditionListener.java +++ b/src/javax/microedition/sensor/ConditionListener.java @@ -18,7 +18,5 @@ public interface ConditionListener { - void conditionMet(SensorConnection sensor, Data data, Condition condition); - } diff --git a/src/javax/microedition/sensor/DataAndErrorListener.java b/src/javax/microedition/sensor/DataAndErrorListener.java new file mode 100644 index 00000000..a1660bec --- /dev/null +++ b/src/javax/microedition/sensor/DataAndErrorListener.java @@ -0,0 +1,24 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor; + +import org.recompile.mobile.Mobile; + +public interface DataAndErrorListener extends DataListener +{ + public void errorReceived(SensorConnection sensor, int errorCode, long timeStamp); +} \ No newline at end of file diff --git a/src/javax/microedition/sensor/LimitCondition.java b/src/javax/microedition/sensor/LimitCondition.java new file mode 100644 index 00000000..8a655c79 --- /dev/null +++ b/src/javax/microedition/sensor/LimitCondition.java @@ -0,0 +1,42 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor; + +import org.recompile.mobile.Mobile; + +public final class LimitCondition implements Condition +{ + double limit; + String operator; + + LimitCondition(double limit, String operator) + { + Mobile.log(Mobile.LOG_WARNING, LimitCondition.class.getPackage().getName() + "." + LimitCondition.class.getSimpleName() + ": " + "Created new LimitCondition."); + this.limit = limit; + this.operator = operator; + } + + public final double getLimit() { return limit; } + + public final String getOperator() { return operator; } + + @Override + public boolean isMet(double value) { return false; } + + @Override + public boolean isMet(Object value) { return false;} +} \ No newline at end of file diff --git a/src/javax/microedition/sensor/ObjectCondition.java b/src/javax/microedition/sensor/ObjectCondition.java new file mode 100644 index 00000000..0ef930ae --- /dev/null +++ b/src/javax/microedition/sensor/ObjectCondition.java @@ -0,0 +1,38 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor; + +import org.recompile.mobile.Mobile; + +public final class ObjectCondition implements Condition +{ + private Object limit; + + public ObjectCondition(Object limit) + { + Mobile.log(Mobile.LOG_WARNING, ObjectCondition.class.getPackage().getName() + "." + ObjectCondition.class.getSimpleName() + ": " + "Created new ObjectCondition."); + this.limit = limit; + } + + public final Object getLimit() { return limit; } + + @Override + public boolean isMet(double value) { return false; } + + @Override + public boolean isMet(Object value) { return false; } +} \ No newline at end of file diff --git a/src/javax/microedition/sensor/RangeCondition.java b/src/javax/microedition/sensor/RangeCondition.java new file mode 100644 index 00000000..7c8ce3aa --- /dev/null +++ b/src/javax/microedition/sensor/RangeCondition.java @@ -0,0 +1,50 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor; + +import org.recompile.mobile.Mobile; + +public class RangeCondition implements Condition +{ + private double lowerLimit; + private String lowerOp; + private double upperLimit; + private String upperOp; + + public RangeCondition(double lowerLimit, String lowerOp, double upperLimit, String upperOp) + { + Mobile.log(Mobile.LOG_WARNING, RangeCondition.class.getPackage().getName() + "." + RangeCondition.class.getSimpleName() + ": " + "Created new RangeCondition."); + this.lowerLimit = lowerLimit; + this.lowerOp = lowerOp; + this.upperLimit = upperLimit; + this.upperOp = upperOp; + } + + public double getLowerLimit() { return lowerLimit; } + + public String getLowerOp() { return lowerOp; } + + public double getUpperLimit() { return upperLimit; } + + public String getUpperOp() { return upperOp; } + + @Override + public boolean isMet(double doubleValue) { return false; } + + @Override + public boolean isMet(Object value) { return false; } +} \ No newline at end of file diff --git a/src/javax/microedition/sensor/SensorInfo.java b/src/javax/microedition/sensor/SensorInfo.java index c64291f0..bb094d19 100644 --- a/src/javax/microedition/sensor/SensorInfo.java +++ b/src/javax/microedition/sensor/SensorInfo.java @@ -26,6 +26,9 @@ public interface SensorInfo public static final String CONTEXT_TYPE_AMBIENT = "ambient"; public static final String CONTEXT_TYPE_DEVICE = "device"; public static final String CONTEXT_TYPE_USER = "user"; + public static final String CONTEXT_TYPE_VEHICLE = "vehicle"; + public static final String PROP_IS_CONTROLLABLE = "controllable"; + public static final String PROP_IS_REPORTING_ERRORS = "errorsReported"; public static final String PROP_LATITUDE = "latitude"; public static final String PROP_LOCATION = "location"; public static final String PROP_LONGITUDE = "longitude"; diff --git a/src/javax/microedition/sensor/SensorManager.java b/src/javax/microedition/sensor/SensorManager.java new file mode 100644 index 00000000..002eb7b5 --- /dev/null +++ b/src/javax/microedition/sensor/SensorManager.java @@ -0,0 +1,50 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor; + +import org.recompile.mobile.Mobile; + +public class SensorManager +{ + + public static void addSensorListener(SensorListener listener, SensorInfo info) + { + Mobile.log(Mobile.LOG_WARNING, SensorManager.class.getPackage().getName() + "." + SensorManager.class.getSimpleName() + ": " + "addSensorListener(SensorListener, SensorInfo)."); + } + + public static void addSensorListener(SensorListener listener, String quantity) + { + Mobile.log(Mobile.LOG_WARNING, SensorManager.class.getPackage().getName() + "." + SensorManager.class.getSimpleName() + ": " + "addSensorListener(SensorListener, String)."); + } + + public static SensorInfo[] findSensors(String url) + { + Mobile.log(Mobile.LOG_WARNING, SensorManager.class.getPackage().getName() + "." + SensorManager.class.getSimpleName() + ": " + "findSensors(String)."); + return new SensorInfo[]{}; + } + + public static SensorInfo[] findSensors(String quantity, String contextType) + { + Mobile.log(Mobile.LOG_WARNING, SensorManager.class.getPackage().getName() + "." + SensorManager.class.getSimpleName() + ": " + "findSensors(String, String)."); + return new SensorInfo[]{}; + } + + public static void removeSensorListener (SensorListener listener) + { + Mobile.log(Mobile.LOG_WARNING, SensorManager.class.getPackage().getName() + "." + SensorManager.class.getSimpleName() + ": " + "removeSensorListener(SensorListener)."); + } +} \ No newline at end of file diff --git a/src/javax/microedition/sensor/Unit.java b/src/javax/microedition/sensor/Unit.java index 8195413d..181bdfc2 100644 --- a/src/javax/microedition/sensor/Unit.java +++ b/src/javax/microedition/sensor/Unit.java @@ -16,13 +16,19 @@ */ package javax.microedition.sensor; +import org.recompile.mobile.Mobile; + public class Unit { + private String symbol; - public Unit() { } - + public Unit(String symbol) + { + Mobile.log(Mobile.LOG_WARNING, Unit.class.getPackage().getName() + "." + Unit.class.getSimpleName() + ": " + "Created new Unit with symbol " + symbol + "."); + this.symbol = symbol; + } - public static Unit getUnit(String symbol) { return new Unit(); } + public static Unit getUnit(String symbol) { return new Unit(symbol); } - public String toString() { return ""; } + public String toString() { return symbol; } } diff --git a/src/javax/microedition/sensor/control/Control.java b/src/javax/microedition/sensor/control/Control.java new file mode 100644 index 00000000..2b976719 --- /dev/null +++ b/src/javax/microedition/sensor/control/Control.java @@ -0,0 +1,24 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor.control; + +public interface Control +{ + public void execute(); + + public String getName(); +} \ No newline at end of file diff --git a/src/javax/microedition/sensor/control/Controllable.java b/src/javax/microedition/sensor/control/Controllable.java new file mode 100644 index 00000000..4d1e7d54 --- /dev/null +++ b/src/javax/microedition/sensor/control/Controllable.java @@ -0,0 +1,24 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor.control; + +public interface Controllable +{ + public Control getControl(String name); + + public Control[] getControls(); +} \ No newline at end of file diff --git a/src/javax/microedition/sensor/control/MeasurementRangeControl.java b/src/javax/microedition/sensor/control/MeasurementRangeControl.java new file mode 100644 index 00000000..a4fa4df4 --- /dev/null +++ b/src/javax/microedition/sensor/control/MeasurementRangeControl.java @@ -0,0 +1,27 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor.control; + +import javax.microedition.sensor.ChannelInfo; +import javax.microedition.sensor.MeasurementRange; + +public interface MeasurementRangeControl extends Control +{ + public MeasurementRange getMeasurementRange(ChannelInfo channelInfo); + + public void setMeasurementRange(ChannelInfo channelInfo, MeasurementRange measurementRange); +} \ No newline at end of file diff --git a/src/javax/microedition/sensor/control/SampleRateControl.java b/src/javax/microedition/sensor/control/SampleRateControl.java new file mode 100644 index 00000000..7f9ee9db --- /dev/null +++ b/src/javax/microedition/sensor/control/SampleRateControl.java @@ -0,0 +1,26 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor.control; + +public interface SampleRateControl extends Control +{ + public float getSampleRate(); + + public float[] getSampleRates(); + + public void setSampleRate(float sampleRate); +} \ No newline at end of file diff --git a/src/javax/microedition/sensor/control/StartControl.java b/src/javax/microedition/sensor/control/StartControl.java new file mode 100644 index 00000000..eb1682d8 --- /dev/null +++ b/src/javax/microedition/sensor/control/StartControl.java @@ -0,0 +1,19 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor.control; + +public interface StartControl extends Control { } \ No newline at end of file diff --git a/src/javax/microedition/sensor/control/StopControl.java b/src/javax/microedition/sensor/control/StopControl.java new file mode 100644 index 00000000..f40616d1 --- /dev/null +++ b/src/javax/microedition/sensor/control/StopControl.java @@ -0,0 +1,19 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.sensor.control; + +public interface StopControl extends Control { } \ No newline at end of file