2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 import java.util.Locale;
22 * Describes the buildtime configuration of a network.
23 * Holds settings read from resources.
26 public class NetworkConfig {
28 * Human readable string
33 * Type from ConnectivityManager
38 * the radio number from radio attributes config
43 * higher number == higher priority when turning off connections
48 * indicates the boot time dependencyMet setting
50 public boolean dependencyMet;
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
57 public int restoreTime;
60 * input string from config.xml resource. Uses the form:
61 * [Connection name],[ConnectivityManager connection type],
62 * [associated radio-type],[priority],[dependencyMet]
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]);
75 * Indicates if this network is supposed to be default-routable
77 public boolean isDefault() {
78 return (type == radio);