NetworkConfig.java revision af2eb4f6db2b54a144ecd0a87a0321933ffabc2c
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 17package android.net; 18 19import android.util.Log; 20 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 /** 53 * input string from config.xml resource. Uses the form: 54 * [Connection name],[ConnectivityManager connection type], 55 * [associated radio-type],[priority],[dependencyMet] 56 */ 57 public NetworkConfig(String init) { 58 String fragments[] = init.split(","); 59 name = fragments[0].trim().toLowerCase(); 60 type = Integer.parseInt(fragments[1]); 61 radio = Integer.parseInt(fragments[2]); 62 priority = Integer.parseInt(fragments[3]); 63 dependencyMet = Boolean.parseBoolean(fragments[4]); 64 } 65 66 /** 67 * Indicates if this network is supposed to be default-routable 68 */ 69 public boolean isDefault() { 70 return (type == radio); 71 } 72} 73