1 /*
2  * Copyright (C) 2020 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.networkstack.apishim.api29;
18 
19 import android.os.Build;
20 import android.provider.Settings;
21 import android.telephony.CarrierConfigManager;
22 
23 import androidx.annotation.RequiresApi;
24 import androidx.annotation.VisibleForTesting;
25 
26 /**
27  * Utility class for defining and importing constants from the Android platform.
28  */
29 public class ConstantsShim {
30     /**
31      * Constant that callers can use to determine what version of the shim they are using.
32      * Must be the same as the version of the shims.
33      * This should only be used by test code. Production code that uses the shims should be using
34      * the shimmed objects and methods themselves.
35      */
36     @VisibleForTesting
37     public static final int VERSION = 29;
38 
39     // Constants defined in android.net.VpnProfileState
40     public static final int VPN_PROFILE_STATE_CONNECTING = 1;
41     public static final int VPN_PROFILE_STATE_CONNECTED = 2;
42 
43     public static final String ACTION_VPN_MANAGER_EVENT = "android.net.action.VPN_MANAGER_EVENT";
44 
45     // Constants defined in android.net.ConnectivityDiagnosticsManager.
46     public static final int DETECTION_METHOD_DNS_EVENTS = 1;
47     public static final int DETECTION_METHOD_TCP_METRICS = 2;
48 
49     // Constants defined in android.net.CaptivePortalData.
50     public static final int CAPTIVE_PORTAL_DATA_SOURCE_OTHER = 0;
51     public static final int CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT = 1;
52 
53     // Constants defined in android.net.NetworkCapabilities.
54     public static final int NET_CAPABILITY_NOT_VCN_MANAGED = 28;
55 
56     // Constants defined in android.content.Context
57     public static final String NEARBY_SERVICE = "nearby";
58 
59     // Constants defined in android.system.OsConstants
60     public static final int IFA_F_MANAGETEMPADDR = 0x100;
61     public static final int IFA_F_NOPREFIXROUTE = 0x200;
62 
63     /** Compatibility class for {@link CarrierConfigManager}. */
64     @RequiresApi(Build.VERSION_CODES.Q)
65     /** See {@link CarrierManager#KEY_CARRIER_SUPPORTS_TETHERING_BOOL} */
66     public static final String KEY_CARRIER_SUPPORTS_TETHERING_BOOL =
67             "carrier_supports_tethering_bool";
68 
69     /** Compatibility class for {@link Settings}. */
70     @RequiresApi(Build.VERSION_CODES.Q)
71     /** @see android.provider.Settings#ACTION_TETHER_UNSUPPORTED_CARRIER_UI */
72     public static final  String ACTION_TETHER_UNSUPPORTED_CARRIER_UI =
73             "android.settings.TETHER_UNSUPPORTED_CARRIER_UI";
74 }
75