1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.net.module.util; 18 19 /** 20 * Class to centralize feature version control that requires a specific module or a specific 21 * module version. 22 * @hide 23 */ 24 public class FeatureVersions { 25 /** 26 * This constant is used to do bitwise shift operation to create module ids. 27 * The module version is composed with 9 digits which is placed in the lower 36 bits. 28 */ 29 private static final int MODULE_SHIFT = 36; 30 /** 31 * The bitmask to do bitwise-and(i.e. {@code &}) operation to get the module id. 32 */ 33 public static final long MODULE_MASK = 0xFF0_0000_0000L; 34 /** 35 * The bitmask to do bitwise-and(i.e. {@code &}) operation to get the module version. 36 */ 37 public static final long VERSION_MASK = 0x00F_FFFF_FFFFL; 38 public static final long CONNECTIVITY_MODULE_ID = 0x01L << MODULE_SHIFT; 39 public static final long NETWORK_STACK_MODULE_ID = 0x02L << MODULE_SHIFT; 40 // CLAT_ADDRESS_TRANSLATE is a feature of the network stack, which doesn't throw when system 41 // try to add a NAT-T keepalive packet filter with v6 address, introduced in version 42 // M-2023-Sept on July 3rd, 2023. 43 public static final long FEATURE_CLAT_ADDRESS_TRANSLATE = 44 NETWORK_STACK_MODULE_ID + 34_09_00_000L; 45 46 // IS_UID_NETWORKING_BLOCKED is a feature in ConnectivityManager, 47 // which provides an API to access BPF maps to check whether the networking is blocked 48 // by BPF for the given uid and conditions, introduced in version M-2024-Feb on Nov 6, 2023. 49 public static final long FEATURE_IS_UID_NETWORKING_BLOCKED = 50 CONNECTIVITY_MODULE_ID + 34_14_00_000L; 51 } 52