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