Skip to content

Commit

Permalink
Merge branch 'release/v0.0.9'
Browse files Browse the repository at this point in the history
# Conflicts:
#	library/build.gradle
#	library/repository/jp/kshoji/ble-midi/maven-metadata.xml
#	library/repository/jp/kshoji/ble-midi/maven-metadata.xml.md5
#	library/repository/jp/kshoji/ble-midi/maven-metadata.xml.sha1
  • Loading branch information
kshoji committed Dec 15, 2015
2 parents 31cae54 + 9c74db1 commit b3a0c04
Show file tree
Hide file tree
Showing 45 changed files with 1,309 additions and 469 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
language: android
jdk: openjdk7
jdk: oraclejdk7
android:
components:
- build-tools-21.1.2
- build-tools-22.0.1
- android-22
- extra-android-m2repository
- android-21
- extra-google-m2repository
licenses:
- '.+'
before_install:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.android.tools.build:gradle:1.5.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
14 changes: 6 additions & 8 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
}

compileOptions {
Expand All @@ -32,8 +29,9 @@ repositories {
}

dependencies {
compile 'jp.kshoji:javax-sound-midi:0.0.2:@aar'
compile 'com.android.support:support-annotations:21.0.3'
compile 'jp.kshoji:javax-sound-midi:0.0.3:@aar'
//noinspection GradleDependency
compile 'com.android.support:support-annotations:22.2.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
}

Expand All @@ -42,7 +40,7 @@ group = 'jp.kshoji'
uploadArchives {
repositories.mavenDeployer {
repository url: 'file://' + file('repository').absolutePath
pom.version = '0.0.8'
pom.version = '0.0.9'
pom.artifactId = 'ble-midi'
}
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
da97f6b38cc65065c98f50f5306db731
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
07465c27eb11fd7b5e24d6a5fd7c414c3fce6982
24 changes: 24 additions & 0 deletions library/repository/jp/kshoji/ble-midi/0.0.9/ble-midi-0.0.9.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>jp.kshoji</groupId>
<artifactId>ble-midi</artifactId>
<version>0.0.9</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>jp.kshoji</groupId>
<artifactId>javax-sound-midi</artifactId>
<version>0.0.3</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-annotations</artifactId>
<version>22.2.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
553afead6d77dc25405ca25a681f6838
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
602fdb77e089d4220508fb54124cc6912409ee95
3 changes: 2 additions & 1 deletion library/repository/jp/kshoji/ble-midi/maven-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<version>0.0.6</version>
<version>0.0.7</version>
<version>0.0.8</version>
<version>0.0.9</version>
</versions>
<lastUpdated>20150430030503</lastUpdated>
<lastUpdated>20151215053958</lastUpdated>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
026f2e59aa250d3ab9a576185506d04c
b92c0a930ddf88bc20a5fb32a5b45d20
Original file line number Diff line number Diff line change
@@ -1 +1 @@
243689f724241aba812ecf9ca614adfe6d78f71c
5da16141807740ebb9c05ee9a647514647f13f76
3 changes: 2 additions & 1 deletion library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jp.kshoji.blemidi">

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public void onServicesDiscovered(final BluetoothGatt gatt, int status) {
synchronized (midiInputDevicesMap) {
Set<MidiInputDevice> midiInputDevices = midiInputDevicesMap.get(gattDeviceAddress);
for (MidiInputDevice midiInputDevice : midiInputDevices) {
((InternalMidiInputDevice) midiInputDevice).stop();
midiInputDevice.setOnMidiInputEventListener(null);
}
midiInputDevicesMap.remove(gattDeviceAddress);
Expand Down Expand Up @@ -285,6 +286,7 @@ private void disconnectByDeviceAddress(@NonNull String deviceAddress) {
midiInputDevicesMap.remove(deviceAddress);

for (MidiInputDevice midiInputDevice : midiInputDevices) {
((InternalMidiInputDevice) midiInputDevice).stop();
midiInputDevice.setOnMidiInputEventListener(null);

if (midiDeviceDetachedListener != null) {
Expand Down Expand Up @@ -326,6 +328,7 @@ public void terminate() {
synchronized (midiInputDevicesMap) {
for (Set<MidiInputDevice> midiInputDevices : midiInputDevicesMap.values()) {
for (MidiInputDevice midiInputDevice : midiInputDevices) {
((InternalMidiInputDevice) midiInputDevice).stop();
midiInputDevice.setOnMidiInputEventListener(null);
}

Expand Down Expand Up @@ -488,6 +491,13 @@ public InternalMidiInputDevice(@NonNull final Context context, @NonNull final Bl
}
}

/**
* Stops parser's thread
*/
void stop() {
midiParser.stop();
}

/**
* Configure the device as BLE Central
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public interface OnMidiInputEventListener {
* MIDI Time Code(MTC) Quarter Frame
*
* @param sender the device sent this message
* @param timing 0-127
* @param timing 0-16383
*/
void onMidiTimeCodeQuarterFrame(@NonNull MidiInputDevice sender, int timing);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,26 @@ public void startAdvertising() {

// these service will be listened.
// FIXME these didn't used for service discovery
gattServer.addService(informationGattService);
gattServer.addService(midiGattService);
boolean serviceInitialized = false;
while (!serviceInitialized) {
try {
gattServer.addService(informationGattService);
gattServer.addService(midiGattService);// NullPointerException, DeadObjectException thrown here
serviceInitialized = true;
} catch (Exception e) {
Log.d(Constants.TAG, "Adding Service failed, retrying..");

try {
gattServer.clearServices();
} catch (Throwable ignored) {
}

try {
Thread.sleep(100);
} catch (InterruptedException ignored) {
}
}
}

// set up advertising setting
AdvertiseSettings advertiseSettings = new AdvertiseSettings.Builder()
Expand Down Expand Up @@ -264,6 +282,7 @@ private void disconnectByDeviceAddress(@NonNull String deviceAddress) {
if (midiInputDevice != null) {
midiInputDevicesMap.remove(deviceAddress);

((InternalMidiInputDevice) midiInputDevice).stop();
midiInputDevice.setOnMidiInputEventListener(null);

if (midiDeviceDetachedListener != null) {
Expand Down Expand Up @@ -306,6 +325,7 @@ public void terminate() {

synchronized (midiInputDevicesMap) {
for (MidiInputDevice midiInputDevice : midiInputDevicesMap.values()) {
((InternalMidiInputDevice) midiInputDevice).stop();
midiInputDevice.setOnMidiInputEventListener(null);
}
midiInputDevicesMap.clear();
Expand Down Expand Up @@ -368,6 +388,7 @@ public void onReceive(Context context, Intent intent) {
if (midiInputDevice != null) {
midiInputDevicesMap.remove(deviceAddress);

((InternalMidiInputDevice) midiInputDevice).stop();
midiInputDevice.setOnMidiInputEventListener(null);
if (midiDeviceDetachedListener != null) {
midiDeviceDetachedListener.onMidiInputDeviceDetached(midiInputDevice);
Expand Down Expand Up @@ -572,6 +593,13 @@ public InternalMidiInputDevice(@NonNull BluetoothDevice bluetoothDevice) {
this.bluetoothDevice = bluetoothDevice;
}

/**
* Stops parser's thread
*/
void stop() {
midiParser.stop();
}

@Override
public void setOnMidiInputEventListener(OnMidiInputEventListener midiInputEventListener) {
midiParser.setMidiInputEventListener(midiInputEventListener);
Expand Down
Loading

0 comments on commit b3a0c04

Please sign in to comment.