Remove unused functions in TrafficController
addInterface and hasUpdateDeviceStatsPermission are not used Test: m & flush & boot Bug: 217624062 Change-Id: I8a0f84f607a4f35512bc72e732df8f689b8ed1c9
This commit is contained in:
@@ -56,7 +56,6 @@ using base::unique_fd;
|
|||||||
using bpf::BpfMap;
|
using bpf::BpfMap;
|
||||||
using bpf::synchronizeKernelRCU;
|
using bpf::synchronizeKernelRCU;
|
||||||
using netdutils::DumpWriter;
|
using netdutils::DumpWriter;
|
||||||
using netdutils::getIfaceList;
|
|
||||||
using netdutils::NetlinkListener;
|
using netdutils::NetlinkListener;
|
||||||
using netdutils::NetlinkListenerInterface;
|
using netdutils::NetlinkListenerInterface;
|
||||||
using netdutils::ScopedIndent;
|
using netdutils::ScopedIndent;
|
||||||
@@ -111,14 +110,6 @@ const std::string uidMatchTypeToString(uint32_t match) {
|
|||||||
return matchType;
|
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) {
|
const std::string UidPermissionTypeToString(int permission) {
|
||||||
if (permission == INetd::PERMISSION_NONE) {
|
if (permission == INetd::PERMISSION_NONE) {
|
||||||
return "PERMISSION_NONE";
|
return "PERMISSION_NONE";
|
||||||
@@ -198,16 +189,6 @@ Status TrafficController::initMaps() {
|
|||||||
Status TrafficController::start() {
|
Status TrafficController::start() {
|
||||||
RETURN_IF_NOT_OK(initMaps());
|
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<std::string, uint32_t> ifacePairs;
|
|
||||||
ASSIGN_OR_RETURN(ifacePairs, getIfaceList());
|
|
||||||
for (const auto& ifacePair:ifacePairs) {
|
|
||||||
addInterface(ifacePair.first.c_str(), ifacePair.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto result = makeSkDestroyListener();
|
auto result = makeSkDestroyListener();
|
||||||
if (!isOk(result)) {
|
if (!isOk(result)) {
|
||||||
ALOGE("Unable to create SkDestroyListener: %s", toString(result).c_str());
|
ALOGE("Unable to create SkDestroyListener: %s", toString(result).c_str());
|
||||||
@@ -245,22 +226,6 @@ Status TrafficController::start() {
|
|||||||
return netdutils::status::ok;
|
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,
|
Status TrafficController::updateOwnerMapEntry(UidOwnerMatchType match, uid_t uid, FirewallRule rule,
|
||||||
FirewallType type) {
|
FirewallType type) {
|
||||||
std::lock_guard guard(mMutex);
|
std::lock_guard guard(mMutex);
|
||||||
|
|||||||
@@ -45,11 +45,6 @@ class TrafficController {
|
|||||||
*/
|
*/
|
||||||
netdutils::Status swapActiveStatsMap() EXCLUDES(mMutex);
|
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 changeUidOwnerRule(ChildChain chain, const uid_t uid, FirewallRule rule, FirewallType type);
|
||||||
|
|
||||||
int removeUidOwnerRule(const uid_t uid);
|
int removeUidOwnerRule(const uid_t uid);
|
||||||
@@ -185,8 +180,6 @@ class TrafficController {
|
|||||||
// need to call back to system server for permission check.
|
// need to call back to system server for permission check.
|
||||||
std::set<uid_t> mPrivilegedUser GUARDED_BY(mMutex);
|
std::set<uid_t> mPrivilegedUser GUARDED_BY(mMutex);
|
||||||
|
|
||||||
bool hasUpdateDeviceStatsPermission(uid_t uid) REQUIRES(mMutex);
|
|
||||||
|
|
||||||
// For testing
|
// For testing
|
||||||
friend class TrafficControllerTest;
|
friend class TrafficControllerTest;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user