Adapt to netlink changes introduced in kernel v3.8

Bug: 13516920

The kernel assigns nt_pid(portid) the process ID to the first netlink socket.
For subsequent netlink socket that the process creates, it assigns value
between 0xFFFFFFFFFFFFEFFF(-4097) and 0x8000000000000000(-2147483648).

pre-v3.8 netlink presents portid in procfs as signed int.
v3.8 changes presentation of portid to unsigned.
This change has no impact for the portid which was assigned the process id.
But in other cases, it causes trouble for Java Integer to decode these values,
because they are larger than the Integer.MAX_VALUE.
To decode these unsigned int values, we have to use Java Long type.

Signed-off-by: Guobin Zhang <>
Signed-off-by: Jack Ren <>
Signed-off-by: Bruce Beare <>

(cherry picked from commit e777c2e418eef078c05af3b225784d3bb15e983b)

Change-Id: If5051369661c3109de80beacfb912bc0ac4e358c
diff --git a/tests/tests/security/src/android/security/cts/ b/tests/tests/security/src/android/security/cts/
index d428c60..4428ba9 100644
--- a/tests/tests/security/src/android/security/cts/
+++ b/tests/tests/security/src/android/security/cts/
@@ -249,7 +249,7 @@
         Set<Integer> retval = new HashSet<Integer>();
         for (List<String> i : netlink) {
             // The PID is in column 3
-            int pid = Integer.decode(i.get(2));
+            int pid = Long.decode(i.get(2)).intValue();
             if (new File("/proc/" + pid + "/cmdline").exists()) {