Ejemplo n.º 1
0
  /**
   * Tries to open socket to Zygote process if not already open. If already open, does nothing. May
   * block and retry.
   */
  private static ZygoteState openZygoteSocketIfNeeded(String abi) throws ZygoteStartFailedEx {
    if (primaryZygoteState == null || primaryZygoteState.isClosed()) {
      primaryZygoteState = ZygoteState.connect(ZYGOTE_SOCKET, getNumTries(primaryZygoteState));
    }

    if (primaryZygoteState.matches(abi)) {
      return primaryZygoteState;
    }

    // TODO: Get rid of this. This is a temporary workaround until all the
    // compilation related pieces for the dual zygote stack are ready.
    // b/3647418.
    if (System.getenv("ANDROID_SOCKET_" + SECONDARY_ZYGOTE_SOCKET) == null) {
      Log.e(LOG_TAG, "Forcing app to primary zygote, secondary unavailable (ABI= " + abi + ")");
      // Should be :
      // throw new ZygoteStartFailedEx("Unsupported zygote ABI: " + abi);
      return primaryZygoteState;
    }

    // The primary zygote didn't match. Try the secondary.
    if (secondaryZygoteState == null || secondaryZygoteState.isClosed()) {
      secondaryZygoteState =
          ZygoteState.connect(SECONDARY_ZYGOTE_SOCKET, getNumTries(secondaryZygoteState));
    }

    if (secondaryZygoteState.matches(abi)) {
      return secondaryZygoteState;
    }

    throw new ZygoteStartFailedEx("Unsupported zygote ABI: " + abi);
  }
Ejemplo n.º 2
0
  /**
   * Tries to open socket to Zygote process if not already open. If already open, does nothing. May
   * block and retry.
   */
  private static ZygoteState openZygoteSocketIfNeeded(String abi) throws ZygoteStartFailedEx {
    if (primaryZygoteState == null || primaryZygoteState.isClosed()) {
      primaryZygoteState = ZygoteState.connect(ZYGOTE_SOCKET, getNumTries(primaryZygoteState));
    }

    if (primaryZygoteState.matches(abi)) {
      return primaryZygoteState;
    }

    // The primary zygote didn't match. Try the secondary.
    if (secondaryZygoteState == null || secondaryZygoteState.isClosed()) {
      secondaryZygoteState =
          ZygoteState.connect(SECONDARY_ZYGOTE_SOCKET, getNumTries(secondaryZygoteState));
    }

    if (secondaryZygoteState.matches(abi)) {
      return secondaryZygoteState;
    }

    throw new ZygoteStartFailedEx("Unsupported zygote ABI: " + abi);
  }