Skip to content

Commit

Permalink
OsCompat.write never returns EINTR, rather throws InterruptedIOException
Browse files Browse the repository at this point in the history
This is effectively clean up for previous commit
 but we're keeping git history for reference.
  • Loading branch information
consp1racy committed Jun 27, 2022
1 parent 8e3b1c3 commit e123efb
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 38 deletions.
2 changes: 0 additions & 2 deletions os-compat/src/main/java/androidx/system/OsConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@

interface OsConstants {

int getConstant(String name);

String errnoName(int errno);
}
15 changes: 0 additions & 15 deletions os-compat/src/main/java/androidx/system/OsConstantsApi21.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,6 @@

@RequiresApi(21)
final class OsConstantsApi21 implements OsConstants {
@Override
public int getConstant(String name) {
switch (name) {
case "EINTR":
return android.system.OsConstants.EINTR;
default:
// Add used constants above as needed.
try {
return android.system.OsConstants.class.getDeclaredField(name).getInt(null);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
}

@Override
public String errnoName(int errno) {
return android.system.OsConstants.errnoName(errno);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ private OsConstantsCompat() {
}
}

public static final int EINTR = IMPL.getConstant("EINTR");

/**
* Returns the string name of an errno value.
* For example, "EACCES". See {@link Os#strerror} for human-readable errno descriptions.
Expand Down
15 changes: 0 additions & 15 deletions os-compat/src/main/java/androidx/system/OsConstantsLibcore.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
package androidx.system;

final class OsConstantsLibcore implements OsConstants {
@Override
public int getConstant(String name) {
switch (name) {
case "EINTR":
return libcore.io.OsConstants.EINTR;
default:
// Add used constants above as needed.
try {
return libcore.io.OsConstants.class.getDeclaredField(name).getInt(null);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
}

@Override
public String errnoName(int errno) {
return libcore.io.OsConstants.errnoName(errno);
Expand Down
5 changes: 1 addition & 4 deletions server/src/main/java/com/genymobile/scrcpy/IO.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import androidx.system.ErrnoException;
import androidx.system.OsCompat;
import androidx.system.OsConstantsCompat;

import java.io.FileDescriptor;
import java.io.IOException;
Expand All @@ -19,9 +18,7 @@ public static void writeFully(FileDescriptor fd, ByteBuffer from) throws IOExcep
OsCompat.write(fd, from);
}
} catch (ErrnoException e) {
if (e.getErrno() != OsConstantsCompat.EINTR) {
throw new IOException(e);
}
throw new IOException(e);
}
}

Expand Down

0 comments on commit e123efb

Please sign in to comment.