Robert Greenwalt | d55a6b4 | 2011-03-25 13:09:25 -0700 | [diff] [blame] | 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 android.util.Log; |
Elliott Hughes | cb64d43 | 2013-08-02 10:00:44 -0700 | [diff] [blame] | 20 | import java.util.Locale; |
Robert Greenwalt | d55a6b4 | 2011-03-25 13:09:25 -0700 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Describes the buildtime configuration of a network. |
| 24 | * Holds settings read from resources. |
| 25 | * @hide |
| 26 | */ |
| 27 | public 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 Greenwalt | f2102f7 | 2011-05-03 19:02:44 -0700 | [diff] [blame] | 54 | * 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 Greenwalt | d55a6b4 | 2011-03-25 13:09:25 -0700 | [diff] [blame] | 61 | * 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 Hughes | cb64d43 | 2013-08-02 10:00:44 -0700 | [diff] [blame] | 67 | name = fragments[0].trim().toLowerCase(Locale.ROOT); |
Robert Greenwalt | d55a6b4 | 2011-03-25 13:09:25 -0700 | [diff] [blame] | 68 | type = Integer.parseInt(fragments[1]); |
| 69 | radio = Integer.parseInt(fragments[2]); |
| 70 | priority = Integer.parseInt(fragments[3]); |
Robert Greenwalt | f2102f7 | 2011-05-03 19:02:44 -0700 | [diff] [blame] | 71 | restoreTime = Integer.parseInt(fragments[4]); |
| 72 | dependencyMet = Boolean.parseBoolean(fragments[5]); |
Robert Greenwalt | d55a6b4 | 2011-03-25 13:09:25 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Indicates if this network is supposed to be default-routable |
| 77 | */ |
| 78 | public boolean isDefault() { |
| 79 | return (type == radio); |
| 80 | } |
| 81 | } |