1 /*
2  * Copyright (C) 2010 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 android.net;
18 
19 import java.util.Locale;
20 
21 /**
22  * Describes the buildtime configuration of a network.
23  * Holds settings read from resources.
24  * @hide
25  */
26 public class NetworkConfig {
27     /**
28      * Human readable string
29      */
30     public String name;
31 
32     /**
33      * Type from ConnectivityManager
34      */
35     public int type;
36 
37     /**
38      * the radio number from radio attributes config
39      */
40     public int radio;
41 
42     /**
43      * higher number == higher priority when turning off connections
44      */
45     public int priority;
46 
47     /**
48      * indicates the boot time dependencyMet setting
49      */
50     public boolean dependencyMet;
51 
52     /**
53      * indicates the default restoral timer in seconds
54      * if the network is used as a special network feature
55      * -1 indicates no restoration of default
56      */
57     public int restoreTime;
58 
59     /**
60      * input string from config.xml resource.  Uses the form:
61      * [Connection name],[ConnectivityManager connection type],
62      * [associated radio-type],[priority],[dependencyMet]
63      */
NetworkConfig(String init)64     public NetworkConfig(String init) {
65         String fragments[] = init.split(",");
66         name = fragments[0].trim().toLowerCase(Locale.ROOT);
67         type = Integer.parseInt(fragments[1]);
68         radio = Integer.parseInt(fragments[2]);
69         priority = Integer.parseInt(fragments[3]);
70         restoreTime = Integer.parseInt(fragments[4]);
71         dependencyMet = Boolean.parseBoolean(fragments[5]);
72     }
73 
74     /**
75      * Indicates if this network is supposed to be default-routable
76      */
isDefault()77     public boolean isDefault() {
78         return (type == radio);
79     }
80 }
81