blob: e2429d8987b8bdb55b0432382d7376c8a3a41cde [file] [log] [blame]
Wink Saville00cfe112010-09-16 15:54:32 -07001/*
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
Wink Saville00cfe112010-09-16 15:54:32 -070019/**
20 * Interface used to get feedback about a {@link android.net.LinkSocket}. Instance is optionally
21 * passed when a LinkSocket is constructed. Multiple LinkSockets may use the same notifier.
22 * @hide
23 */
24public interface LinkSocketNotifier {
25 /**
26 * This callback function will be called if a better link
27 * becomes available.
28 * TODO - this shouldn't be checked for all cases - what's the conditional
29 * flag?
30 * If the duplicate socket is accepted, the original will be marked invalid
31 * and additional use will throw exceptions.
32 * @param original the original LinkSocket
33 * @param duplicate the new LinkSocket that better meets the application
34 * requirements
35 * @return {@code true} if the application intends to use this link
36 *
37 * REM
38 * TODO - how agressive should we be?
39 * At a minimum CS tracks which LS have this turned on and tracks the requirements
40 * When a new link becomes available, automatically check if any of the LinkSockets
41 * will care.
42 * If found, grab a refcount on the link so it doesn't go away and send notification
43 * Optionally, periodically setup connection on available networks to check for better links
44 * Maybe pass this info into the LinkFactories so condition changes can be acted on more quickly
45 */
46 public boolean onBetterLinkAvailable(LinkSocket original, LinkSocket duplicate);
47
48 /**
49 * This callback function will be called when a LinkSocket no longer has
50 * an active link.
51 * @param socket the LinkSocket that lost its link
52 *
53 * REM
54 * NetworkStateTracker tells us it is disconnected
55 * CS checks the table for LS on that link
56 * CS calls each callback (need to work out p2p cross process callback)
57 */
58 public void onLinkLost(LinkSocket socket);
59
60 /**
61 * This callback function will be called when an application calls
62 * requestNewLink on a LinkSocket but the LinkSocket is unable to find
63 * a suitable new link.
64 * @param socket the LinkSocket for which a new link was not found
65 * TODO - why the diff between initial request (sync) and requestNewLink?
66 *
67 * REM
68 * CS process of trying to find a new link must track the LS that started it
69 * on failure, call callback
70 */
71 public void onNewLinkUnavailable(LinkSocket socket);
72
73 /**
74 * This callback function will be called when any of the notification-marked
75 * capabilities of the LinkSocket (e.g. upstream bandwidth) have changed.
76 * @param socket the linkSocet for which capabilities have changed
77 * @param changedCapabilities the set of capabilities that the application
78 * is interested in and have changed (with new values)
79 *
80 * REM
81 * Maybe pass the interesting capabilities into the Links.
82 * Get notified of every capability change
83 * check for LinkSockets on that Link that are interested in that Capability - call them
84 */
Wink Saville6e809972010-09-21 09:15:35 -070085 public void onCapabilitiesChanged(LinkSocket socket, LinkCapabilities changedCapabilities);
Wink Saville00cfe112010-09-16 15:54:32 -070086}