Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21985b42 authored by Chiachang Wang's avatar Chiachang Wang Committed by Automerger Merge Worker
Browse files

Merge "Use ParcelFileDescriptor instead of FileDescriptor in the aidl" am:...

Merge "Use ParcelFileDescriptor instead of FileDescriptor in the aidl" am: 39efdb24 am: 2de37869 am: c5698a5b

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1554098

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8c873db971acd19cba9dd45a874e036587f88940
parents df28bddb c5698a5b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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) {
+1 −3
Original line number Diff line number Diff line
@@ -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();
+8 −6
Original line number Diff line number Diff line
@@ -7912,10 +7912,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
    }

    @Override
    public void startNattKeepaliveWithFd(Network network, FileDescriptor fd, int resourceId,
    public void startNattKeepaliveWithFd(Network network, ParcelFileDescriptor pfd, int resourceId,
            int intervalSeconds, ISocketKeepaliveCallback cb, String srcAddr,
            String dstAddr) {
        try {
            final FileDescriptor fd = pfd.getFileDescriptor();
            mKeepaliveTracker.startNattKeepalive(
                    getNetworkAgentInfoForNetwork(network), fd, resourceId,
                    intervalSeconds, cb,
@@ -7923,24 +7924,25 @@ public class ConnectivityService extends IConnectivityManager.Stub
        } finally {
            // FileDescriptors coming from AIDL calls must be manually closed to prevent leaks.
            // startNattKeepalive calls Os.dup(fd) before returning, so we can close immediately.
            if (fd != null && Binder.getCallingPid() != Process.myPid()) {
                IoUtils.closeQuietly(fd);
            if (pfd != null && Binder.getCallingPid() != Process.myPid()) {
                IoUtils.closeQuietly(pfd);
            }
        }
    }

    @Override
    public void startTcpKeepalive(Network network, FileDescriptor fd, int intervalSeconds,
    public void startTcpKeepalive(Network network, ParcelFileDescriptor pfd, int intervalSeconds,
            ISocketKeepaliveCallback cb) {
        try {
            enforceKeepalivePermission();
            final FileDescriptor fd = pfd.getFileDescriptor();
            mKeepaliveTracker.startTcpKeepalive(
                    getNetworkAgentInfoForNetwork(network), fd, intervalSeconds, cb);
        } finally {
            // FileDescriptors coming from AIDL calls must be manually closed to prevent leaks.
            // startTcpKeepalive calls Os.dup(fd) before returning, so we can close immediately.
            if (fd != null && Binder.getCallingPid() != Process.myPid()) {
                IoUtils.closeQuietly(fd);
            if (pfd != null && Binder.getCallingPid() != Process.myPid()) {
                IoUtils.closeQuietly(pfd);
            }
        }
    }