Change the netId to nethandle mapping.
Being able to update this handle is necessary to ensure that
system-only OTAs do not break vendor code that relies on
nethandles.
Bug: 63052780
Test: walleye builds, boots, networking works
Test: MultinetworkApiTest CTS tests passes
Change-Id: I049a4ad2610ca68b8f56377b63be7e5e8ce76039
diff --git a/server/NetworkController.h b/server/NetworkController.h
index 08ba602..378c9f1 100644
--- a/server/NetworkController.h
+++ b/server/NetworkController.h
@@ -34,6 +34,8 @@
namespace android {
namespace net {
+constexpr uint32_t kHandleMagic = 0xcafed00d;
+
// Utility to convert from netId to net_handle_t. Doing this here as opposed to exporting
// from net.c as it may have NDK implications. Besides no conversion available in net.c for
// obtaining handle given netId.
@@ -42,7 +44,6 @@
const uint32_t k32BitMask = 0xffffffff;
// This value MUST be kept in sync with the corresponding value in
// the android.net.Network#getNetworkHandle() implementation.
- const uint32_t kHandleMagic = 0xfacade;
// Check for minimum acceptable version of the API in the low bits.
if (fromNetHandle != NETWORK_UNSPECIFIED &&
@@ -56,12 +57,10 @@
// Utility to convert from nethandle to netid, keep in sync with getNetworkHandle
// in Network.java.
static inline net_handle_t netIdToNetHandle(unsigned fromNetId) {
- const net_handle_t HANDLE_MAGIC = 0xfacade;
-
if (!fromNetId) {
return NETWORK_UNSPECIFIED;
}
- return (((net_handle_t)fromNetId << 32) | HANDLE_MAGIC);
+ return (((net_handle_t)fromNetId << 32) | kHandleMagic);
}
class DumpWriter;