Skip to content

Commit

Permalink
List network permissions in dumpsys netd.
Browse files Browse the repository at this point in the history
Bug: 23113288
Change-Id: Iea225ead1f6296ded29fcee2435a8c6aa2a67429
  • Loading branch information
lcolitti committed Sep 26, 2016
1 parent c6201c3 commit 1f28b64
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions include/Permission.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,14 @@ enum Permission {
PERMISSION_SYSTEM = 0x3, // Includes PERMISSION_NETWORK.
};

inline const char *permissionToName(Permission permission) {
switch (permission) {
case PERMISSION_NONE: return "NONE";
case PERMISSION_NETWORK: return "NETWORK";
case PERMISSION_SYSTEM: return "SYSTEM";
// No default statement. We want to see errors of the form:
// "enumeration value 'PERMISSION_SYSTEM' not handled in switch [-Werror,-Wswitch]".
}
}

#endif // NETD_INCLUDE_PERMISSION_H
9 changes: 8 additions & 1 deletion server/NetworkController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,14 @@ void NetworkController::dump(DumpWriter& dw) {
dw.println("Networks:");
dw.incIndent();
for (const auto& i : mNetworks) {
dw.println(i.second->toString().c_str());
Network* network = i.second;
dw.println(network->toString().c_str());
if (network->getType() == Network::PHYSICAL) {
dw.incIndent();
Permission permission = reinterpret_cast<PhysicalNetwork*>(network)->getPermission();
dw.println("Required permission: %s", permissionToName(permission));
dw.decIndent();
}
android::net::gCtls->resolverCtrl.dump(dw, i.first);
dw.blankline();
}
Expand Down

0 comments on commit 1f28b64

Please sign in to comment.