Skip to content

Commit

Permalink
v1.11: Android 13 crash fix / AGP 8.1.0 / build configuration update
Browse files Browse the repository at this point in the history
  • Loading branch information
green-green-avk committed Aug 10, 2023
1 parent 69f2479 commit 7a1c4f2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Device enumeration and hot plug/unplug events are supported.
To be used with **green-green-avk/libusb**:

Branches:

* <kbd>[v1.0.23-android-libusbmanager](https://github.com/green-green-avk/libusb/tree/v1.0.23-android-libusbmanager)</kbd>
* <kbd>[v1.0.26-android-libusbmanager](https://github.com/green-green-avk/libusb/tree/v1.0.26-android-libusbmanager)</kbd>

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath 'com.android.tools.build:gradle:8.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -19,6 +19,6 @@ allprojects {
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
9 changes: 5 additions & 4 deletions libusbmanager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'com.github.green-green-avk'
version = '1.10'
version = '1.11'

android {
namespace 'green_green_avk.libusbmanager'
Expand Down Expand Up @@ -34,21 +34,22 @@ dependencies {
implementation 'androidx.annotation:annotation:1.5.0'
}

task javadoc(type: Javadoc) {
tasks.register('javadoc', Javadoc) {
failOnError true
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
options {
addStringOption('link', 'https://developer.android.com/reference')
}
android.libraryVariants.all { variant ->
android.libraryVariants.configureEach { variant ->
if (variant.name == 'release') {
owner.classpath += variant.javaCompileProvider.get().classpath
}
}
}

task javadocJar(type: Jar, dependsOn: javadoc) {
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier.set 'javadoc'
from javadoc.destinationDir
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,20 @@ private void client(@NonNull final LocalSocket socket) {
if (devConn == null)
throw new ProcessException(context.getString(
R.string.libusbmanager_msg_unable_to_open_device_s, devName));
socket.setFileDescriptorsForSend(new FileDescriptor[]{
ParcelFileDescriptor.adoptFd(devConn.getFileDescriptor()).getFileDescriptor()
});
socket.getOutputStream().write(0);
// We need to `dup()` here: stupid `ParcelFileDescriptor.adoptFd()` semantics...
// It was possible to use it though before `fdsan` went such aggressive
// in Android 13.
// I prefer not go native to resolve it rightly for the sake of the library size.
final ParcelFileDescriptor devFd =
ParcelFileDescriptor.fromFd(devConn.getFileDescriptor());
try {
socket.setFileDescriptorsForSend(new FileDescriptor[]{
devFd.getFileDescriptor()
});
socket.getOutputStream().write(0);
} finally {
devFd.close();
}
while (cis.read() != -1) ; // Wait for closing by the client...
} catch (final InterruptedIOException ignored) {
} catch (final SecurityException | IOException |
Expand Down

0 comments on commit 7a1c4f2

Please sign in to comment.