aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhurshid <beenish.khurshid@thisisant.com>2013-07-19 16:16:41 -0600
committerKhurshid <beenish.khurshid@thisisant.com>2013-07-19 16:16:41 -0600
commit9a3be4106f3b5e906ea9fddf9799c5c260ffec45 (patch)
tree14fff7d41bec7d8d4fee92af08282d18a6b39454
parent130d7b7db84b39f65fcdd21a7cc0ec3b8caaf5d5 (diff)
downloadandroid_external_ant-wireless_ant_service-9a3be4106f3b5e906ea9fddf9799c5c260ffec45.tar.gz
android_external_ant-wireless_ant_service-9a3be4106f3b5e906ea9fddf9799c5c260ffec45.tar.bz2
android_external_ant-wireless_ant_service-9a3be4106f3b5e906ea9fddf9799c5c260ffec45.zip
Android_System_ANTHALService_3-1-0
-rw-r--r--Android.mk13
-rw-r--r--AndroidManifest.xml13
-rw-r--r--ReleaseNotes.txt10
-rw-r--r--src/com/dsi/ant/server/AntService.java156
4 files changed, 115 insertions, 77 deletions
diff --git a/Android.mk b/Android.mk
index f119ec0..2169f06 100644
--- a/Android.mk
+++ b/Android.mk
@@ -20,9 +20,6 @@ ifneq ($(BOARD_ANT_WIRELESS_DEVICE),)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-BT_ON_SRC_FILES := \
- src/com/dsi/ant/server/StateChangedReceiver.java
-
#
# ANT java system service
#
@@ -32,16 +29,6 @@ LOCAL_SRC_FILES := \
src/com/dsi/ant/server/IAntHal.aidl \
src/com/dsi/ant/server/IAntHalCallback.aidl
-#
-# If target board is not one that requires Bluetooth to be enabled for ANT to enable,
-# filter out files that are only needed for Bluetooth to enable when ANT is enabled.
-#
-
-ifeq ($(filter msm8610 msm8226 msm8974, $(TARGET_BOARD_PLATFORM)),)
-LOCAL_SRC_FILES := \
- $(filter-out $(BT_ON_SRC_FILES), $(LOCAL_SRC_FILES))
-endif
-
LOCAL_REQUIRED_MODULES := libantradio
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_CERTIFICATE := platform
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7e0a17e..28b95be 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -16,8 +16,8 @@ limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dsi.ant.server"
- android:versionName="3.0.1"
- android:versionCode="030001"
+ android:versionName="3.1.0"
+ android:versionCode="030100"
android:sharedUserId="android.uid.system">
<uses-sdk
@@ -49,15 +49,6 @@ limitations under the License.
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
-
- <receiver android:name="com.dsi.ant.server.StateChangedReceiver"
- android:enabled="true"
- android:exported="false"
- android:label="StateChangedReceiver">
- <intent-filter>
- <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
- </intent-filter>
- </receiver>
</application>
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
index d889dc7..82df96b 100644
--- a/ReleaseNotes.txt
+++ b/ReleaseNotes.txt
@@ -1,6 +1,6 @@
AntHalService - Release Notes
-v3.0.1
-2013-07-18
+v3.1.0
+2013-07-19
Copyright 2011 Dynastream Innovations
@@ -27,6 +27,12 @@ messages, enable, disable and get the enebaled state.
=============================================================
2. REVISION HISTORY
+v3.1.0 : 2013-07-19 : Android_System_ANTHALService_3-1-0
+
+Task
+ [ANTDROID-2035] - Remove tabs from AntService
+ [ANTDROID-1987] - Enable Bluetooth when ANT is enabled, if required by chip
+
v3.0.0 : 2013-01-17 : Android_System_ANTHALService_3-0-0
Bug
diff --git a/src/com/dsi/ant/server/AntService.java b/src/com/dsi/ant/server/AntService.java
index 388a311..1ed828f 100644
--- a/src/com/dsi/ant/server/AntService.java
+++ b/src/com/dsi/ant/server/AntService.java
@@ -46,18 +46,35 @@ public class AntService extends Service
public static final String ANT_SERVICE = "AntService";
+ /**
+ * Allows the application to directly configure the ANT radio through the
+ * proxy service. Malicious applications may prevent other ANT applications
+ * from connecting to ANT devices
+ */
public static final String ANT_ADMIN_PERMISSION = "com.dsi.ant.permission.ANT_ADMIN";
+ /**
+ * Request that ANT be enabled
+ */
public static final String ACTION_REQUEST_ENABLE = "com.dsi.ant.server.action.REQUEST_ENABLE";
+ /**
+ * Request that ANT be disabled
+ */
public static final String ACTION_REQUEST_DISABLE = "com.dsi.ant.server.action.REQUEST_DISABLE";
private JAntJava mJAnt = null;
private boolean mInitialized = false;
+ /**
+ * Flag for if Bluetooth needs to be enabled for ANT to enable
+ */
private boolean mRequiresBluetoothOn = false;
+ /**
+ * Flag which specifies if we are waiting for an ANT enable intent
+ */
private boolean mEnablePending = false;
private Object mChangeAntPowerState_LOCK = new Object();
@@ -65,17 +82,16 @@ public class AntService extends Service
IAntHalCallback mCallback;
- private boolean isQcomPlatform()
- {
- if ((SystemProperties.get("ro.board.platform").equals("msm8974"))
- || (SystemProperties.get("ro.board.platform").equals("msm8610"))
- || (SystemProperties.get("ro.board.platform").equals("msm8226"))) {
-
- return true;
- }
- return false;
- }
+ /**
+ * Receives Bluetooth State Changed intent and sends {@link ACTION_REQUEST_ENABLE}
+ * and {@link ACTION_REQUEST_DISABLE} accordingly
+ */
+ private final StateChangedReceiver mStateChangedReceiver = new StateChangedReceiver();
+ /**
+ * Receives {@link ACTION_REQUEST_ENABLE} and {@link ACTION_REQUEST_DISABLE}
+ * intents to enable and disable ANT.
+ */
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -97,6 +113,27 @@ public class AntService extends Service
}
};
+ /**
+ * Checks if Bluetooth needs to be turned on for ANT to enable
+ */
+ private boolean requiresBluetoothOn() {
+ return isQcomPlatform();
+ }
+
+ /**
+ * Checks if the current platform is QCom
+ */
+ private boolean isQcomPlatform()
+ {
+ if ((SystemProperties.get("ro.board.platform").equals("msm8974"))
+ || (SystemProperties.get("ro.board.platform").equals("msm8610"))
+ || (SystemProperties.get("ro.board.platform").equals("msm8226"))) {
+
+ return true;
+ }
+ return false;
+ }
+
public static boolean startService(Context context)
{
return ( null != context.startService(new Intent(IAntHal.class.getName())) );
@@ -157,22 +194,25 @@ public class AntService extends Service
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (bluetoothAdapter != null) {
+
+ // run with permissions of ANTHALService
long callingPid = Binder.clearCallingIdentity();
if (!bluetoothAdapter.isEnabled()) {
waitForBluetoothToEnable = true;
-
- // check permissions of ANTHALService
+ mEnablePending = true;
+
boolean isEnabling = bluetoothAdapter.enable();
// if enabling adapter has begun, return
// success.
if (isEnabling) {
- mEnablePending = true;
result = AntHalDefine.ANT_HAL_RESULT_SUCCESS;
// StateChangedReceiver will receive
// enabled status and then enable ANT
+ } else {
+ mEnablePending = false;
}
}
@@ -226,44 +266,48 @@ public class AntService extends Service
*/
private int asyncSetAntPowerState(final boolean state)
{
- int result = AntHalDefine.ANT_HAL_RESULT_FAIL_UNKNOWN;
-
- synchronized(mChangeAntPowerState_LOCK) {
- // Check we are not already in/transitioning to the state we want
- int currentState = doGetAntState();
-
- if(state) {
- if((AntHalDefine.ANT_HAL_STATE_ENABLED == currentState)
- || (AntHalDefine.ANT_HAL_STATE_ENABLING == currentState)) {
- if(DEBUG) Log.d(TAG, "Enable request ignored as already enabled/enabling");
-
- return AntHalDefine.ANT_HAL_RESULT_SUCCESS;
- } else if(AntHalDefine.ANT_HAL_STATE_DISABLING == currentState) {
- Log.w(TAG, "Enable request ignored as already disabling");
-
- return AntHalDefine.ANT_HAL_RESULT_FAIL_UNKNOWN;
- }
- } else {
- if((AntHalDefine.ANT_HAL_STATE_DISABLED == currentState)
- || (AntHalDefine.ANT_HAL_STATE_DISABLING == currentState)) {
- if(DEBUG)Log.d(TAG, "Disable request ignored as already disabled/disabling");
-
- return AntHalDefine.ANT_HAL_RESULT_SUCCESS;
- } else if(AntHalDefine.ANT_HAL_STATE_ENABLING == currentState) {
- Log.w(TAG, "Disable request ignored as already enabling");
-
- return AntHalDefine.ANT_HAL_RESULT_FAIL_UNKNOWN;
- }
- }
-
- if (state) {
- result = enableBackground();
- } else {
- result = disableBackground();
- }
+ int result = AntHalDefine.ANT_HAL_RESULT_FAIL_UNKNOWN;
+
+ synchronized (mChangeAntPowerState_LOCK) {
+ // Check we are not already in/transitioning to the state we want
+ int currentState = doGetAntState();
+
+ if (state) {
+ if ((AntHalDefine.ANT_HAL_STATE_ENABLED == currentState)
+ || (AntHalDefine.ANT_HAL_STATE_ENABLING == currentState)) {
+ if (DEBUG) {
+ Log.d(TAG, "Enable request ignored as already enabled/enabling");
+ }
+
+ return AntHalDefine.ANT_HAL_RESULT_SUCCESS;
+ } else if (AntHalDefine.ANT_HAL_STATE_DISABLING == currentState) {
+ Log.w(TAG, "Enable request ignored as already disabling");
+
+ return AntHalDefine.ANT_HAL_RESULT_FAIL_UNKNOWN;
+ }
+ } else {
+ if ((AntHalDefine.ANT_HAL_STATE_DISABLED == currentState)
+ || (AntHalDefine.ANT_HAL_STATE_DISABLING == currentState)) {
+ if (DEBUG) {
+ Log.d(TAG, "Disable request ignored as already disabled/disabling");
+ }
+
+ return AntHalDefine.ANT_HAL_RESULT_SUCCESS;
+ } else if (AntHalDefine.ANT_HAL_STATE_ENABLING == currentState) {
+ Log.w(TAG, "Disable request ignored as already enabling");
+
+ return AntHalDefine.ANT_HAL_RESULT_FAIL_UNKNOWN;
+ }
+ }
+
+ if (state) {
+ result = enableBackground();
+ } else {
+ result = disableBackground();
+ }
}
-
- return result;
+
+ return result;
}
/**
@@ -513,7 +557,7 @@ public class AntService extends Service
}
// create a single new JAnt HCI Interface instance
mJAnt = new JAntJava();
- mRequiresBluetoothOn = isQcomPlatform();
+ mRequiresBluetoothOn = requiresBluetoothOn();
JAntStatus createResult = mJAnt.create(mJAntCallback);
if (createResult == JAntStatus.SUCCESS)
@@ -533,6 +577,12 @@ public class AntService extends Service
filter.addAction(ACTION_REQUEST_ENABLE);
filter.addAction(ACTION_REQUEST_DISABLE);
registerReceiver(mReceiver, filter);
+
+ if (mRequiresBluetoothOn) {
+ IntentFilter stateChangedFilter = new IntentFilter();
+ stateChangedFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
+ registerReceiver(mStateChangedReceiver, stateChangedFilter);
+ }
}
@Override
@@ -561,6 +611,10 @@ public class AntService extends Service
super.onDestroy();
}
+ if (mRequiresBluetoothOn) {
+ unregisterReceiver(mStateChangedReceiver);
+ }
+
unregisterReceiver(mReceiver);
}