• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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.server.connectivity;
18 
19 import android.content.Context;
20 
21 import com.android.internal.annotations.VisibleForTesting;
22 import com.android.server.ConnectivityService;
23 
24 /**
25  * Collection of constants for the connectivity module.
26  */
27 public final class ConnectivityFlags {
28     /**
29      * Boot namespace for this module. Values from this should only be read at boot.
30      */
31     public static final String NAMESPACE_TETHERING_BOOT = "tethering_boot";
32 
33     /**
34      * Minimum module version at which to avoid rematching all requests when a network request is
35      * registered, and rematch only the registered requests instead.
36      */
37     @VisibleForTesting
38     public static final String NO_REMATCH_ALL_REQUESTS_ON_REGISTER =
39             "no_rematch_all_requests_on_register";
40 
41     public static final String CARRIER_SERVICE_CHANGED_USE_CALLBACK =
42             "carrier_service_changed_use_callback_version";
43 
44     public static final String REQUEST_RESTRICTED_WIFI =
45             "request_restricted_wifi";
46 
47     public static final String INGRESS_TO_VPN_ADDRESS_FILTERING =
48             "ingress_to_vpn_address_filtering";
49 
50     public static final String BACKGROUND_FIREWALL_CHAIN = "background_firewall_chain";
51 
52     public static final String CELLULAR_DATA_INACTIVITY_TIMEOUT =
53             "cellular_data_inactivity_timeout";
54 
55     public static final String WIFI_DATA_INACTIVITY_TIMEOUT = "wifi_data_inactivity_timeout";
56 
57     public static final String DELAY_DESTROY_SOCKETS = "delay_destroy_sockets";
58 
59     public static final String USE_DECLARED_METHODS_FOR_CALLBACKS =
60             "use_declared_methods_for_callbacks";
61 
62     public static final String QUEUE_CALLBACKS_FOR_FROZEN_APPS =
63             "queue_callbacks_for_frozen_apps";
64 
65     public static final String QUEUE_NETWORK_AGENT_EVENTS_IN_SYSTEM_SERVER =
66             "queue_network_agent_events_in_system_server";
67 
68     private boolean mNoRematchAllRequestsOnRegister;
69 
70     /**
71      * Whether ConnectivityService should avoid avoid rematching all requests when a network
72      * request is registered, and rematch only the registered requests instead.
73      *
74      * This flag is disabled by default.
75      *
76      * IMPORTANT NOTE: This flag is false by default and will only be loaded in ConnectivityService
77      * systemReady. It is also not volatile for performance reasons, so for most threads it may
78      * only change to true after some time. This is fine for this particular flag because it only
79      * controls whether all requests or a subset of requests should be rematched, which is only
80      * a performance optimization, so its value does not need to be consistent over time; but most
81      * flags will not have these properties and should not use the same model.
82      *
83      * TODO: when adding other flags, consider the appropriate timing to load them, and necessary
84      * threading guarantees according to the semantics of the flags.
85      */
noRematchAllRequestsOnRegister()86     public boolean noRematchAllRequestsOnRegister() {
87         return mNoRematchAllRequestsOnRegister;
88     }
89 
90     /**
91      * Load flag values. Should only be called once, and can only be called once PackageManager is
92      * ready.
93      */
loadFlags(ConnectivityService.Dependencies deps, Context ctx)94     public void loadFlags(ConnectivityService.Dependencies deps, Context ctx) {
95         mNoRematchAllRequestsOnRegister = deps.isFeatureEnabled(
96                 ctx, NO_REMATCH_ALL_REQUESTS_ON_REGISTER);
97     }
98 }
99