From aadb17ed59be867a78efc83b82169da99b8b82b8 Mon Sep 17 00:00:00 2001 From: Hungming Chen Date: Thu, 5 May 2022 23:35:33 +0800 Subject: [PATCH] Make IBpfMap extends AutoCloseable and BpfMap implements IBpfMap IBpfMap defines all required functions of BpfMap interface. Ex: close() from AutoCloseable After: AutoCloseable ---> IBpfMap ---> BpfMap Before: AutoCloseable -+ | +---> BpfMap | IBpfMap -------+ Test: BpfMapTest Change-Id: I5266d9bfdfcb68f632c13d214705309893dded95 --- staticlibs/device/com/android/net/module/util/BpfMap.java | 2 +- staticlibs/device/com/android/net/module/util/IBpfMap.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/staticlibs/device/com/android/net/module/util/BpfMap.java b/staticlibs/device/com/android/net/module/util/BpfMap.java index d4ce83b48e..f1420c2131 100644 --- a/staticlibs/device/com/android/net/module/util/BpfMap.java +++ b/staticlibs/device/com/android/net/module/util/BpfMap.java @@ -39,7 +39,7 @@ import java.util.Objects; * @param the key of the map. * @param the value of the map. */ -public class BpfMap implements IBpfMap, AutoCloseable { +public class BpfMap implements IBpfMap { static { System.loadLibrary(JniUtil.getJniLibraryName(BpfMap.class.getPackage())); } diff --git a/staticlibs/device/com/android/net/module/util/IBpfMap.java b/staticlibs/device/com/android/net/module/util/IBpfMap.java index d43b22c619..dce369a25c 100644 --- a/staticlibs/device/com/android/net/module/util/IBpfMap.java +++ b/staticlibs/device/com/android/net/module/util/IBpfMap.java @@ -20,7 +20,6 @@ import android.system.ErrnoException; import androidx.annotation.NonNull; import java.util.NoSuchElementException; -import java.util.function.BiConsumer; /** * The interface of BpfMap. This could be used to inject for testing. @@ -29,7 +28,7 @@ import java.util.function.BiConsumer; * @param the key of the map. * @param the value of the map. */ -public interface IBpfMap { +public interface IBpfMap extends AutoCloseable { /** Update an existing or create a new key -> value entry in an eBbpf map. */ void updateEntry(K key, V value) throws ErrnoException;