summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/providers/downloads/FakeIConnectivityManager.java
blob: 0e92bd5f96e48e38ab7566c1a0c6c73a0866c89d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.providers.downloads;

import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.os.IBinder;
import android.os.RemoteException;

class FakeIConnectivityManager implements IConnectivityManager {
    private static class MockNetworkInfo extends NetworkInfo {
        private State mState;

        @SuppressWarnings("deprecation")
        public MockNetworkInfo(State state) {
            super(0);
            mState = state;
        }

        @Override
        public State getState() {
            return mState;
        }

        @Override
        public int getType() {
            return ConnectivityManager.TYPE_MOBILE;
        }
    }

    private State mCurrentState = State.CONNECTED;

    public void setNetworkState(State state) {
        mCurrentState = state;
    }

    public IBinder asBinder() {
        throw new UnsupportedOperationException();
    }

    public NetworkInfo getActiveNetworkInfo() throws RemoteException {
        return new MockNetworkInfo(mCurrentState);
    }

    public NetworkInfo[] getAllNetworkInfo() throws RemoteException {
        return new NetworkInfo[] {getActiveNetworkInfo()};
    }

    public boolean getBackgroundDataSetting() throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public int getLastTetherError(String iface) throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public boolean getMobileDataEnabled() throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public NetworkInfo getNetworkInfo(int networkType) throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public int getNetworkPreference() throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public String[] getTetherableIfaces() throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public String[] getTetherableUsbRegexs() throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public String[] getTetherableWifiRegexs() throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public String[] getTetheredIfaces() throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public String[] getTetheringErroredIfaces() throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public boolean isTetheringSupported() throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public boolean requestRouteToHost(int networkType, int hostAddress) throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public void setBackgroundDataSetting(boolean allowBackgroundData) throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public void setMobileDataEnabled(boolean enabled) throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public void setNetworkPreference(int pref) throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public boolean setRadio(int networkType, boolean turnOn) throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public boolean setRadios(boolean onOff) throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public int startUsingNetworkFeature(int networkType, String feature, IBinder binder)
            throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public int stopUsingNetworkFeature(int networkType, String feature) throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public int tether(String iface) throws RemoteException {
        throw new UnsupportedOperationException();
    }

    public int untether(String iface) throws RemoteException {
        throw new UnsupportedOperationException();
    }
}