Methods Summary |
---|
public int | getPort()
return mPort;
|
public boolean | isBound()
return (mPort != -1);
|
public void | run()
try {
serverSocket = new ServerSocket(0);
if (serverSocket != null) {
setPort(serverSocket.getLocalPort());
while (mIsRunning) {
try {
Socket socket = serverSocket.accept();
// Only receive local connections.
if (socket.getInetAddress().isLoopbackAddress()) {
ProxyConnection parser = new ProxyConnection(socket);
threadExecutor.execute(parser);
} else {
socket.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
} catch (SocketException e) {
Log.e(TAG, "Failed to start proxy server", e);
} catch (IOException e1) {
Log.e(TAG, "Failed to start proxy server", e1);
}
mIsRunning = false;
|
public synchronized void | setCallback(com.android.net.IProxyPortListener callback)
if (mPort != -1) {
try {
callback.setProxyPort(mPort);
} catch (RemoteException e) {
Log.w(TAG, "Proxy failed to report port to PacManager", e);
}
}
mCallback = callback;
|
public synchronized void | setPort(int port)
if (mCallback != null) {
try {
mCallback.setProxyPort(port);
} catch (RemoteException e) {
Log.w(TAG, "Proxy failed to report port to PacManager", e);
}
}
mPort = port;
|
public synchronized void | startServer()
mIsRunning = true;
start();
|
public synchronized void | stopServer()
mIsRunning = false;
if (serverSocket != null) {
try {
serverSocket.close();
serverSocket = null;
} catch (IOException e) {
e.printStackTrace();
}
}
|