blob: 32a2cda00370a3b5fa779fa2cb145e1ec08f2aed [file] [log] [blame]
Robert Greenwaltd55a6b42011-03-25 13:09:25 -07001/*
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
17package android.net;
18
Elliott Hughescb64d432013-08-02 10:00:44 -070019import java.util.Locale;
Robert Greenwaltd55a6b42011-03-25 13:09:25 -070020
21/**
22 * Describes the buildtime configuration of a network.
23 * Holds settings read from resources.
24 * @hide
25 */
26public 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 /**
Robert Greenwaltf2102f72011-05-03 19:02:44 -070053 * 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 /**
Robert Greenwaltd55a6b42011-03-25 13:09:25 -070060 * input string from config.xml resource. Uses the form:
61 * [Connection name],[ConnectivityManager connection type],
62 * [associated radio-type],[priority],[dependencyMet]
63 */
64 public NetworkConfig(String init) {
65 String fragments[] = init.split(",");
Elliott Hughescb64d432013-08-02 10:00:44 -070066 name = fragments[0].trim().toLowerCase(Locale.ROOT);
Robert Greenwaltd55a6b42011-03-25 13:09:25 -070067 type = Integer.parseInt(fragments[1]);
68 radio = Integer.parseInt(fragments[2]);
69 priority = Integer.parseInt(fragments[3]);
Robert Greenwaltf2102f72011-05-03 19:02:44 -070070 restoreTime = Integer.parseInt(fragments[4]);
71 dependencyMet = Boolean.parseBoolean(fragments[5]);
Robert Greenwaltd55a6b42011-03-25 13:09:25 -070072 }
73
74 /**
75 * Indicates if this network is supposed to be default-routable
76 */
77 public boolean isDefault() {
78 return (type == radio);
79 }
80}