Use ParcelFileDescriptor instead of FileDescriptor in the aidl
Using FileDescriptor in the aidl will refer to Parcel.readRawFileDescriptor() and Parcel.writeRawFileDescriptor() whilie trying to do parcel operations. Those two APIs are hidden and not accessible for the incoming ConnectivityService mainline module. For such use cases in a module, it should be replaced by using ParcelFileDescriptor that is designed for such usages. Bug: 170598012 Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk Change-Id: Ia7e3a71ccb4b136cc55c9e90a384870c32cfd37b
This commit is contained in:
@@ -206,11 +206,11 @@ interface IConnectivityManager
|
||||
void startNattKeepalive(in Network network, int intervalSeconds,
|
||||
in ISocketKeepaliveCallback cb, String srcAddr, int srcPort, String dstAddr);
|
||||
|
||||
void startNattKeepaliveWithFd(in Network network, in FileDescriptor fd, int resourceId,
|
||||
void startNattKeepaliveWithFd(in Network network, in ParcelFileDescriptor pfd, int resourceId,
|
||||
int intervalSeconds, in ISocketKeepaliveCallback cb, String srcAddr,
|
||||
String dstAddr);
|
||||
|
||||
void startTcpKeepalive(in Network network, in FileDescriptor fd, int intervalSeconds,
|
||||
void startTcpKeepalive(in Network network, in ParcelFileDescriptor pfd, int intervalSeconds,
|
||||
in ISocketKeepaliveCallback cb);
|
||||
|
||||
void stopKeepalive(in Network network, int slot);
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class NattSocketKeepalive extends SocketKeepalive {
|
||||
void startImpl(int intervalSec) {
|
||||
mExecutor.execute(() -> {
|
||||
try {
|
||||
mService.startNattKeepaliveWithFd(mNetwork, mPfd.getFileDescriptor(), mResourceId,
|
||||
mService.startNattKeepaliveWithFd(mNetwork, mPfd, mResourceId,
|
||||
intervalSec, mCallback,
|
||||
mSource.getHostAddress(), mDestination.getHostAddress());
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/** @hide */
|
||||
@@ -54,8 +53,7 @@ final class TcpSocketKeepalive extends SocketKeepalive {
|
||||
void startImpl(int intervalSec) {
|
||||
mExecutor.execute(() -> {
|
||||
try {
|
||||
final FileDescriptor fd = mPfd.getFileDescriptor();
|
||||
mService.startTcpKeepalive(mNetwork, fd, intervalSec, mCallback);
|
||||
mService.startTcpKeepalive(mNetwork, mPfd, intervalSec, mCallback);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error starting packet keepalive: ", e);
|
||||
throw e.rethrowFromSystemServer();
|
||||
|
||||
Reference in New Issue
Block a user