Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 263829e0 authored by Calin Juravle's avatar Calin Juravle Committed by Android Git Automerger
Browse files

am 5d4deb82: am f7d24d24: Merge "PreInitializeNativeBridge only if its Available"

* commit '5d4deb82':
  PreInitializeNativeBridge only if its Available
parents 64a1a901 5d4deb82
Loading
Loading
Loading
Loading
+13 −13
Original line number Original line Diff line number Diff line
@@ -418,6 +418,10 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra
  pid_t pid = fork();
  pid_t pid = fork();


  if (pid == 0) {
  if (pid == 0) {
    if (!is_system_server && dataDir == NULL) {
        ALOGE("Application private dir cannot be null");
        RuntimeAbort(env);
    }
    // The child process.
    // The child process.
    gMallocLeakZygoteChild = 1;
    gMallocLeakZygoteChild = 1;


@@ -431,13 +435,14 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra


    DropCapabilitiesBoundingSet(env);
    DropCapabilitiesBoundingSet(env);


    bool need_native_bridge = false;
    bool use_native_bridge = !is_system_server && (instructionSet != NULL)
    if (instructionSet != NULL) {
        && android::NativeBridgeAvailable();
    if (use_native_bridge) {
      ScopedUtfChars isa_string(env, instructionSet);
      ScopedUtfChars isa_string(env, instructionSet);
      need_native_bridge = android::NeedsNativeBridge(isa_string.c_str());
      use_native_bridge = android::NeedsNativeBridge(isa_string.c_str());
    }
    }


    if (!MountEmulatedStorage(uid, mount_external, need_native_bridge)) {
    if (!MountEmulatedStorage(uid, mount_external, use_native_bridge)) {
      ALOGW("Failed to mount emulated storage: %s", strerror(errno));
      ALOGW("Failed to mount emulated storage: %s", strerror(errno));
      if (errno == ENOTCONN || errno == EROFS) {
      if (errno == ENOTCONN || errno == EROFS) {
        // When device is actively encrypting, we get ENOTCONN here
        // When device is actively encrypting, we get ENOTCONN here
@@ -466,16 +471,11 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra


    SetRLimits(env, javaRlimits);
    SetRLimits(env, javaRlimits);


    if (!is_system_server && need_native_bridge) {
    if (use_native_bridge) {
      // Set the environment for the apps running with native bridge.
      ScopedUtfChars isa_string(env, instructionSet);
      ScopedUtfChars isa_string(env, instructionSet);  // Known non-null because of need_native_...
      if (dataDir == NULL) {
        android::PreInitializeNativeBridge(NULL, isa_string.c_str());
      } else {
      ScopedUtfChars data_dir(env, dataDir);
      ScopedUtfChars data_dir(env, dataDir);
      android::PreInitializeNativeBridge(data_dir.c_str(), isa_string.c_str());
      android::PreInitializeNativeBridge(data_dir.c_str(), isa_string.c_str());
    }
    }
    }


    int rc = setresgid(gid, gid, gid);
    int rc = setresgid(gid, gid, gid);
    if (rc == -1) {
    if (rc == -1) {