Merge "Use ErrnoException for handling exceptions in JNI functions" into main
This commit is contained in:
commit
0cf79aa0ed
2 changed files with 8 additions and 11 deletions
|
|
@ -17,8 +17,7 @@
|
|||
package com.android.net.module.util;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import android.system.ErrnoException;
|
||||
|
||||
/**
|
||||
* Contains JNI functions for use in service-connectivity
|
||||
|
|
@ -38,17 +37,17 @@ public class ServiceConnectivityJni {
|
|||
/**
|
||||
* Create a timerfd.
|
||||
*
|
||||
* @throws IOException if the timerfd creation is failed.
|
||||
* @throws ErrnoException if the timerfd creation is failed.
|
||||
*/
|
||||
public static native int createTimerFd() throws IOException;
|
||||
public static native int createTimerFd() throws ErrnoException;
|
||||
|
||||
/**
|
||||
* Set given time to the timerfd.
|
||||
*
|
||||
* @param timeMs target time
|
||||
* @throws IOException if setting expiration time is failed.
|
||||
* @throws ErrnoException if setting expiration time is failed.
|
||||
*/
|
||||
public static native void setTimerFdTime(int fd, long timeMs) throws IOException;
|
||||
public static native void setTimerFdTime(int fd, long timeMs) throws ErrnoException;
|
||||
|
||||
/** Create tun/tap interface */
|
||||
public static native int createTunTap(boolean isTun, boolean hasCarrier,
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@
|
|||
|
||||
package com.android.net.module.util;
|
||||
|
||||
import android.os.Process;
|
||||
import android.system.ErrnoException;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Contains mostly timerfd functionality.
|
||||
*/
|
||||
|
|
@ -33,7 +31,7 @@ public class TimerFdUtils {
|
|||
static int createTimerFileDescriptor() {
|
||||
try {
|
||||
return ServiceConnectivityJni.createTimerFd();
|
||||
} catch (IOException e) {
|
||||
} catch (ErrnoException e) {
|
||||
Log.e(TAG, "createTimerFd failed", e);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -45,7 +43,7 @@ public class TimerFdUtils {
|
|||
static boolean setExpirationTime(int fd, long expirationTimeMs) {
|
||||
try {
|
||||
ServiceConnectivityJni.setTimerFdTime(fd, expirationTimeMs);
|
||||
} catch (IOException e) {
|
||||
} catch (ErrnoException e) {
|
||||
Log.e(TAG, "setExpirationTime failed", e);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue