liyujie
2025-08-28 b3810562527858a3b3d98ffa6e9c9c5b0f4a9a8e
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
 * Copyright (C) 2014 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 android.net;
 
import android.content.Context;
import android.os.RemoteException;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.net.DhcpInfo;
import android.net.LinkProperties;
import android.os.Binder;
import android.os.IBinder;
import android.os.Handler;
import android.os.Message;
import android.os.Looper;
import android.os.HandlerThread;
import android.os.RemoteException;
import android.util.Log;
import android.net.IpConfiguration;
import java.util.List;
/**
 * A class to control the pppoe network.
 *
 * @hide
 */
public class PppoeManager {
    private static final String TAG = "PppoeManager";
 
    private final IPppoeManager mService;
    private final Context mContext;
    public static boolean DEBUG = true;
 
    private static void LOG(String msg) {
        if (DEBUG) {
            Log.d(TAG, msg);
        }
    }
    public PppoeManager(Context context, IPppoeManager service) {
        mContext = context;
        mService = service;
    }
    /**
     * @hide
     */
    public static final String EXTRA_PPPOE_ERRMSG = "pppoe_errmsg";
 
    /**
     * @hide
     */
 
    public static final String PPPOE_STATE_CHANGED_ACTION  = "android.net.pppoe.PPPOE_STATE_CHANGED";
 
    /**
     * @hide
     */
    public static final String EXTRA_PPPOE_STATE = "pppoe_state";
 
    /**
     * @hide
     */
    public static final String EXTRA_PREVIOUS_PPPOE_STATE = "previous_pppoe_state";
    /**
     * @hide
     */
    public static final int PPPOE_STATE_DISCONNECTED = 0;
    /**
     * @hide
     */
    public static final int PPPOE_STATE_CONNECTING = 1;
    /**
     * @hide
     */
    public static final int PPPOE_STATE_CONNECTED = 2;
 
    /**
     * @hide
     */
    public static final int PPPOE_STATE_DISCONNECTING = 3;
 
    /**
     * @hide
     */
    public static final int PPPOE_EVENT_CONNECTING = 0;
    public static final int PPPOE_EVENT_CONNECT_SUCCESSED = 1;
    public static final int PPPOE_EVENT_CONNECT_FAILED = 2;
    public static final int PPPOE_EVENT_DISCONNECTING = 3;
    public static final int PPPOE_EVENT_DISCONNECT_SUCCESSED = 4;
 
    public boolean setupPppoe(String iface, String user, String password) {
        try {
            return mService.setupPppoe(iface,user, password);
        } catch (RemoteException e) {
            return false;
        }
    }
 
    public boolean connectPppoe(String iface) {
        try {
            mService.startPppoe(iface);
        } catch (RemoteException e) {
            Log.e(TAG, "startPppoe failed"+e);
            return false;
        }
        return true;
    }
 
    public boolean disconnectPppoe(String iface) {
        try {
            mService.stopPppoe(iface);
        } catch (RemoteException e) {
            Log.e(TAG, "startPppoe failed"+e);
            return false;
        }
        return true;
 
    }
 
    public int getPppoeState(String Iface) {
        try {
            return mService.getPppoeState(Iface);
        } catch (RemoteException e) {
            Log.e(TAG, "stopPppoe failed");
            return -1;
        }
    }
 
    public boolean isPppoeEnabled() {
        try {
            return mService.isPppoeEnabled();
        } catch (RemoteException e) {
            Log.w(TAG,"isAvailable excute failed");
            return false;
        }
    }
 
    public List<String> getPppoeUserInfo(String iface) {
        try {
            return mService.getPppoeUserInfo(iface);
        } catch (RemoteException e) {
            Log.w(TAG,"can't get Pppoe User and Password!");
            return null;
        }
    }
 
    public String getPppoeInterfaceName() {
        try {
            return mService.getPppoeInterfaceName();
        } catch (RemoteException e) {
            Log.e(TAG, "can't get PPPoE interface name");
            return null;
        }
    }
 
    public LinkProperties getPppoelinkProperties() {
        try {
            return mService.getPppoelinkProperties();
        } catch (RemoteException e) {
            Log.w(TAG,"can't get Pppoe linkProperties");
            return null;
        }
 
    }
 
}