Closed GoogleCodeExporter closed 9 years ago
For the record, simply running "battery_info.lua", which ships as a sample with
the Lua interpreter, crashes SL4A every single time too.
o Motorola Droid
o 2.6.32.9-g68eeef5
o version 3 on Android 2.2.1
Original comment by pgy...@gmail.com
on 15 Dec 2010 at 3:06
On further investigation, the error actually occurs when the script stops.
What is more, if 'batterStopMonitoring' is NOT called, the error does not occur.
I would imagine that the problem is being caused here:
BatteryManagerFacade.java:
@Rpc(description = "Stops tracking battery state.")
public void batteryStopMonitoring() {
mService.unregisterReceiver(mReceiver);
mBatteryData = null;
}
@Override
public void shutdown() {
batteryStopMonitoring();
}
unregisterReceiver must throw an IllegalArgumentException it is called twice.
Fix: trap exception in batteryStopMonitoring, and/or reference count calls to
batteryStartMonitoring
Workaround: don't call batteryStopMonitoring in your script.
Original comment by rjmatthews62
on 15 Dec 2010 at 4:46
The actual fix is a one line fix in BatteryManagerFacade.java:
public void batteryStopMonitoring() {
if (mReceiver != null) {
mService.unregisterReceiver(mReceiver);
** mReceiver = null; **
}
mBatteryData = null;
}
I'd fix it myself but I can't get SL4A to compile in my environment.
Original comment by rjmatthews62
on 18 Dec 2010 at 11:23
... and now the change is checked into clone:
rjmatthews62-android-scripting
Original comment by rjmatthews62
on 19 Dec 2010 at 11:20
Fixed in latest unofficial release 3x
Original comment by rjmatthews62
on 7 Jan 2011 at 1:45
Original issue reported on code.google.com by
rjmatthews62
on 15 Dec 2010 at 1:23Attachments: