1 /* 2 * Copyright (C) 2021 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.net.NetworkRequest; 20 21 /** 22 * A callback registered with connectivity by network providers together with 23 * a NetworkOffer. 24 * 25 * When the network for this offer is needed to satisfy some application or 26 * system component, connectivity will call onNetworkNeeded on this callback. 27 * When this happens, the provider should try and bring up the network. 28 * 29 * When the network for this offer is no longer needed, for example because 30 * the application has withdrawn the request or if the request is being 31 * satisfied by a network that this offer will never be able to beat, 32 * connectivity calls onNetworkUnneeded. When this happens, the provider 33 * should stop trying to bring up the network, or tear it down if it has 34 * already been brought up. 35 * 36 * When NetworkProvider#offerNetwork is called, the provider can expect to 37 * immediately receive all requests that can be fulfilled by that offer and 38 * are not already satisfied by a better network. It is possible no such 39 * request is currently outstanding, because no requests have been made that 40 * can be satisfied by this offer, or because all such requests are already 41 * satisfied by a better network. 42 * onNetworkNeeded can be called at any time after registration and until the 43 * offer is withdrawn with NetworkProvider#unofferNetwork is called. This 44 * typically happens when a new network request is filed by an application, 45 * or when the network satisfying a request disconnects and this offer now 46 * stands a chance to supply the best network for it. 47 * 48 * @hide 49 */ 50 oneway interface INetworkOfferCallback { 51 /** 52 * Called when a network for this offer is needed to fulfill this request. 53 * @param networkRequest the request to satisfy 54 */ 55 void onNetworkNeeded(in NetworkRequest networkRequest); 56 57 /** 58 * Informs the registrant that the offer is no longer valuable to fulfill this request. 59 */ 60 void onNetworkUnneeded(in NetworkRequest networkRequest); 61 } 62