This let me find why AltosDroid was losing the last state information
for each target.
Signed-off-by: Keith Packard <keithp@keithp.com>
public File homeDirectory() {
return Environment.getExternalStorageDirectory();
}
public File homeDirectory() {
return Environment.getExternalStorageDirectory();
}
+
+ public void debug(String format, Object ... arguments) {
+ AltosDebug.debug(format, arguments);
+ }
public static void set_state(int serial, AltosState state, AltosListenerState listener_state) {
public static void set_state(int serial, AltosState state, AltosListenerState listener_state) {
+ backend.debug("set_state for %d pos %g,%g\n",
+ serial,
+ state.gps != null ? state.gps.lat : 0.0,
+ state.gps != null ? state.gps.lon : 0.0);
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
flush_preferences();
}
} catch (IOException ie) {
flush_preferences();
}
} catch (IOException ie) {
+ backend.debug("set_state failed %s\n", ie.toString());
for (String key : keys) {
if (key.startsWith(statePreferenceHead)) {
for (String key : keys) {
if (key.startsWith(statePreferenceHead)) {
+ backend.debug("list_states %s\n", key);
try {
int serial = AltosParse.parse_int(key.substring(statePreferenceHead.length()));
states.add(serial);
try {
int serial = AltosParse.parse_int(key.substring(statePreferenceHead.length()));
states.add(serial);
public static AltosSavedState state(int serial) {
byte[] bytes = null;
public static AltosSavedState state(int serial) {
byte[] bytes = null;
+ backend.debug("get state %d\n", serial);
+
synchronized(backend) {
bytes = backend.getBytes(String.format(statePreferenceFormat, serial), null);
}
synchronized(backend) {
bytes = backend.getBytes(String.format(statePreferenceFormat, serial), null);
}
+ if (bytes == null) {
+ backend.debug("no state for %d\n", serial);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
try {
ObjectInputStream ois = new ObjectInputStream(bais);
AltosSavedState saved_state = (AltosSavedState) ois.readObject();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
try {
ObjectInputStream ois = new ObjectInputStream(bais);
AltosSavedState saved_state = (AltosSavedState) ois.readObject();
+ backend.debug("got saved state for %d: %g,%g\n",
+ serial,
+ saved_state.state.gps != null ? saved_state.state.gps.lat : 0.0,
+ saved_state.state.gps != null ? saved_state.state.gps.lon : 0.0);
return saved_state;
} catch (IOException ie) {
return saved_state;
} catch (IOException ie) {
+ backend.debug("IO exception %s\n", ie.toString());
} catch (ClassNotFoundException ce) {
} catch (ClassNotFoundException ce) {
+ backend.debug("ClassNotFoundException %s\n", ce.toString());
public void flush();
public File homeDirectory();
public void flush();
public File homeDirectory();
+
+ public void debug(String format, Object ... arguments);
/* Use the file system view default directory */
return FileSystemView.getFileSystemView().getDefaultDirectory();
}
/* Use the file system view default directory */
return FileSystemView.getFileSystemView().getDefaultDirectory();
}
+
+ public void debug(String format, Object ... arguments) {
+ System.out.printf(format, arguments);
+ }