Skip to content

Commit 5e79157

Browse files
committed
Merge branch 'release/v0.0.15'
2 parents c28d5aa + a33480d commit 5e79157

35 files changed

+286
-52
lines changed

BLE-MIDI-library/build.gradle

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@ plugins {
44
}
55

66
android {
7-
compileSdkVersion 33
7+
compileSdk 34
88

99
defaultConfig {
1010
minSdkVersion 18
11-
targetSdkVersion 33
11+
targetSdkVersion 34
1212
}
1313

1414
compileOptions {
15-
sourceCompatibility JavaVersion.VERSION_1_7
16-
targetCompatibility JavaVersion.VERSION_1_7
15+
sourceCompatibility JavaVersion.VERSION_1_8
16+
targetCompatibility JavaVersion.VERSION_1_8
17+
}
18+
19+
defaultConfig {
20+
consumerProguardFiles 'proguard-rules.pro'
1721
}
1822

1923
buildTypes {
20-
release {
24+
debug {
2125
minifyEnabled false
2226
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2327
}
28+
release {
29+
minifyEnabled true
30+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
31+
}
2432
}
2533

2634
publishing {
@@ -50,7 +58,7 @@ publishing {
5058
release(MavenPublication) {
5159
group = 'jp.kshoji'
5260
artifactId = 'ble-midi'
53-
version = '0.0.14'
61+
version = '0.0.15'
5462

5563
afterEvaluate {
5664
from components.release

BLE-MIDI-library/proguard-rules.pro

+27-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1-
# Add project specific ProGuard rules here.
2-
# By default, the flags in this file are appended to flags specified
3-
# in /Applications/Android Studio 0.8.app/sdk/tools/proguard/proguard-android.txt
4-
# You can edit the include path and order by changing the proguardFiles
5-
# directive in build.gradle.
6-
#
7-
# For more details, see
8-
# http://developer.android.com/guide/developing/tools/proguard.html
1+
-keep public class jp.kshoji.blemidi.** {
2+
public protected *;
3+
}
4+
-keep public class jp.kshoji.javax.sound.midi.** {
5+
public protected *;
6+
}
7+
-keep public class jp.kshoji.unity.midi.** {
8+
public protected *;
9+
}
910

10-
# Add any project specific keep options here:
11+
-keepparameternames
12+
-renamesourcefileattribute SourceFile
13+
-keepattributes Signature,Exceptions,*Annotation*,
14+
InnerClasses,PermittedSubclasses,EnclosingMethod,
15+
Deprecated,SourceFile,LineNumberTable
1116

12-
# If your project uses WebView with JS, uncomment the following
13-
# and specify the fully qualified class name to the JavaScript interface
14-
# class:
15-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16-
# public *;
17-
#}
17+
-keepclassmembers,allowoptimization enum * {
18+
public static **[] values();
19+
public static ** valueOf(java.lang.String);
20+
}
21+
22+
-keepclassmembers class * implements java.io.Serializable {
23+
static final long serialVersionUID;
24+
private static final java.io.ObjectStreamField[] serialPersistentFields;
25+
private void writeObject(java.io.ObjectOutputStream);
26+
private void readObject(java.io.ObjectInputStream);
27+
java.lang.Object writeReplace();
28+
java.lang.Object readResolve();
29+
}

BLE-MIDI-library/src/main/java/jp/kshoji/blemidi/central/BleMidiCallback.java

+29-8
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public final class BleMidiCallback extends BluetoothGattCallback {
5151
private final Map<String, String> deviceAddressManufacturerMap = new HashMap<>();
5252
private final Map<String, String> deviceAddressModelMap = new HashMap<>();
5353

54-
List<Runnable> gattRequestQueue = new ArrayList<>();
54+
final List<Runnable> gattRequestQueue = new ArrayList<>();
5555
private final Context context;
5656

5757
private OnMidiDeviceAttachedListener midiDeviceAttachedListener;
@@ -160,10 +160,28 @@ public void run() {
160160
gattRequestQueue.add(new Runnable() {
161161
@Override
162162
public void run() {
163-
// request maximum MTU size
164-
// this calls onMtuChanged after completed
165-
boolean result = gatt.requestMtu(517); // GATT_MAX_MTU_SIZE defined at `stack/include/gatt_api.h`
166-
Log.d(Constants.TAG, "Central requestMtu address: " + gatt.getDevice().getAddress() + ", succeed: " + result);
163+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
164+
// Android 14: the default MTU size set to 517
165+
// https://developer.android.com/about/versions/14/behavior-changes-all#mtu-set-to-517
166+
final int mtu = 517;
167+
synchronized (midiOutputDevicesMap) {
168+
Set<MidiOutputDevice> midiOutputDevices = midiOutputDevicesMap.get(gatt.getDevice().getAddress());
169+
if (midiOutputDevices != null) {
170+
for (MidiOutputDevice midiOutputDevice : midiOutputDevices) {
171+
((InternalMidiOutputDevice) midiOutputDevice).setBufferSize(mtu - 3);
172+
}
173+
}
174+
}
175+
176+
if (gattRequestQueue.size() > 0) {
177+
gattRequestQueue.remove(0).run();
178+
}
179+
} else {
180+
// request maximum MTU size
181+
// this calls onMtuChanged after completed
182+
boolean result = gatt.requestMtu(517); // GATT_MAX_MTU_SIZE defined at `stack/include/gatt_api.h`
183+
Log.d(Constants.TAG, "Central requestMtu address: " + gatt.getDevice().getAddress() + ", succeed: " + result);
184+
}
167185
}
168186
});
169187
}
@@ -789,10 +807,13 @@ public void configureAsCentralDevice() {
789807

790808
@Override
791809
public void transferData(@NonNull byte[] writeBuffer) throws SecurityException {
792-
midiOutputCharacteristic.setValue(writeBuffer);
793-
794810
try {
795-
bluetoothGatt.writeCharacteristic(midiOutputCharacteristic);
811+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
812+
bluetoothGatt.writeCharacteristic(midiOutputCharacteristic, writeBuffer, BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
813+
} else {
814+
midiOutputCharacteristic.setValue(writeBuffer);
815+
bluetoothGatt.writeCharacteristic(midiOutputCharacteristic);
816+
}
796817
} catch (Throwable ignored) {
797818
// android.os.DeadObjectException will be thrown
798819
// ignore it

BLE-MIDI-library/src/main/java/jp/kshoji/blemidi/device/MidiOutputDevice.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void run() {
7676

7777
while (true) {
7878
// running
79-
while (!transferDataThreadAlive && isRunning) {
79+
while (transferDataThreadAlive && isRunning) {
8080
synchronized (transferDataStream) {
8181
if (writtenDataCount > 0) {
8282
transferData(transferDataStream.toByteArray());
@@ -167,6 +167,8 @@ private void storeTransferData(byte[] data) {
167167
writtenDataCount += data.length;
168168
} catch (IOException ignored) {
169169
}
170+
171+
transferDataThread.interrupt();
170172
}
171173
}
172174

UnityPlayerMock/build.gradle

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

33
android {
4-
compileSdkVersion 33
4+
compileSdk 34
55

66
defaultConfig {
77
minSdkVersion 18
8-
targetSdkVersion 33
8+
targetSdkVersion 34
99
}
1010

1111
compileOptions {
12-
sourceCompatibility JavaVersion.VERSION_1_7
13-
targetCompatibility JavaVersion.VERSION_1_7
12+
sourceCompatibility JavaVersion.VERSION_1_8
13+
targetCompatibility JavaVersion.VERSION_1_8
1414
}
1515

1616
buildTypes {

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
google()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:8.2.0'
9+
classpath 'com.android.tools.build:gradle:8.3.1'
1010

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

gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m
2323
#android.defaults.buildfeatures.buildconfig=true
2424
android.nonTransitiveRClass=false
2525
android.nonFinalResIds=false
26+
org.gradle.configuration-cache=true

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
19e3e2462a40cb35401640b5f875359b
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3ad83424e4db9d8e5c25844060f99f4a9f08a673
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
853cbd4d6d6fb23dede75d911cab3fe8a56f0e98cb8ff104bc9bd76528a3b587
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f48aaf2791211c2e6cb8de09722be5751fefc38db868a72bc714f5ed5c7655f21cdd4e8b51bc2190046e545be97fb2f01ba97c230e86c8d9c513c9ee08a618a9
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
83631d14a5293675b87d506b755bcf47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8756d18aaa2d4c1cb67b08841003e56b3c6652ba
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
aa4d1d0d19c13aeacda6801ef1abff5b4e86f1b55baf645035ed5f3c71240ee9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5d6e95bfa8c3b3fb90d9b06dcdd38dd2bba578789c936dcd87fa1fc5b3d479066d770e3d1d1012311856530110906aab81bf5035ac7f91b0f235e05cb683b31c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"formatVersion": "1.1",
3+
"component": {
4+
"group": "jp.kshoji",
5+
"module": "ble-midi",
6+
"version": "0.0.15",
7+
"attributes": {
8+
"org.gradle.status": "release"
9+
}
10+
},
11+
"createdBy": {
12+
"gradle": {
13+
"version": "8.4"
14+
}
15+
},
16+
"variants": [
17+
{
18+
"name": "releaseVariantReleaseApiPublication",
19+
"attributes": {
20+
"org.gradle.category": "library",
21+
"org.gradle.dependency.bundling": "external",
22+
"org.gradle.libraryelements": "aar",
23+
"org.gradle.usage": "java-api"
24+
},
25+
"dependencies": [
26+
{
27+
"group": "jp.kshoji",
28+
"module": "javax-sound-midi",
29+
"version": {
30+
"requires": "0.0.4"
31+
},
32+
"excludes": [
33+
{
34+
"group": "*",
35+
"module": "*"
36+
}
37+
],
38+
"thirdPartyCompatibility": {
39+
"artifactSelector": {
40+
"name": "javax-sound-midi",
41+
"type": "aar",
42+
"extension": "aar"
43+
}
44+
}
45+
},
46+
{
47+
"group": "com.android.support",
48+
"module": "support-annotations",
49+
"version": {
50+
"requires": "28.0.0"
51+
}
52+
}
53+
],
54+
"files": [
55+
{
56+
"name": "ble-midi-0.0.15.aar",
57+
"url": "ble-midi-0.0.15.aar",
58+
"size": 100902,
59+
"sha512": "5d6e95bfa8c3b3fb90d9b06dcdd38dd2bba578789c936dcd87fa1fc5b3d479066d770e3d1d1012311856530110906aab81bf5035ac7f91b0f235e05cb683b31c",
60+
"sha256": "aa4d1d0d19c13aeacda6801ef1abff5b4e86f1b55baf645035ed5f3c71240ee9",
61+
"sha1": "8756d18aaa2d4c1cb67b08841003e56b3c6652ba",
62+
"md5": "83631d14a5293675b87d506b755bcf47"
63+
}
64+
]
65+
},
66+
{
67+
"name": "releaseVariantReleaseRuntimePublication",
68+
"attributes": {
69+
"org.gradle.category": "library",
70+
"org.gradle.dependency.bundling": "external",
71+
"org.gradle.libraryelements": "aar",
72+
"org.gradle.usage": "java-runtime"
73+
},
74+
"dependencies": [
75+
{
76+
"group": "jp.kshoji",
77+
"module": "javax-sound-midi",
78+
"version": {
79+
"requires": "0.0.4"
80+
},
81+
"excludes": [
82+
{
83+
"group": "*",
84+
"module": "*"
85+
}
86+
],
87+
"thirdPartyCompatibility": {
88+
"artifactSelector": {
89+
"name": "javax-sound-midi",
90+
"type": "aar",
91+
"extension": "aar"
92+
}
93+
}
94+
},
95+
{
96+
"group": "com.android.support",
97+
"module": "support-annotations",
98+
"version": {
99+
"requires": "28.0.0"
100+
}
101+
}
102+
],
103+
"files": [
104+
{
105+
"name": "ble-midi-0.0.15.aar",
106+
"url": "ble-midi-0.0.15.aar",
107+
"size": 100902,
108+
"sha512": "5d6e95bfa8c3b3fb90d9b06dcdd38dd2bba578789c936dcd87fa1fc5b3d479066d770e3d1d1012311856530110906aab81bf5035ac7f91b0f235e05cb683b31c",
109+
"sha256": "aa4d1d0d19c13aeacda6801ef1abff5b4e86f1b55baf645035ed5f3c71240ee9",
110+
"sha1": "8756d18aaa2d4c1cb67b08841003e56b3c6652ba",
111+
"md5": "83631d14a5293675b87d506b755bcf47"
112+
}
113+
]
114+
},
115+
{
116+
"name": "releaseVariantReleaseSourcePublication",
117+
"attributes": {
118+
"org.gradle.category": "documentation",
119+
"org.gradle.dependency.bundling": "external",
120+
"org.gradle.docstype": "sources",
121+
"org.gradle.usage": "java-runtime"
122+
},
123+
"files": [
124+
{
125+
"name": "ble-midi-0.0.15-sources.jar",
126+
"url": "ble-midi-0.0.15-sources.jar",
127+
"size": 45880,
128+
"sha512": "f48aaf2791211c2e6cb8de09722be5751fefc38db868a72bc714f5ed5c7655f21cdd4e8b51bc2190046e545be97fb2f01ba97c230e86c8d9c513c9ee08a618a9",
129+
"sha256": "853cbd4d6d6fb23dede75d911cab3fe8a56f0e98cb8ff104bc9bd76528a3b587",
130+
"sha1": "3ad83424e4db9d8e5c25844060f99f4a9f08a673",
131+
"md5": "19e3e2462a40cb35401640b5f875359b"
132+
}
133+
]
134+
}
135+
]
136+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9c5d6e746959b389094169b9c3e6da31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
13f4e8eb6526683d7e2b8d43caead48afa363a71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
aee1f9dd880454d611f1bfe06699b74d1c185979e0286113ae22e3b3c4f894b2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
27b4dad64eb1a6106f334723bd5abc92f4011c45bf1824956907af75e45386fbb0440f39e1c758b8941a649d03703ca9d8c923ec02f3a387bc2ae9ae17053ab1

0 commit comments

Comments
 (0)