[core] Check apk path is not null (#885)

This commit is contained in:
LoveSy 2021-08-11 19:05:42 +08:00 committed by GitHub
parent 09e50460cd
commit 3cc368754b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 15 deletions

View File

@ -476,7 +476,7 @@ public class ConfigManager {
continue; continue;
} }
var path = apkPath; var path = apkPath;
if (!new File(path).exists()) { if (path == null || !new File(path).exists()) {
path = getModuleApkPath(pkgInfo.applicationInfo); path = getModuleApkPath(pkgInfo.applicationInfo);
if (path == null) obsoleteModules.add(packageName); if (path == null) obsoleteModules.add(packageName);
else obsoletePaths.put(packageName, path); else obsoletePaths.put(packageName, path);
@ -621,6 +621,7 @@ public class ConfigManager {
@Nullable @Nullable
private PreLoadedApk loadModule(String path) { private PreLoadedApk loadModule(String path) {
if (path == null) return null;
var file = new PreLoadedApk(); var file = new PreLoadedApk();
var preLoadedDexes = new ArrayList<SharedMemory>(); var preLoadedDexes = new ArrayList<SharedMemory>();
var moduleClassNames = new ArrayList<String>(1); var moduleClassNames = new ArrayList<String>(1);
@ -685,6 +686,10 @@ public class ConfigManager {
apks[info.splitSourceDirs.length] = info.sourceDir; apks[info.splitSourceDirs.length] = info.sourceDir;
} else apks = new String[]{info.sourceDir}; } else apks = new String[]{info.sourceDir};
var apkPath = Arrays.stream(apks).parallel().filter(apk -> { var apkPath = Arrays.stream(apks).parallel().filter(apk -> {
if (apk == null) {
Log.w(TAG, info.packageName + " has null apk path???");
return false;
}
try (var zip = new ZipFile(apk)) { try (var zip = new ZipFile(apk)) {
return zip.getEntry("assets/xposed_init") != null; return zip.getEntry("assets/xposed_init") != null;
} catch (IOException e) { } catch (IOException e) {

View File

@ -25,7 +25,6 @@ import static org.lsposed.lspd.service.ServiceManager.TAG;
import android.app.IServiceConnection; import android.app.IServiceConnection;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
@ -124,15 +123,8 @@ public class LSPManagerService extends ILSPManagerService.Stub {
@Override @Override
public boolean enableModule(String packageName) throws RemoteException { public boolean enableModule(String packageName) throws RemoteException {
PackageInfo pkgInfo = PackageService.getPackageInfo(packageName, PackageService.MATCH_ALL_FLAGS, 0); PackageInfo pkgInfo = PackageService.getPackageInfo(packageName, PackageService.MATCH_ALL_FLAGS, 0);
if (pkgInfo != null) { if (pkgInfo != null && pkgInfo.applicationInfo != null) {
ApplicationInfo appInfo; return ConfigManager.getInstance().enableModule(packageName, pkgInfo.applicationInfo);
try {
appInfo = pkgInfo.applicationInfo;
} catch (Throwable t) {
Log.wtf(TAG, t);
throw t;
}
return ConfigManager.getInstance().enableModule(packageName, appInfo);
} else { } else {
return false; return false;
} }
@ -247,7 +239,7 @@ public class LSPManagerService extends ILSPManagerService.Stub {
} }
@Override @Override
public boolean systemServerRequested() throws RemoteException { public boolean systemServerRequested() {
return ServiceManager.systemServerRequested(); return ServiceManager.systemServerRequested();
} }
@ -271,9 +263,6 @@ public class LSPManagerService extends ILSPManagerService.Stub {
@Override @Override
public boolean dex2oatFlagsLoaded() { public boolean dex2oatFlagsLoaded() {
// var splitFlags = new ArrayList<>(Arrays.asList(flags.split(" ")));
// splitFlags.add(PROP_VALUE);
// SystemProperties.set(PROP_NAME, String.join(" ", splitFlags));
return SystemProperties.get(PROP_NAME).contains(PROP_VALUE); return SystemProperties.get(PROP_NAME).contains(PROP_VALUE);
} }
} }