Skip to content

Commit

Permalink
microedition: sensor: Stub everything from the Mobile Sensor API
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AShiningRay committed Dec 15, 2024
1 parent 6ba7967 commit 2c68b30
Show file tree
Hide file tree
Showing 14 changed files with 356 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/javax/microedition/sensor/ConditionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@

public interface ConditionListener
{

void conditionMet(SensorConnection sensor, Data data, Condition condition);

}
24 changes: 24 additions & 0 deletions src/javax/microedition/sensor/DataAndErrorListener.java
Original file line number Diff line number Diff line change
@@ -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);
}
42 changes: 42 additions & 0 deletions src/javax/microedition/sensor/LimitCondition.java
Original file line number Diff line number Diff line change
@@ -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;}
}
38 changes: 38 additions & 0 deletions src/javax/microedition/sensor/ObjectCondition.java
Original file line number Diff line number Diff line change
@@ -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; }
}
50 changes: 50 additions & 0 deletions src/javax/microedition/sensor/RangeCondition.java
Original file line number Diff line number Diff line change
@@ -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; }
}
3 changes: 3 additions & 0 deletions src/javax/microedition/sensor/SensorInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
50 changes: 50 additions & 0 deletions src/javax/microedition/sensor/SensorManager.java
Original file line number Diff line number Diff line change
@@ -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).");
}
}
14 changes: 10 additions & 4 deletions src/javax/microedition/sensor/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
24 changes: 24 additions & 0 deletions src/javax/microedition/sensor/control/Control.java
Original file line number Diff line number Diff line change
@@ -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();
}
24 changes: 24 additions & 0 deletions src/javax/microedition/sensor/control/Controllable.java
Original file line number Diff line number Diff line change
@@ -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();
}
27 changes: 27 additions & 0 deletions src/javax/microedition/sensor/control/MeasurementRangeControl.java
Original file line number Diff line number Diff line change
@@ -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);
}
26 changes: 26 additions & 0 deletions src/javax/microedition/sensor/control/SampleRateControl.java
Original file line number Diff line number Diff line change
@@ -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);
}
19 changes: 19 additions & 0 deletions src/javax/microedition/sensor/control/StartControl.java
Original file line number Diff line number Diff line change
@@ -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 { }
Loading

0 comments on commit 2c68b30

Please sign in to comment.