Skip to content

Commit

Permalink
Merge branch 'release/v0.0.15'
Browse files Browse the repository at this point in the history
  • Loading branch information
kshoji committed Apr 8, 2024
2 parents c28d5aa + a33480d commit 5e79157
Show file tree
Hide file tree
Showing 35 changed files with 286 additions and 52 deletions.
20 changes: 14 additions & 6 deletions BLE-MIDI-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,31 @@ plugins {
}

android {
compileSdkVersion 33
compileSdk 34

defaultConfig {
minSdkVersion 18
targetSdkVersion 33
targetSdkVersion 34
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
consumerProguardFiles 'proguard-rules.pro'
}

buildTypes {
release {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

publishing {
Expand Down Expand Up @@ -50,7 +58,7 @@ publishing {
release(MavenPublication) {
group = 'jp.kshoji'
artifactId = 'ble-midi'
version = '0.0.14'
version = '0.0.15'

afterEvaluate {
from components.release
Expand Down
42 changes: 27 additions & 15 deletions BLE-MIDI-library/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Applications/Android Studio 0.8.app/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
-keep public class jp.kshoji.blemidi.** {
public protected *;
}
-keep public class jp.kshoji.javax.sound.midi.** {
public protected *;
}
-keep public class jp.kshoji.unity.midi.** {
public protected *;
}

# Add any project specific keep options here:
-keepparameternames
-renamesourcefileattribute SourceFile
-keepattributes Signature,Exceptions,*Annotation*,
InnerClasses,PermittedSubclasses,EnclosingMethod,
Deprecated,SourceFile,LineNumberTable

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keepclassmembers,allowoptimization enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public final class BleMidiCallback extends BluetoothGattCallback {
private final Map<String, String> deviceAddressManufacturerMap = new HashMap<>();
private final Map<String, String> deviceAddressModelMap = new HashMap<>();

List<Runnable> gattRequestQueue = new ArrayList<>();
final List<Runnable> gattRequestQueue = new ArrayList<>();
private final Context context;

private OnMidiDeviceAttachedListener midiDeviceAttachedListener;
Expand Down Expand Up @@ -160,10 +160,28 @@ public void run() {
gattRequestQueue.add(new Runnable() {
@Override
public void run() {
// request maximum MTU size
// this calls onMtuChanged after completed
boolean result = gatt.requestMtu(517); // GATT_MAX_MTU_SIZE defined at `stack/include/gatt_api.h`
Log.d(Constants.TAG, "Central requestMtu address: " + gatt.getDevice().getAddress() + ", succeed: " + result);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
// Android 14: the default MTU size set to 517
// https://developer.android.com/about/versions/14/behavior-changes-all#mtu-set-to-517
final int mtu = 517;
synchronized (midiOutputDevicesMap) {
Set<MidiOutputDevice> midiOutputDevices = midiOutputDevicesMap.get(gatt.getDevice().getAddress());
if (midiOutputDevices != null) {
for (MidiOutputDevice midiOutputDevice : midiOutputDevices) {
((InternalMidiOutputDevice) midiOutputDevice).setBufferSize(mtu - 3);
}
}
}

if (gattRequestQueue.size() > 0) {
gattRequestQueue.remove(0).run();
}
} else {
// request maximum MTU size
// this calls onMtuChanged after completed
boolean result = gatt.requestMtu(517); // GATT_MAX_MTU_SIZE defined at `stack/include/gatt_api.h`
Log.d(Constants.TAG, "Central requestMtu address: " + gatt.getDevice().getAddress() + ", succeed: " + result);
}
}
});
}
Expand Down Expand Up @@ -789,10 +807,13 @@ public void configureAsCentralDevice() {

@Override
public void transferData(@NonNull byte[] writeBuffer) throws SecurityException {
midiOutputCharacteristic.setValue(writeBuffer);

try {
bluetoothGatt.writeCharacteristic(midiOutputCharacteristic);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
bluetoothGatt.writeCharacteristic(midiOutputCharacteristic, writeBuffer, BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
} else {
midiOutputCharacteristic.setValue(writeBuffer);
bluetoothGatt.writeCharacteristic(midiOutputCharacteristic);
}
} catch (Throwable ignored) {
// android.os.DeadObjectException will be thrown
// ignore it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void run() {

while (true) {
// running
while (!transferDataThreadAlive && isRunning) {
while (transferDataThreadAlive && isRunning) {
synchronized (transferDataStream) {
if (writtenDataCount > 0) {
transferData(transferDataStream.toByteArray());
Expand Down Expand Up @@ -167,6 +167,8 @@ private void storeTransferData(byte[] data) {
writtenDataCount += data.length;
} catch (IOException ignored) {
}

transferDataThread.interrupt();
}
}

Expand Down
8 changes: 4 additions & 4 deletions UnityPlayerMock/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 33
compileSdk 34

defaultConfig {
minSdkVersion 18
targetSdkVersion 33
targetSdkVersion 34
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.0'
classpath 'com.android.tools.build:gradle:8.3.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m
#android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
org.gradle.configuration-cache=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
19e3e2462a40cb35401640b5f875359b
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3ad83424e4db9d8e5c25844060f99f4a9f08a673
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
853cbd4d6d6fb23dede75d911cab3fe8a56f0e98cb8ff104bc9bd76528a3b587
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f48aaf2791211c2e6cb8de09722be5751fefc38db868a72bc714f5ed5c7655f21cdd4e8b51bc2190046e545be97fb2f01ba97c230e86c8d9c513c9ee08a618a9
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
83631d14a5293675b87d506b755bcf47
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8756d18aaa2d4c1cb67b08841003e56b3c6652ba
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aa4d1d0d19c13aeacda6801ef1abff5b4e86f1b55baf645035ed5f3c71240ee9
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5d6e95bfa8c3b3fb90d9b06dcdd38dd2bba578789c936dcd87fa1fc5b3d479066d770e3d1d1012311856530110906aab81bf5035ac7f91b0f235e05cb683b31c
136 changes: 136 additions & 0 deletions library/repository/jp/kshoji/ble-midi/0.0.15/ble-midi-0.0.15.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"formatVersion": "1.1",
"component": {
"group": "jp.kshoji",
"module": "ble-midi",
"version": "0.0.15",
"attributes": {
"org.gradle.status": "release"
}
},
"createdBy": {
"gradle": {
"version": "8.4"
}
},
"variants": [
{
"name": "releaseVariantReleaseApiPublication",
"attributes": {
"org.gradle.category": "library",
"org.gradle.dependency.bundling": "external",
"org.gradle.libraryelements": "aar",
"org.gradle.usage": "java-api"
},
"dependencies": [
{
"group": "jp.kshoji",
"module": "javax-sound-midi",
"version": {
"requires": "0.0.4"
},
"excludes": [
{
"group": "*",
"module": "*"
}
],
"thirdPartyCompatibility": {
"artifactSelector": {
"name": "javax-sound-midi",
"type": "aar",
"extension": "aar"
}
}
},
{
"group": "com.android.support",
"module": "support-annotations",
"version": {
"requires": "28.0.0"
}
}
],
"files": [
{
"name": "ble-midi-0.0.15.aar",
"url": "ble-midi-0.0.15.aar",
"size": 100902,
"sha512": "5d6e95bfa8c3b3fb90d9b06dcdd38dd2bba578789c936dcd87fa1fc5b3d479066d770e3d1d1012311856530110906aab81bf5035ac7f91b0f235e05cb683b31c",
"sha256": "aa4d1d0d19c13aeacda6801ef1abff5b4e86f1b55baf645035ed5f3c71240ee9",
"sha1": "8756d18aaa2d4c1cb67b08841003e56b3c6652ba",
"md5": "83631d14a5293675b87d506b755bcf47"
}
]
},
{
"name": "releaseVariantReleaseRuntimePublication",
"attributes": {
"org.gradle.category": "library",
"org.gradle.dependency.bundling": "external",
"org.gradle.libraryelements": "aar",
"org.gradle.usage": "java-runtime"
},
"dependencies": [
{
"group": "jp.kshoji",
"module": "javax-sound-midi",
"version": {
"requires": "0.0.4"
},
"excludes": [
{
"group": "*",
"module": "*"
}
],
"thirdPartyCompatibility": {
"artifactSelector": {
"name": "javax-sound-midi",
"type": "aar",
"extension": "aar"
}
}
},
{
"group": "com.android.support",
"module": "support-annotations",
"version": {
"requires": "28.0.0"
}
}
],
"files": [
{
"name": "ble-midi-0.0.15.aar",
"url": "ble-midi-0.0.15.aar",
"size": 100902,
"sha512": "5d6e95bfa8c3b3fb90d9b06dcdd38dd2bba578789c936dcd87fa1fc5b3d479066d770e3d1d1012311856530110906aab81bf5035ac7f91b0f235e05cb683b31c",
"sha256": "aa4d1d0d19c13aeacda6801ef1abff5b4e86f1b55baf645035ed5f3c71240ee9",
"sha1": "8756d18aaa2d4c1cb67b08841003e56b3c6652ba",
"md5": "83631d14a5293675b87d506b755bcf47"
}
]
},
{
"name": "releaseVariantReleaseSourcePublication",
"attributes": {
"org.gradle.category": "documentation",
"org.gradle.dependency.bundling": "external",
"org.gradle.docstype": "sources",
"org.gradle.usage": "java-runtime"
},
"files": [
{
"name": "ble-midi-0.0.15-sources.jar",
"url": "ble-midi-0.0.15-sources.jar",
"size": 45880,
"sha512": "f48aaf2791211c2e6cb8de09722be5751fefc38db868a72bc714f5ed5c7655f21cdd4e8b51bc2190046e545be97fb2f01ba97c230e86c8d9c513c9ee08a618a9",
"sha256": "853cbd4d6d6fb23dede75d911cab3fe8a56f0e98cb8ff104bc9bd76528a3b587",
"sha1": "3ad83424e4db9d8e5c25844060f99f4a9f08a673",
"md5": "19e3e2462a40cb35401640b5f875359b"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9c5d6e746959b389094169b9c3e6da31
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
13f4e8eb6526683d7e2b8d43caead48afa363a71
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aee1f9dd880454d611f1bfe06699b74d1c185979e0286113ae22e3b3c4f894b2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
27b4dad64eb1a6106f334723bd5abc92f4011c45bf1824956907af75e45386fbb0440f39e1c758b8941a649d03703ca9d8c923ec02f3a387bc2ae9ae17053ab1
Loading

0 comments on commit 5e79157

Please sign in to comment.