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

Commit 6ec9acac authored by Sarah Chin's avatar Sarah Chin
Browse files

Add prefix to create correct enterprise OsAppId

Test: atest DataConnectionTest, DcTrackerTest
Fix: 183948070
Change-Id: I30493810519f63f4e06000203c2ee19367dde373
Merged-In: I30493810519f63f4e06000203c2ee19367dde373
parent 1aa9c075
Loading
Loading
Loading
Loading
+25 −0
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;

    /**
@@ -816,6 +824,23 @@ public class DataConnection extends StateMachine {
                : AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
    }

    /**
     * API to generate the OsAppId for enterprise traffic category.
     * @return byte[] representing OsId + length of OsAppId + OsAppId
     */
    @VisibleForTesting
    public static byte[] getEnterpriseOsAppId() {
        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();
    }

    /**
     * Begin setting up a data connection, calls setupDataCall
     * and the ConnectionParams will be returned with the