diff options
-rw-r--r-- | core/java/android/app/ActivityThread.java | 2 | ||||
-rw-r--r-- | services/net/java/android/net/apf/ApfFilter.java | 7 | ||||
-rw-r--r-- | services/net/java/android/net/apf/ApfGenerator.java | 6 |
3 files changed, 10 insertions, 5 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 36e962e81338..97bc570aff4c 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -5045,6 +5045,8 @@ public final class ActivityThread { } private void handleBindApplication(AppBindData data) { + // Register the UI Thread as a sensitive thread to the runtime. + VMRuntime.registerSensitiveThread(); if (data.trackAllocation) { DdmVmInternal.enableRecentAllocations(true); } diff --git a/services/net/java/android/net/apf/ApfFilter.java b/services/net/java/android/net/apf/ApfFilter.java index 6722332b4d96..5a1027547fc6 100644 --- a/services/net/java/android/net/apf/ApfFilter.java +++ b/services/net/java/android/net/apf/ApfFilter.java @@ -107,6 +107,7 @@ public class ApfFilter { private static final boolean VDBG = false; private static final int ETH_HEADER_LEN = 14; + private static final int ETH_DEST_ADDR_OFFSET = 0; private static final int ETH_ETHERTYPE_OFFSET = 12; private static final byte[] ETH_BROADCAST_MAC_ADDRESS = new byte[]{ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff }; @@ -582,7 +583,6 @@ public class ApfFilter { * DROP_LABEL or PASS_LABEL and does not fall off the end. * Preconditions: * - Packet being filtered is IPv4 - * - R1 is initialized to 0 */ @GuardedBy("this") private void generateIPv4FilterLocked(ApfGenerator gen) throws IllegalInstructionException { @@ -605,9 +605,8 @@ public class ApfFilter { // Drop all broadcasts besides DHCP addressed to us // If not a broadcast packet, pass - // NOTE: Relies on R1 being initialized to 0 which is the offset of the ethernet - // destination MAC address - gen.addJumpIfBytesNotEqual(Register.R1, ETH_BROADCAST_MAC_ADDRESS, gen.PASS_LABEL); + gen.addLoadImmediate(Register.R0, ETH_DEST_ADDR_OFFSET); + gen.addJumpIfBytesNotEqual(Register.R0, ETH_BROADCAST_MAC_ADDRESS, gen.PASS_LABEL); // If not UDP, drop gen.addLoad8(Register.R0, IPV4_PROTOCOL_OFFSET); gen.addJumpIfR0NotEquals(IPPROTO_UDP, gen.DROP_LABEL); diff --git a/services/net/java/android/net/apf/ApfGenerator.java b/services/net/java/android/net/apf/ApfGenerator.java index 96c2ba535dd1..d41fbce1f206 100644 --- a/services/net/java/android/net/apf/ApfGenerator.java +++ b/services/net/java/android/net/apf/ApfGenerator.java @@ -734,7 +734,11 @@ public class ApfGenerator { * Add an instruction to the end of the program to jump to {@code target} if the bytes of the * packet at, an offset specified by {@code register}, match {@code bytes}. */ - public ApfGenerator addJumpIfBytesNotEqual(Register register, byte[] bytes, String target) { + public ApfGenerator addJumpIfBytesNotEqual(Register register, byte[] bytes, String target) + throws IllegalInstructionException { + if (register == Register.R1) { + throw new IllegalInstructionException("JNEBS fails with R1"); + } Instruction instruction = new Instruction(Opcodes.JNEBS, register); instruction.setUnsignedImm(bytes.length); instruction.setTargetLabel(target); |