1/*
2 * Copyright (C) 2016 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 com.android.server.connectivity.tethering;
18
19import android.net.LinkProperties;
20
21/**
22 * @hide
23 *
24 * Interface with methods necessary to notify that a given interface is ready for tethering.
25 *
26 * Rename to something more representative, e.g. IpServingControlCallback.
27 *
28 * All methods MUST be called on the TetherMasterSM main Looper's thread.
29 */
30public class IControlsTethering {
31    public static final int STATE_UNAVAILABLE = 0;
32    public static final int STATE_AVAILABLE   = 1;
33    public static final int STATE_TETHERED    = 2;
34    public static final int STATE_LOCAL_ONLY  = 3;
35
36    public static String getStateString(int state) {
37        switch (state) {
38            case STATE_UNAVAILABLE: return "UNAVAILABLE";
39            case STATE_AVAILABLE:   return "AVAILABLE";
40            case STATE_TETHERED:    return "TETHERED";
41            case STATE_LOCAL_ONLY:  return "LOCAL_ONLY";
42        }
43        return "UNKNOWN: " + state;
44    }
45
46    /**
47     * Notify that |who| has changed its tethering state.
48     *
49     * TODO: Remove the need for the |who| argument.
50     *
51     * @param who corresponding instance of a TetherInterfaceStateMachine
52     * @param state one of IControlsTethering.STATE_*
53     * @param lastError one of ConnectivityManager.TETHER_ERROR_*
54     */
55    public void updateInterfaceState(TetherInterfaceStateMachine who, int state, int lastError) {}
56
57    /**
58     * Notify that |who| has new LinkProperties.
59     *
60     * TODO: Remove the need for the |who| argument.
61     *
62     * @param who corresponding instance of a TetherInterfaceStateMachine
63     * @param newLp the new LinkProperties to report
64     */
65    public void updateLinkProperties(TetherInterfaceStateMachine who, LinkProperties newLp) {}
66}
67