diff --git a/service/native/TrafficController.cpp b/service/native/TrafficController.cpp index adc1925fc9..4dc056d89a 100644 --- a/service/native/TrafficController.cpp +++ b/service/native/TrafficController.cpp @@ -56,7 +56,6 @@ using base::unique_fd; using bpf::BpfMap; using bpf::synchronizeKernelRCU; using netdutils::DumpWriter; -using netdutils::getIfaceList; using netdutils::NetlinkListener; using netdutils::NetlinkListenerInterface; using netdutils::ScopedIndent; @@ -111,14 +110,6 @@ const std::string uidMatchTypeToString(uint32_t match) { return matchType; } -bool TrafficController::hasUpdateDeviceStatsPermission(uid_t uid) { - // This implementation is the same logic as method ActivityManager#checkComponentPermission. - // It implies that the calling uid can never be the same as PER_USER_RANGE. - uint32_t appId = uid % PER_USER_RANGE; - return ((appId == AID_ROOT) || (appId == AID_SYSTEM) || - mPrivilegedUser.find(appId) != mPrivilegedUser.end()); -} - const std::string UidPermissionTypeToString(int permission) { if (permission == INetd::PERMISSION_NONE) { return "PERMISSION_NONE"; @@ -198,16 +189,6 @@ Status TrafficController::initMaps() { Status TrafficController::start() { RETURN_IF_NOT_OK(initMaps()); - // Fetch the list of currently-existing interfaces. At this point NetlinkHandler is - // already running, so it will call addInterface() when any new interface appears. - // TODO: Clean-up addInterface() after interface monitoring is in - // NetworkStatsService. - std::map ifacePairs; - ASSIGN_OR_RETURN(ifacePairs, getIfaceList()); - for (const auto& ifacePair:ifacePairs) { - addInterface(ifacePair.first.c_str(), ifacePair.second); - } - auto result = makeSkDestroyListener(); if (!isOk(result)) { ALOGE("Unable to create SkDestroyListener: %s", toString(result).c_str()); @@ -245,22 +226,6 @@ Status TrafficController::start() { return netdutils::status::ok; } -int TrafficController::addInterface(const char* name, uint32_t ifaceIndex) { - IfaceValue iface; - if (ifaceIndex == 0) { - ALOGE("Unknown interface %s(%d)", name, ifaceIndex); - return -1; - } - - strlcpy(iface.name, name, sizeof(IfaceValue)); - Status res = mIfaceIndexNameMap.writeValue(ifaceIndex, iface, BPF_ANY); - if (!isOk(res)) { - ALOGE("Failed to add iface %s(%d): %s", name, ifaceIndex, strerror(res.code())); - return -res.code(); - } - return 0; -} - Status TrafficController::updateOwnerMapEntry(UidOwnerMatchType match, uid_t uid, FirewallRule rule, FirewallType type) { std::lock_guard guard(mMutex); diff --git a/service/native/include/TrafficController.h b/service/native/include/TrafficController.h index c921ff2df0..8512929b8e 100644 --- a/service/native/include/TrafficController.h +++ b/service/native/include/TrafficController.h @@ -45,11 +45,6 @@ class TrafficController { */ netdutils::Status swapActiveStatsMap() EXCLUDES(mMutex); - /* - * Add the interface name and index pair into the eBPF map. - */ - int addInterface(const char* name, uint32_t ifaceIndex); - int changeUidOwnerRule(ChildChain chain, const uid_t uid, FirewallRule rule, FirewallType type); int removeUidOwnerRule(const uid_t uid); @@ -187,8 +182,6 @@ class TrafficController { // need to call back to system server for permission check. std::set mPrivilegedUser GUARDED_BY(mMutex); - bool hasUpdateDeviceStatsPermission(uid_t uid) REQUIRES(mMutex); - // For testing friend class TrafficControllerTest; };