Skip to content

Commit b3a0c04

Browse files
committed
Merge branch 'release/v0.0.9'
# 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
2 parents 31cae54 + 9c74db1 commit b3a0c04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1309
-469
lines changed

.travis.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
language: android
2-
jdk: openjdk7
2+
jdk: oraclejdk7
33
android:
44
components:
5-
- build-tools-21.1.2
5+
- build-tools-22.0.1
6+
- android-22
67
- extra-android-m2repository
7-
- android-21
8+
- extra-google-m2repository
89
licenses:
910
- '.+'
1011
before_install:

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:1.0.0'
8+
classpath 'com.android.tools.build:gradle:1.5.0'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files

library/build.gradle

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 21
5-
buildToolsVersion "21.1.2"
4+
compileSdkVersion 22
5+
buildToolsVersion "22.0.1"
66

77
defaultConfig {
88
minSdkVersion 18
9-
targetSdkVersion 21
10-
versionCode 1
11-
versionName "1.0"
129
}
1310

1411
compileOptions {
@@ -32,8 +29,9 @@ repositories {
3229
}
3330

3431
dependencies {
35-
compile 'jp.kshoji:javax-sound-midi:0.0.2:@aar'
36-
compile 'com.android.support:support-annotations:21.0.3'
32+
compile 'jp.kshoji:javax-sound-midi:0.0.3:@aar'
33+
//noinspection GradleDependency
34+
compile 'com.android.support:support-annotations:22.2.1'
3735
compile fileTree(dir: 'libs', include: ['*.jar'])
3836
}
3937

@@ -42,7 +40,7 @@ group = 'jp.kshoji'
4240
uploadArchives {
4341
repositories.mavenDeployer {
4442
repository url: 'file://' + file('repository').absolutePath
45-
pom.version = '0.0.8'
43+
pom.version = '0.0.9'
4644
pom.artifactId = 'ble-midi'
4745
}
4846
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
da97f6b38cc65065c98f50f5306db731
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
07465c27eb11fd7b5e24d6a5fd7c414c3fce6982
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>jp.kshoji</groupId>
6+
<artifactId>ble-midi</artifactId>
7+
<version>0.0.9</version>
8+
<packaging>aar</packaging>
9+
<dependencies>
10+
<dependency>
11+
<groupId>jp.kshoji</groupId>
12+
<artifactId>javax-sound-midi</artifactId>
13+
<version>0.0.3</version>
14+
<type>aar</type>
15+
<scope>compile</scope>
16+
</dependency>
17+
<dependency>
18+
<groupId>com.android.support</groupId>
19+
<artifactId>support-annotations</artifactId>
20+
<version>22.2.1</version>
21+
<scope>compile</scope>
22+
</dependency>
23+
</dependencies>
24+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
553afead6d77dc25405ca25a681f6838
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
602fdb77e089d4220508fb54124cc6912409ee95

library/repository/jp/kshoji/ble-midi/maven-metadata.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
<version>0.0.6</version>
1919
<version>0.0.7</version>
2020
<version>0.0.8</version>
21+
<version>0.0.9</version>
2122
</versions>
22-
<lastUpdated>20150430030503</lastUpdated>
23+
<lastUpdated>20151215053958</lastUpdated>
2324
</versioning>
2425
</metadata>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
026f2e59aa250d3ab9a576185506d04c
1+
b92c0a930ddf88bc20a5fb32a5b45d20
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
243689f724241aba812ecf9ca614adfe6d78f71c
1+
5da16141807740ebb9c05ee9a647514647f13f76

library/src/main/AndroidManifest.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="jp.kshoji.blemidi">
3-
3+
<uses-permission android:name="android.permission.BLUETOOTH" />
4+
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
45
</manifest>

library/src/main/java/jp/kshoji/blemidi/central/BleMidiCallback.java

+10
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public void onServicesDiscovered(final BluetoothGatt gatt, int status) {
113113
synchronized (midiInputDevicesMap) {
114114
Set<MidiInputDevice> midiInputDevices = midiInputDevicesMap.get(gattDeviceAddress);
115115
for (MidiInputDevice midiInputDevice : midiInputDevices) {
116+
((InternalMidiInputDevice) midiInputDevice).stop();
116117
midiInputDevice.setOnMidiInputEventListener(null);
117118
}
118119
midiInputDevicesMap.remove(gattDeviceAddress);
@@ -285,6 +286,7 @@ private void disconnectByDeviceAddress(@NonNull String deviceAddress) {
285286
midiInputDevicesMap.remove(deviceAddress);
286287

287288
for (MidiInputDevice midiInputDevice : midiInputDevices) {
289+
((InternalMidiInputDevice) midiInputDevice).stop();
288290
midiInputDevice.setOnMidiInputEventListener(null);
289291

290292
if (midiDeviceDetachedListener != null) {
@@ -326,6 +328,7 @@ public void terminate() {
326328
synchronized (midiInputDevicesMap) {
327329
for (Set<MidiInputDevice> midiInputDevices : midiInputDevicesMap.values()) {
328330
for (MidiInputDevice midiInputDevice : midiInputDevices) {
331+
((InternalMidiInputDevice) midiInputDevice).stop();
329332
midiInputDevice.setOnMidiInputEventListener(null);
330333
}
331334

@@ -488,6 +491,13 @@ public InternalMidiInputDevice(@NonNull final Context context, @NonNull final Bl
488491
}
489492
}
490493

494+
/**
495+
* Stops parser's thread
496+
*/
497+
void stop() {
498+
midiParser.stop();
499+
}
500+
491501
/**
492502
* Configure the device as BLE Central
493503
*/

library/src/main/java/jp/kshoji/blemidi/listener/OnMidiInputEventListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public interface OnMidiInputEventListener {
9090
* MIDI Time Code(MTC) Quarter Frame
9191
*
9292
* @param sender the device sent this message
93-
* @param timing 0-127
93+
* @param timing 0-16383
9494
*/
9595
void onMidiTimeCodeQuarterFrame(@NonNull MidiInputDevice sender, int timing);
9696

library/src/main/java/jp/kshoji/blemidi/peripheral/BleMidiPeripheralProvider.java

+30-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,26 @@ public void startAdvertising() {
155155

156156
// these service will be listened.
157157
// FIXME these didn't used for service discovery
158-
gattServer.addService(informationGattService);
159-
gattServer.addService(midiGattService);
158+
boolean serviceInitialized = false;
159+
while (!serviceInitialized) {
160+
try {
161+
gattServer.addService(informationGattService);
162+
gattServer.addService(midiGattService);// NullPointerException, DeadObjectException thrown here
163+
serviceInitialized = true;
164+
} catch (Exception e) {
165+
Log.d(Constants.TAG, "Adding Service failed, retrying..");
166+
167+
try {
168+
gattServer.clearServices();
169+
} catch (Throwable ignored) {
170+
}
171+
172+
try {
173+
Thread.sleep(100);
174+
} catch (InterruptedException ignored) {
175+
}
176+
}
177+
}
160178

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

285+
((InternalMidiInputDevice) midiInputDevice).stop();
267286
midiInputDevice.setOnMidiInputEventListener(null);
268287

269288
if (midiDeviceDetachedListener != null) {
@@ -306,6 +325,7 @@ public void terminate() {
306325

307326
synchronized (midiInputDevicesMap) {
308327
for (MidiInputDevice midiInputDevice : midiInputDevicesMap.values()) {
328+
((InternalMidiInputDevice) midiInputDevice).stop();
309329
midiInputDevice.setOnMidiInputEventListener(null);
310330
}
311331
midiInputDevicesMap.clear();
@@ -368,6 +388,7 @@ public void onReceive(Context context, Intent intent) {
368388
if (midiInputDevice != null) {
369389
midiInputDevicesMap.remove(deviceAddress);
370390

391+
((InternalMidiInputDevice) midiInputDevice).stop();
371392
midiInputDevice.setOnMidiInputEventListener(null);
372393
if (midiDeviceDetachedListener != null) {
373394
midiDeviceDetachedListener.onMidiInputDeviceDetached(midiInputDevice);
@@ -572,6 +593,13 @@ public InternalMidiInputDevice(@NonNull BluetoothDevice bluetoothDevice) {
572593
this.bluetoothDevice = bluetoothDevice;
573594
}
574595

596+
/**
597+
* Stops parser's thread
598+
*/
599+
void stop() {
600+
midiParser.stop();
601+
}
602+
575603
@Override
576604
public void setOnMidiInputEventListener(OnMidiInputEventListener midiInputEventListener) {
577605
midiParser.setMidiInputEventListener(midiInputEventListener);

0 commit comments

Comments
 (0)