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