Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67cf3453 authored by Sarah Chin's avatar Sarah Chin Committed by Android (Google) Code Review
Browse files

Merge "Add prefix to create correct enterprise OsAppId" into sc-dev

parents dbf839b0 14b7039c
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -116,6 +117,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
@@ -141,6 +143,12 @@ public class DataConnection extends StateMachine {
    private static final String RAT_NAME_5G = "nr";
    private static final String RAT_NAME_EVDO = "evdo";

    /**
     * OSId for "Android", using UUID version 5 with namespace ISO OSI.
     * Prepended to the OsAppId in TrafficDescriptor to use for URSP matching.
     */
    private static final UUID OS_ID = UUID.fromString("97a498e3-fc92-5c94-8986-0333d06e4e47");

    private static final int MIN_V6_MTU = 1280;

    /**
@@ -825,13 +833,20 @@ public class DataConnection extends StateMachine {
    }

    /**
     * API to generate the OSAppId for enterprise traffic category.
     * @return byte[] representing OSId + OSAppId
     * API to generate the OsAppId for enterprise traffic category.
     * @return byte[] representing OsId + length of OsAppId + OsAppId
     */
    @VisibleForTesting
    public static byte[] getEnterpriseOsAppId() {
        return NetworkCapabilities.getCapabilityCarrierName(
        byte[] osAppId = NetworkCapabilities.getCapabilityCarrierName(
                NetworkCapabilities.NET_CAPABILITY_ENTERPRISE).getBytes();
        // 16 bytes for UUID, 1 byte for length of osAppId, and up to 255 bytes for osAppId
        ByteBuffer bb = ByteBuffer.allocate(16 + 1 + osAppId.length);
        bb.putLong(OS_ID.getMostSignificantBits());
        bb.putLong(OS_ID.getLeastSignificantBits());
        bb.put((byte) osAppId.length);
        bb.put(osAppId);
        return bb.array();
    }

    /**