Java Code Examples for android.net.LocalSocket#getInputStream()

The following examples show how to use android.net.LocalSocket#getInputStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZygoteConnection.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs instance from connected socket.
 *
 * @param socket non-null; connected socket
 * @param abiList non-null; a list of ABIs this zygote supports.
 * @throws IOException
 */
ZygoteConnection(LocalSocket socket, String abiList) throws IOException {
    mSocket = socket;
    this.abiList = abiList;

    mSocketOutStream
            = new DataOutputStream(socket.getOutputStream());

    mSocketReader = new BufferedReader(
            new InputStreamReader(socket.getInputStream()), 256);

    mSocket.setSoTimeout(CONNECTION_TIMEOUT_MILLIS);

    try {
        peer = mSocket.getPeerCredentials();
    } catch (IOException ex) {
        Log.e(TAG, "Cannot read peer credentials", ex);
        throw ex;
    }

    isEof = false;
}
 
Example 2
Source File: ProtocolDetectingSocketHandler.java    From Dream-Catcher with MIT License 6 votes vote down vote up
@Override
protected void onSecured(LocalSocket socket) throws IOException {
  LeakyBufferedInputStream leakyIn = new LeakyBufferedInputStream(
      socket.getInputStream(),
      SENSING_BUFFER_SIZE);

  if (mHandlers.isEmpty()) {
    throw new IllegalStateException("No handlers added");
  }

  for (int i = 0, N = mHandlers.size(); i < N; i++) {
    HandlerInfo handlerInfo = mHandlers.get(i);
    leakyIn.mark(SENSING_BUFFER_SIZE);
    boolean matches = handlerInfo.magicMatcher.matches(leakyIn);
    leakyIn.reset();
    if (matches) {
      LogUtil.d("Matches!" + handlerInfo.handler.getClass().getSimpleName());
      SocketLike socketLike = new SocketLike(socket, leakyIn);
      handlerInfo.handler.onAccepted(socketLike);
      return;
    }
  }

  throw new IOException("No matching handler, firstByte=" + leakyIn.read());
}
 
Example 3
Source File: ProtocolDetectingSocketHandler.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
protected void onSecured(LocalSocket socket) throws IOException {
  LeakyBufferedInputStream leakyIn = new LeakyBufferedInputStream(
      socket.getInputStream(),
      SENSING_BUFFER_SIZE);

  if (mHandlers.isEmpty()) {
    throw new IllegalStateException("No handlers added");
  }

  for (int i = 0, N = mHandlers.size(); i < N; i++) {
    HandlerInfo handlerInfo = mHandlers.get(i);
    leakyIn.mark(SENSING_BUFFER_SIZE);
    boolean matches = handlerInfo.magicMatcher.matches(leakyIn);
    leakyIn.reset();
    if (matches) {
      SocketLike socketLike = new SocketLike(socket, leakyIn);
      handlerInfo.handler.onAccepted(socketLike);
      return;
    }
  }

  throw new IOException("No matching handler, firstByte=" + leakyIn.read());
}
 
Example 4
Source File: ProtocolDetectingSocketHandler.java    From stetho with MIT License 6 votes vote down vote up
@Override
protected void onSecured(LocalSocket socket) throws IOException {
  LeakyBufferedInputStream leakyIn = new LeakyBufferedInputStream(
      socket.getInputStream(),
      SENSING_BUFFER_SIZE);

  if (mHandlers.isEmpty()) {
    throw new IllegalStateException("No handlers added");
  }

  for (int i = 0, N = mHandlers.size(); i < N; i++) {
    HandlerInfo handlerInfo = mHandlers.get(i);
    leakyIn.mark(SENSING_BUFFER_SIZE);
    boolean matches = handlerInfo.magicMatcher.matches(leakyIn);
    leakyIn.reset();
    if (matches) {
      SocketLike socketLike = new SocketLike(socket, leakyIn);
      handlerInfo.handler.onAccepted(socketLike);
      return;
    }
  }

  throw new IOException("No matching handler, firstByte=" + leakyIn.read());
}