NetworkStateTracker.java revision 0d25534fed91f636def5776ddc4605005bd7471c
1/* 2 * Copyright (C) 2008 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 19/** 20 * Interface for connectivity service to act on a network interface. 21 * All state information for a network should be kept in a Tracker class. 22 * This interface defines network-type-independent functions that should 23 * be implemented by the Tracker class. 24 * 25 * {@hide} 26 */ 27public interface NetworkStateTracker { 28 29 public static final int EVENT_STATE_CHANGED = 1; 30 /** 31 * arg1: 1 to show, 0 to hide 32 * arg2: ID of the notification 33 * obj: Notification (if showing) 34 */ 35 public static final int EVENT_NOTIFICATION_CHANGED = 2; 36 public static final int EVENT_CONFIGURATION_CHANGED = 3; 37 public static final int EVENT_ROAMING_CHANGED = 4; 38 public static final int EVENT_NETWORK_SUBTYPE_CHANGED = 5; 39 public static final int EVENT_RESTORE_DEFAULT_NETWORK = 6; 40 public static final int EVENT_CLEAR_NET_TRANSITION_WAKELOCK = 7; 41 42 /** 43 * Fetch NetworkInfo for the network 44 */ 45 public NetworkInfo getNetworkInfo(); 46 47 /** 48 * Fetch NetworkProperties for the network 49 */ 50 public NetworkProperties getNetworkProperties(); 51 52 /** 53 * Return the system properties name associated with the tcp buffer sizes 54 * for this network. 55 */ 56 public String getTcpBufferSizesPropName(); 57 58 /** 59 * Check if private DNS route is set for the network 60 */ 61 public boolean isPrivateDnsRouteSet(); 62 63 /** 64 * Set a flag indicating private DNS route is set 65 */ 66 public void privateDnsRouteSet(boolean enabled); 67 68 /** 69 * Fetch default gateway address for the network 70 */ 71 public int getDefaultGatewayAddr(); 72 73 /** 74 * Check if default route is set 75 */ 76 public boolean isDefaultRouteSet(); 77 78 /** 79 * Set a flag indicating default route is set for the network 80 */ 81 public void defaultRouteSet(boolean enabled); 82 83 /** 84 * Indicate tear down requested from connectivity 85 */ 86 public void setTeardownRequested(boolean isRequested); 87 88 /** 89 * Check if tear down was requested 90 */ 91 public boolean isTeardownRequested(); 92 93 public void startMonitoring(); 94 95 /** 96 * Disable connectivity to a network 97 * @return {@code true} if a teardown occurred, {@code false} if the 98 * teardown did not occur. 99 */ 100 public boolean teardown(); 101 102 /** 103 * Reenable connectivity to a network after a {@link #teardown()}. 104 * @return {@code true} if we're connected or expect to be connected 105 */ 106 public boolean reconnect(); 107 108 /** 109 * Turn the wireless radio off for a network. 110 * @param turnOn {@code true} to turn the radio on, {@code false} 111 */ 112 public boolean setRadio(boolean turnOn); 113 114 /** 115 * Returns an indication of whether this network is available for 116 * connections. A value of {@code false} means that some quasi-permanent 117 * condition prevents connectivity to this network. 118 */ 119 public boolean isAvailable(); 120 121 /** 122 * Tells the underlying networking system that the caller wants to 123 * begin using the named feature. The interpretation of {@code feature} 124 * is completely up to each networking implementation. 125 * @param feature the name of the feature to be used 126 * @param callingPid the process ID of the process that is issuing this request 127 * @param callingUid the user ID of the process that is issuing this request 128 * @return an integer value representing the outcome of the request. 129 * The interpretation of this value is specific to each networking 130 * implementation+feature combination, except that the value {@code -1} 131 * always indicates failure. 132 */ 133 public int startUsingNetworkFeature(String feature, int callingPid, int callingUid); 134 135 /** 136 * Tells the underlying networking system that the caller is finished 137 * using the named feature. The interpretation of {@code feature} 138 * is completely up to each networking implementation. 139 * @param feature the name of the feature that is no longer needed. 140 * @param callingPid the process ID of the process that is issuing this request 141 * @param callingUid the user ID of the process that is issuing this request 142 * @return an integer value representing the outcome of the request. 143 * The interpretation of this value is specific to each networking 144 * implementation+feature combination, except that the value {@code -1} 145 * always indicates failure. 146 */ 147 public int stopUsingNetworkFeature(String feature, int callingPid, int callingUid); 148 149} 150