Skip to content

Commit

Permalink
Trigger unpacking when /data/app/../lib/arm does not exist
Browse files Browse the repository at this point in the history
Reviewed By: michalgr

Differential Revision: D62753901

fbshipit-source-id: c936ccdb933fd2170c60c209f14a02d693129838
  • Loading branch information
adicatana authored and facebook-github-bot committed Sep 19, 2024
1 parent 132d7bb commit 5d17873
Showing 1 changed file with 50 additions and 36 deletions.
86 changes: 50 additions & 36 deletions java/com/facebook/soloader/recovery/CheckOnDiskStateDataApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,48 +46,62 @@ public boolean recover(UnsatisfiedLinkError error, SoSource[] soSources) {

File nativeLibStandardDir = new File(mContext.getApplicationInfo().nativeLibraryDir);
if (!nativeLibStandardDir.exists()) {
LogUtil.e(
SoLoader.TAG,
"Native library directory "
+ nativeLibStandardDir
+ " does not exist, exiting /data/app recovery.");
return false;
}
for (SoSource soSource : soSources) {
if (!(soSource instanceof BackupSoSource)) {
continue;
}
BackupSoSource uss = (BackupSoSource) soSource;
try {

ArrayList<String> missingLibs = new ArrayList<>();
for (SoSource soSource : soSources) {
if (!(soSource instanceof BackupSoSource)) {
continue;
LogUtil.e(
SoLoader.TAG,
"Native library directory "
+ nativeLibStandardDir
+ " does not exist, will unpack everything under /data/data.");
uss.prepare(0);
break;
} catch (Exception e) {
LogUtil.e(
SoLoader.TAG, "Encountered an exception while recovering from /data/app failure ", e);
return false;
}
}
BackupSoSource uss = (BackupSoSource) soSource;
try {
Dso[] dsosFromArchive = uss.getDsosBaseApk();
for (Dso dso : dsosFromArchive) {
File soFile = new File(nativeLibStandardDir, dso.name);
if (soFile.exists()) {
continue;
}
missingLibs.add(dso.name);
} else {
ArrayList<String> missingLibs = new ArrayList<>();
for (SoSource soSource : soSources) {
if (!(soSource instanceof BackupSoSource)) {
continue;
}
BackupSoSource uss = (BackupSoSource) soSource;
try {
Dso[] dsosFromArchive = uss.getDsosBaseApk();
for (Dso dso : dsosFromArchive) {
File soFile = new File(nativeLibStandardDir, dso.name);
if (soFile.exists()) {
continue;
}
missingLibs.add(dso.name);
}

if (missingLibs.isEmpty()) {
LogUtil.e(SoLoader.TAG, "No libraries missing from " + nativeLibStandardDir);
if (missingLibs.isEmpty()) {
LogUtil.e(SoLoader.TAG, "No libraries missing from " + nativeLibStandardDir);
return false;
}

LogUtil.e(
SoLoader.TAG,
"Missing libraries from "
+ nativeLibStandardDir
+ ": "
+ missingLibs.toString()
+ ", will run prepare on tbe backup so source");
uss.prepare(0);
break;
} catch (Exception e) {
LogUtil.e(
SoLoader.TAG, "Encountered an exception while recovering from /data/app failure ", e);
return false;
}

LogUtil.e(
SoLoader.TAG,
"Missing libraries from "
+ nativeLibStandardDir
+ ": "
+ missingLibs.toString()
+ ", will run prepare on tbe backup so source");
uss.prepare(0);
break;
} catch (Exception e) {
LogUtil.e(
SoLoader.TAG, "Encountered an exception while recovering from /data/app failure ", e);
return false;
}
}

Expand Down

0 comments on commit 5d17873

Please sign in to comment.