Only allow libconnectivity_native usage on U+
No user of the API is expected before U, so limit its usage to U+. Bug: 262199896 Test: atest Change-Id: I211f459a729c216eb1ba9e3b983042e4afcbd135
This commit is contained in:
@@ -27,6 +27,7 @@ cc_library_shared {
|
|||||||
min_sdk_version: "30",
|
min_sdk_version: "30",
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"connectivity_native_aidl_interface-V1-ndk",
|
"connectivity_native_aidl_interface-V1-ndk",
|
||||||
|
"libmodules-utils-build",
|
||||||
],
|
],
|
||||||
export_include_dirs: ["include"],
|
export_include_dirs: ["include"],
|
||||||
cflags: [
|
cflags: [
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "connectivity_native.h"
|
#include "connectivity_native.h"
|
||||||
|
|
||||||
#include <android/binder_manager.h>
|
#include <android/binder_manager.h>
|
||||||
|
#include <android-modules-utils/sdk_level.h>
|
||||||
#include <aidl/android/net/connectivity/aidl/ConnectivityNative.h>
|
#include <aidl/android/net/connectivity/aidl/ConnectivityNative.h>
|
||||||
|
|
||||||
using aidl::android::net::connectivity::aidl::IConnectivityNative;
|
using aidl::android::net::connectivity::aidl::IConnectivityNative;
|
||||||
@@ -44,21 +45,25 @@ static int getErrno(const ::ndk::ScopedAStatus& status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int AConnectivityNative_blockPortForBind(in_port_t port) {
|
int AConnectivityNative_blockPortForBind(in_port_t port) {
|
||||||
|
if (!android::modules::sdklevel::IsAtLeastU()) return ENOSYS;
|
||||||
std::shared_ptr<IConnectivityNative> c = getBinder();
|
std::shared_ptr<IConnectivityNative> c = getBinder();
|
||||||
return getErrno(c->blockPortForBind(port));
|
return getErrno(c->blockPortForBind(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
int AConnectivityNative_unblockPortForBind(in_port_t port) {
|
int AConnectivityNative_unblockPortForBind(in_port_t port) {
|
||||||
|
if (!android::modules::sdklevel::IsAtLeastU()) return ENOSYS;
|
||||||
std::shared_ptr<IConnectivityNative> c = getBinder();
|
std::shared_ptr<IConnectivityNative> c = getBinder();
|
||||||
return getErrno(c->unblockPortForBind(port));
|
return getErrno(c->unblockPortForBind(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
int AConnectivityNative_unblockAllPortsForBind() {
|
int AConnectivityNative_unblockAllPortsForBind() {
|
||||||
|
if (!android::modules::sdklevel::IsAtLeastU()) return ENOSYS;
|
||||||
std::shared_ptr<IConnectivityNative> c = getBinder();
|
std::shared_ptr<IConnectivityNative> c = getBinder();
|
||||||
return getErrno(c->unblockAllPortsForBind());
|
return getErrno(c->unblockAllPortsForBind());
|
||||||
}
|
}
|
||||||
|
|
||||||
int AConnectivityNative_getPortsBlockedForBind(in_port_t *ports, size_t *count) {
|
int AConnectivityNative_getPortsBlockedForBind(in_port_t *ports, size_t *count) {
|
||||||
|
if (!android::modules::sdklevel::IsAtLeastU()) return ENOSYS;
|
||||||
std::shared_ptr<IConnectivityNative> c = getBinder();
|
std::shared_ptr<IConnectivityNative> c = getBinder();
|
||||||
std::vector<int32_t> actualBlockedPorts;
|
std::vector<int32_t> actualBlockedPorts;
|
||||||
int err = getErrno(c->getPortsBlockedForBind(&actualBlockedPorts));
|
int err = getErrno(c->getPortsBlockedForBind(&actualBlockedPorts));
|
||||||
|
|||||||
Reference in New Issue
Block a user