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

Commit 23468dd4 authored by Song Chun Fan's avatar Song Chun Fan
Browse files

[pm] Avoid system server watchdog kills during native library extraction

The native library extraction could take a long time especially when IO is already slow, and can potentially cause the system server to be killed by the watchdog. This patch will pause the thread watchdog during the native library extraction.

BUG: 393698598
FIXES: 393698598
Test: presubmit
FLAG: EXEMPT bug fix
Change-Id: I65661b588af7806cd1d1cee72b339f05b09b5358
parent fa160447
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -219,6 +219,7 @@ import com.android.server.pm.dex.DexManager;
import com.android.server.pm.pkg.AndroidPackage;
import com.android.server.pm.pkg.PackageStateInternal;
import com.android.server.pm.verify.developer.DeveloperVerifierController;
import com.android.server.Watchdog;

import libcore.io.IoUtils;
import libcore.util.EmptyArray;
@@ -5006,6 +5007,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                // Use mStageDirInUse to prevent stage dir from being deleted during the extraction.
                markStageDirInUseLocked();
            }
            // Native library extraction may take a very long time and we don't want to trigger
            // a watchdog kill and crash the system server.
            Watchdog.getInstance().pauseWatchingCurrentThread("extract_native_libraries");
            final int res = NativeLibraryHelper.copyNativeBinariesWithOverride(handle, libDir,
                    params.abiOverride, isIncrementalInstallation());
            if (res != INSTALL_SUCCEEDED) {
@@ -5014,6 +5018,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            }
        } finally {
            IoUtils.closeQuietly(handle);
            Watchdog.getInstance().resumeWatchingCurrentThread("extract_native_libraries");
        }
    }