aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2014-08-27 01:57:50 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2014-08-27 01:57:50 -0700
commitd1cd68eca1bbcfe523b365edc9808fe79cc20c90 (patch)
tree6946720660c4772a5592eabf46bc672ce1138ad3
parent5c9ec1753dfcb83b98c26354d92d05f4be4fd808 (diff)
parent83cab5026087debc28bbe8b187655626c55e9103 (diff)
downloadandroid_external_ant-wireless_ant_service-d1cd68eca1bbcfe523b365edc9808fe79cc20c90.tar.gz
android_external_ant-wireless_ant_service-d1cd68eca1bbcfe523b365edc9808fe79cc20c90.tar.bz2
android_external_ant-wireless_ant_service-d1cd68eca1bbcfe523b365edc9808fe79cc20c90.zip
-rw-r--r--.cvsignore8
-rw-r--r--.gitignore33
-rw-r--r--AndroidManifest.xml18
-rw-r--r--NOTICE5
-rw-r--r--README.md34
-rw-r--r--ReleaseNotes.txt210
-rw-r--r--res/drawable-xxhdpi/ic_launcher.pngbin0 -> 85882 bytes
-rw-r--r--res/drawable/icon.pngbin6093 -> 0 bytes
-rw-r--r--src/com/dsi/ant/server/AntService.java74
9 files changed, 94 insertions, 288 deletions
diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index cd8b547..0000000
--- a/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-gen
-bin
-doc
-libs
-assets
-.settings
-secure.properties
-
diff --git a/.gitignore b/.gitignore
index ae0d9e7..cc0f5a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,21 +1,12 @@
-# built application files
-*.apk
-*.ap_
-
-# files for the dex VM
-*.dex
-
-# Java class files
-*.class
-
-# generated files
-bin/
-gen/
-
-# Local configuration file (sdk path, etc)
-local.properties
-# and the not safe to be released part
-secure.properties
-
-# CVS files
-CVS/
+# Ignores for Eclipse
+/.settings/
+
+# Ignores for Android Projects
+/bin/
+/gen/
+/publish/
+/local.properties
+/secure.properties
+
+# Ignores for Mac machines
+.DS_Store \ No newline at end of file
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index dd9cfc2..ebd1541 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.1.1"
- android:versionCode="030101"
+ android:versionName="4.0.0"
+ android:versionCode="030200"
android:sharedUserId="android.uid.system">
<uses-sdk
@@ -25,7 +25,7 @@ limitations under the License.
android:targetSdkVersion="10"
/>
- <application android:icon="@drawable/icon"
+ <application android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:process="system"
android:permission="com.dsi.ant.permission.ANTRADIO" >
@@ -53,18 +53,6 @@ limitations under the License.
</application>
<!-- These permissions should be defined in the system -->
- <permission android:name="com.dsi.ant.permission.ANT"
- android:protectionLevel="dangerous"
- android:permissionGroup="android.permission-group.NETWORK"
- android:description="@string/permdesc_ant"
- android:label="@string/permlab_ant"/>
-
- <permission android:name="com.dsi.ant.permission.ANT_ADMIN"
- android:protectionLevel="dangerous"
- android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
- android:description="@string/permdesc_antAdmin"
- android:label="@string/permlab_antAdmin"/>
-
<permission android:name="com.dsi.ant.permission.ANTRADIO"
android:protectionLevel="dangerous"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index 0dafa6b..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-ANT Android System Package
-Copyright 2009-2012 Dynastream Innovations
-
-This product includes software developed at
-Dynastream Innovations (http://www.dynastream.com/). \ No newline at end of file
diff --git a/README.md b/README.md
index 3ed7db9..debf7ca 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,32 @@
-Android_ANTHALService
-===================== \ No newline at end of file
+# Android ANT HAL Service v.4.0.0 - 25 Aug 2014
+
+The ANT HAL Service functions as a JNI wrapper for the ANT HAL.
+The ANT Hal Service provides the messaging and state control interface
+to the built-in adapter for the ANT Radio Service to interact with.
+
+
+## License
+
+Copyright 2009-2014 Dynastream Innovations
+
+This product includes software developed at
+Dynastream Innovations (http://www.dynastream.com/).
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+## Changelog
+
+v4.0.0 - 25 Aug 2014 (changes since 3.2.0)
+-------------------------------------------------------------
+> * Remove ANT and ANT_ADMIN permission defines which conflict with ANT Radio Service defines with new Android L permission behaviour (INSTALL_FAILED_DUPLICATE_PERMISSIONS_ERROR) \ No newline at end of file
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
deleted file mode 100644
index 9f4f8f4..0000000
--- a/ReleaseNotes.txt
+++ /dev/null
@@ -1,210 +0,0 @@
-AntHalService - Release Notes
-v3.1.1
-2013-11-18
-
-Copyright 2011 Dynastream Innovations
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-=============================================================
-1. USAGE
-
-The ANT HAL Service provides a transport from the ANT Radio Service (or
-any application which binds to IAntHal AIDL) through JNI to the native ANT
-stack code (libantradio.so). It provides the basics of send/recieve Rx
-messages, enable, disable and get the enebaled state.
-
-=============================================================
-2. REVISION HISTORY
-
-v.3.1.1: 2013-11-18 : Android_System_ANTHALService_3-1-0
-Improvement
- [ANTDROID-2223] - Disable "Need BT On for ANT" logic by default
-
--------------------------------------------------------------
-
-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
-
- [ANTDROID-1383] - Can not build for Android 4.2 [Delete integration with BluetoothService]
- [ANTDROID-1389] - onDestroy() starts new disable thread, when it should be ensuring there are no threads left running
-
--------------------------------------------------------------
-
-v2.1.0 : 2012-07-20 : Android_System_ANTHALService_2-1-0
-
-Bug
-
- [ANTDROID-992] - getEnabledState returns disabled while ANT is enabling in BT service
- [ANTDROID-1007] - if enable is called, and already enabled, ENABLED then ENABLING is sent out
-
-Task
-
- [ANTDROID-1256] - Remove "DSI BlueZ" from name as service is generic
- [ANTDROID-1248] - Remove full path from repository
- [ANTDROID-1286] - Synchronise all updating of state
-
--------------------------------------------------------------
-
-v2.0.0 : 2012-07-20 : Android_System_ANTHALService_2-0-0
-
-Improvement
-
- * [ANTDROID-614] - Specify targetSdkVersion to let the system use compatibility behaviours for newer versions
-
-New Feature
-
- * [ANTDROID-953] - Do ANT enable/disable through BluetoothService ANT methods if they exist
-
-Task
-
- * [ANTDROID-938] - .classpath needs new entry for ADT Libraries
-
-Sub-task
-
- * [ANTDROID-786] - Only include LICENCE and NOTICE in system-package_X directories
-
--------------------------------------------------------------
-
-v1.3.2 : 2012-04-02 : Android_System_ANTHALService_1-3-2
-
-Bug
-
- [ANTDROID-570] - Unregister callback does not work correctly
-
-New Feature
-
- [ANTDROID-611] - Define meta-data to notify that this service provides a connection to built-in ANT hardware
-
--------------------------------------------------------------
-
-v1.3.1 : 2012-03-20 : Android_System_ANTHALService_1-3-1
-
-Bug
-
- [ANTDROID-533] - Document how to build in to Android with a single HOWTO for each platform type (not seperate steps per component)
-
--------------------------------------------------------------
-
-v1.3.0 : 2012-02-22 : Android_System_AntHalService_1-3-0
-
-Code Task
-
- * [ANTDROID-510] - Project has both proguard.cfg and proguard.flags files
-
-Improvement
-
- * [ANTDROID-511] - Create Hard Reset call from ARS to native
-
-New Feature
-
- * [ANTDROID-483] - configure ANT in Android build by chip
-
-Sub-task
-
- * [ANTDROID-481] - create callback for native code so it can do state change intents
-
-
--------------------------------------------------------------
-
-v1.2.0 : 2011-12-12 : Android_System_AntHalService_1-2-0
-
-Bug
-
- * [ANTDROID-314] - An unsuccessful JAntJava.create() doesn't do anything
- * [ANTDROID-380] - Change target API to 7 for onStartCommand() support
- * [ANTDROID-382] - Service will not run for ever once restarted after being destroyed
- * [ANTDROID-384] - Nullpointer in disable thread if onDestroy was called
-
-Code Task
-
- * [ANTDROID-126] - Ensure header/license is on all possibly released source files
- * [ANTDROID-331] - Update/Sync up documentation of AIDL system service interface
- * [ANTDROID-338] - Update projects for ADT r14 (naming and configuration)
-
-Improvement
-
- * [ANTDROID-222] - Each component adding to/modifying Android framework should include full path within Android source
-
-New Feature
-
- * [ANTDROID-7] - Check if "ant" is in Settings.System.AIRPLANE_MODE_RADIOS.
-
-Task
-
- * [ANTDROID-197] - Individual "how to include in build" file for each component, and Vendors Package HOW TO just says what the components are and where to find HOW TO for each
-
--------------------------------------------------------------
-
-v1.1.0 : 2011-10-14 : Android_System_AntHalService_1-1-0
-
-Bug
-
- * [ANTDROID-198] - "Commented out mutex on tx message to test lower level mutex" commit, but change still exists
- * [ANTDROID-215] - Manifest does not point to correct location of BootCompletedReceiver class
-
-Improvement
-
- * [ANTDROID-170] - ANT HAL Service should start at BOOT_COMPLETED and run forever
- * [ANTDROID-214] - Remove unnecessary Bluetooth and Vibrate permissions
- * [ANTDROID-223] - Put enable and disable on their own threads
-
-Task
-
- * [ANTDROID-176] - Create ANT HAL Service Release Notes / Revision history / versioning
-
--------------------------------------------------------------
-
-v1.0.0 : 2011-09-15 : Android_System_AntHalService_1-0-0
-
-Bug
-
- * [ANTDROID-147] - Dead objects in AntService.java mCallbackList are not cleared
- * [ANTDROID-149] - AntService and JAntJava are able to register multiple callback functions
-
-Improvement
-
- * [ANTDROID-232] - Use a single JAntJava instance across enable/disables
- * [ANTDROID-233] - Get state (enabled, enabling,...) of ANT chip from lowest layer
- * [ANTDROID-234] - ANT System Service as independent application (not a thread in system_process)
-
-Task
-
- * [ANTDROID-243] - Treat each component as independent from others (ie stack library, service, command line app, bluedroid rework)
-
--------------------------------------------------------------
-
-Previous versions were not a stand-alone component.
-
-=============================================================
-3. TODO
-
-ANTDROID-685 Update to follow Android Code Style guidelines
-ANTDROID-383 Allow multiple clients to register IAntHalCallback
-ANTDROID-346 Create AntHalLib
-ANTDROID-309 What is Version.java used for for AntHal?
-ANTDROID-246 Store platform specific values in system settings
-ANTDROID-244 Separate data and command paths
-
-=============================================================
-4. KNOWN ISSUES
-
-ANTDROID-961 On a phone with no BluetoothService, ANT HAL will not work
-ANTDROID-615 When debugging, registerCallback() doesn't check if callback is null before logging value
diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..50efac8
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/res/drawable/icon.png b/res/drawable/icon.png
deleted file mode 100644
index 4bd12b3..0000000
--- a/res/drawable/icon.png
+++ /dev/null
Binary files differ
diff --git a/src/com/dsi/ant/server/AntService.java b/src/com/dsi/ant/server/AntService.java
index 92e4e67..4e6f891 100644
--- a/src/com/dsi/ant/server/AntService.java
+++ b/src/com/dsi/ant/server/AntService.java
@@ -80,7 +80,11 @@ public class AntService extends Service
private Object mChangeAntPowerState_LOCK = new Object();
private static Object sAntHalServiceDestroy_LOCK = new Object();
- IAntHalCallback mCallback;
+ /** Callback object for sending events to the upper layers */
+ private volatile IAntHalCallback mCallback;
+ /** Used for synchronizing changes to {@link #mCallback}
+ * The synchronization is needed because of how {@link #doUnregisterAntHalCallback(IAntHalCallback)} works */
+ private final Object mCallback_LOCK = new Object();
/**
* Receives Bluetooth State Changed intent and sends {@link ACTION_REQUEST_ENABLE}
@@ -126,7 +130,7 @@ public class AntService extends Service
}
/**
- * Calls back the registered callback with the change to the new state
+ * Calls back the registered callback with the change to the new state
* @param state the {@link AntHalDefine} state
*/
private void setState(int state)
@@ -134,13 +138,16 @@ public class AntService extends Service
synchronized(mChangeAntPowerState_LOCK) {
if(DEBUG) Log.i(TAG, "Setting ANT State = "+ state +" / "+ AntHalDefine.getAntHalStateString(state));
- if (mCallback != null)
+ // Use caching instead of synchronization so that we do not have to hold a lock during a callback.
+ // It is safe to not hold the lock because we are not doing any write accesses.
+ IAntHalCallback callback = mCallback;
+ if (callback != null)
{
try
{
- if(DEBUG) Log.d(TAG, "Calling status changed callback "+ mCallback.toString());
+ if(DEBUG) Log.d(TAG, "Calling status changed callback "+ callback.toString());
- mCallback.antHalStateChanged(state);
+ callback.antHalStateChanged(state);
}
catch (RemoteException e)
{
@@ -188,7 +195,7 @@ public class AntService extends Service
waitForBluetoothToEnable = true;
mEnablePending = true;
-
+
boolean isEnabling = bluetoothAdapter.enable();
// if enabling adapter has begun, return
@@ -222,7 +229,7 @@ public class AntService extends Service
break;
}
}
-
+
return result;
}
}
@@ -236,7 +243,7 @@ public class AntService extends Service
if(DEBUG) Log.v(TAG, "doGetAntState start");
int retState = mJAnt.getRadioEnabledStatus(); // ANT state is native state
-
+
if(DEBUG) Log.i(TAG, "Get ANT State = "+ retState +" / "+ AntHalDefine.getAntHalStateString(retState));
return retState;
@@ -244,11 +251,9 @@ public class AntService extends Service
/**
* Perform a power change if required.
- * Tries to use changeAntWirelessState() in {@link BluetoothService}. If it does not exist then
- * it defaults to a native enable() or disable() call
* @param state true for enable, false for disable
- * @return {@link AntHalDefine#ANT_HAL_RESULT_SUCCESS} when the request is successfully sent,
- * false otherwise
+ * @return {@link AntHalDefine#ANT_HAL_RESULT_SUCCESS} when the request has
+ * been posted, false otherwise
*/
private int asyncSetAntPowerState(final boolean state)
{
@@ -435,7 +440,10 @@ public class AntService extends Service
{
if(DEBUG) Log.i(TAG, "Registering callback: "+ callback.toString());
- mCallback = callback;
+ synchronized(mCallback_LOCK)
+ {
+ mCallback = callback;
+ }
return AntHalDefine.ANT_HAL_RESULT_SUCCESS;
}
@@ -446,10 +454,13 @@ public class AntService extends Service
int result = AntHalDefine.ANT_HAL_RESULT_FAIL_UNKNOWN;
- if(mCallback.asBinder() == callback.asBinder())
+ synchronized (mCallback_LOCK)
{
- mCallback = null;
- result = AntHalDefine.ANT_HAL_RESULT_SUCCESS;
+ if(mCallback.asBinder() == callback.asBinder())
+ {
+ mCallback = null;
+ result = AntHalDefine.ANT_HAL_RESULT_SUCCESS;
+ }
}
return result;
@@ -535,7 +546,7 @@ public class AntService extends Service
if (DEBUG) Log.d(TAG, "onCreate() entered");
super.onCreate();
-
+
if(null != mJAnt)
{
// This somehow happens when quickly starting/stopping an application.
@@ -548,9 +559,9 @@ public class AntService extends Service
if (createResult == JAntStatus.SUCCESS)
{
- mInitialized = true;
+ mInitialized = true;
- if (DEBUG) Log.d(TAG, "JAntJava create success");
+ if (DEBUG) Log.d(TAG, "JAntJava create success");
}
else
{
@@ -563,7 +574,7 @@ 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);
@@ -578,19 +589,22 @@ public class AntService extends Service
try
{
- synchronized(sAntHalServiceDestroy_LOCK)
+ synchronized(sAntHalServiceDestroy_LOCK)
{
if(null != mJAnt)
{
int result = disableBlocking();
if (DEBUG) Log.d(TAG, "onDestroy: disable result is: " + AntHalDefine.getAntHalResultString(result));
-
+
mJAnt.destroy();
mJAnt = null;
}
}
- mCallback = null;
+ synchronized (mCallback_LOCK)
+ {
+ mCallback = null;
+ }
}
finally
{
@@ -633,7 +647,10 @@ public class AntService extends Service
{
if (DEBUG) Log.d(TAG, "onUnbind() entered");
- mCallback = null;
+ synchronized (mCallback_LOCK)
+ {
+ mCallback = null;
+ }
return super.onUnbind(intent);
}
@@ -657,11 +674,14 @@ public class AntService extends Service
{
public synchronized void ANTRxMessage( byte[] message)
{
- if(null != mCallback)
+ // Use caching instead of synchronization so that we do not have to hold a lock during a callback.
+ // It is safe to not hold the lock because we are not doing any write accesses.
+ IAntHalCallback callback = mCallback;
+ if(null != callback)
{
try
{
- mCallback.antHalRxMessage(message);
+ callback.antHalRxMessage(message);
}
catch (RemoteException e)
{
@@ -678,7 +698,7 @@ public class AntService extends Service
public synchronized void ANTStateChange(int NewState)
{
if (DEBUG) Log.i(TAG, "ANTStateChange callback to " + NewState);
-
+
setState(NewState);
}
};