diff --git a/java/com/facebook/soloader/BackupSoSource.java b/java/com/facebook/soloader/BackupSoSource.java index a08c100..098657f 100644 --- a/java/com/facebook/soloader/BackupSoSource.java +++ b/java/com/facebook/soloader/BackupSoSource.java @@ -100,7 +100,8 @@ public int loadLibrary(String soName, int loadFlags, StrictMode.ThreadPolicy thr @Override public void prepare(int flags) throws IOException { - if ((flags & SoSource.PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE) != 0) { + if ((flags & SoSource.PREPARE_FLAG_NO_UNPACKING_BACKUP_SO_SOURCE) != 0) { + super.prepare(flags | SoSource.PREPARE_FLAG_NO_UNPACKING); return; } super.prepare(flags); diff --git a/java/com/facebook/soloader/SoLoader.java b/java/com/facebook/soloader/SoLoader.java index deb5c52..c435d7f 100644 --- a/java/com/facebook/soloader/SoLoader.java +++ b/java/com/facebook/soloader/SoLoader.java @@ -534,7 +534,7 @@ private static int makePrepareFlags() { prepareFlags |= SoSource.PREPARE_FLAG_DISABLE_FS_SYNC_JOB; } if ((sFlags & SOLOADER_EXPLICITLY_ENABLE_BACKUP_SOSOURCE) == 0) { - prepareFlags |= SoSource.PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE; + prepareFlags |= SoSource.PREPARE_FLAG_NO_UNPACKING_BACKUP_SO_SOURCE; } return prepareFlags; } finally { diff --git a/java/com/facebook/soloader/SoSource.java b/java/com/facebook/soloader/SoSource.java index e419bc4..9580232 100644 --- a/java/com/facebook/soloader/SoSource.java +++ b/java/com/facebook/soloader/SoSource.java @@ -59,7 +59,9 @@ public abstract class SoSource { public static final int PREPARE_FLAG_DISABLE_FS_SYNC_JOB = (1 << 2); /** Skip preparing backup so source. */ - public static final int PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE = (1 << 3); + public static final int PREPARE_FLAG_NO_UNPACKING_BACKUP_SO_SOURCE = (1 << 3); + + public static final int PREPARE_FLAG_NO_UNPACKING = (1 << 4); /** Prepare to install this SoSource in SoLoader. */ protected void prepare(int flags) throws IOException { diff --git a/java/com/facebook/soloader/UnpackingSoSource.java b/java/com/facebook/soloader/UnpackingSoSource.java index ef1b84f..3f9cc66 100644 --- a/java/com/facebook/soloader/UnpackingSoSource.java +++ b/java/com/facebook/soloader/UnpackingSoSource.java @@ -338,18 +338,23 @@ private boolean refreshLocked(final FileLocker lock, final int flags) throws IOE LogUtil.v(TAG, "so store dirty: regenerating"); writeState(stateFileName, STATE_DIRTY, runFsync); deleteSoFiles(); - try (Unpacker u = makeUnpacker()) { - u.unpack(soDirectory); - } - // N.B. We can afford to write the deps file without fsyncs because we've marked the DSO - // store STATE_DIRTY, which will cause us to ignore all intermediate state when regenerating it. - // That is, it's okay for the depsFile blocks to hit the disk before the actual DSO data file - // blocks as long as both hit the disk before we reset STATE_CLEAN. - final File depsFileName = new File(soDirectory, DEPS_FILE_NAME); - try (RandomAccessFile depsFile = new RandomAccessFile(depsFileName, "rw")) { - depsFile.write(recomputedDeps); - depsFile.setLength(depsFile.getFilePointer()); + final boolean noUnpacking = (flags & PREPARE_FLAG_NO_UNPACKING) != 0; + if (!noUnpacking) { + try (Unpacker u = makeUnpacker()) { + u.unpack(soDirectory); + } + + // N.B. We can afford to write the deps file without fsyncs because we've marked the DSO + // store STATE_DIRTY, which will cause us to ignore all intermediate state when regenerating + // it. + // That is, it's okay for the depsFile blocks to hit the disk before the actual DSO data file + // blocks as long as both hit the disk before we reset STATE_CLEAN. + final File depsFileName = new File(soDirectory, DEPS_FILE_NAME); + try (RandomAccessFile depsFile = new RandomAccessFile(depsFileName, "rw")) { + depsFile.write(recomputedDeps); + depsFile.setLength(depsFile.getFilePointer()); + } } // Task to dump the buffer cache to disk to guard against battery outages. The default is to run