- Fix proguard issue with ANT+ services.

- Fix AntSensorManager.onDestroy, check antReceiver is not null.
- In AntSensorManager.onDestroy, log info rather than log error
  for AntServiceNotConnectedException.
This commit is contained in:
Jimmy Shih
2011-10-18 13:18:02 -07:00
parent 4ab93b067e
commit 9b97570a92
2 changed files with 17 additions and 7 deletions
+6
View File
@@ -67,3 +67,9 @@
# Needed by Guava # Needed by Guava
-dontwarn sun.misc.Unsafe -dontwarn sun.misc.Unsafe
# Keep services needed by ANT+ protocol
-keep public class com.dsi.ant.IAnt_6
-keep public class com.dsi.ant.IAnt
-keep public class com.dsi.ant.IServiceSettings
@@ -22,6 +22,7 @@ import com.dsi.ant.AntInterface;
import com.dsi.ant.AntInterfaceIntent; import com.dsi.ant.AntInterfaceIntent;
import com.dsi.ant.AntMesg; import com.dsi.ant.AntMesg;
import com.dsi.ant.exception.AntInterfaceException; import com.dsi.ant.exception.AntInterfaceException;
import com.dsi.ant.exception.AntServiceNotConnectedException;
import com.google.android.apps.mytracks.content.Sensor; import com.google.android.apps.mytracks.content.Sensor;
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet; import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
import com.google.android.apps.mytracks.services.sensors.SensorManager; import com.google.android.apps.mytracks.services.sensors.SensorManager;
@@ -142,14 +143,17 @@ public abstract class AntSensorManager extends SensorManager {
Log.w(TAG, "Failed to unregister ANT data receiver", e); Log.w(TAG, "Failed to unregister ANT data receiver", e);
} }
if (antReceiver != null) {
try { try {
antReceiver.releaseInterface(); antReceiver.releaseInterface();
} catch (AntServiceNotConnectedException e) {
Log.i(TAG, "ANT service not connected", e);
} catch (AntInterfaceException e) { } catch (AntInterfaceException e) {
Log.e(TAG, "failed to release ANT interface", e); Log.e(TAG, "failed to release ANT interface", e);
} }
antReceiver.destroy(); antReceiver.destroy();
} }
}
@Override @Override
public SensorDataSet getSensorDataSet() { public SensorDataSet getSensorDataSet() {
@@ -236,7 +240,7 @@ public abstract class AntSensorManager extends SensorManager {
/** /**
* Process a raw ANT message. * Process a raw ANT message.
* @param antMessage the ANT message, including the size and message ID bytes * @param antMessage the ANT message, including the size and message ID bytes
* @deprecated Use {@link #handleMessage(int, byte[])} instead. * @deprecated Use {@link #handleMessage(byte, byte[])} instead.
*/ */
protected void handleMessage(byte[] antMessage) { protected void handleMessage(byte[] antMessage) {
int len = antMessage[0]; int len = antMessage[0];