From edcd4c2bf004c4e1d89aa8f2701c21d6e1a6dce6 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sat, 20 Feb 2021 00:06:28 +0800 Subject: [PATCH] [core] ParceledSliceList cannot accept null --- .../io/github/lsposed/lspd/service/ConfigManager.java | 10 +++++----- .../github/lsposed/lspd/service/LSPManagerService.java | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/io/github/lsposed/lspd/service/ConfigManager.java b/core/src/main/java/io/github/lsposed/lspd/service/ConfigManager.java index 25cce5b9..da14e703 100644 --- a/core/src/main/java/io/github/lsposed/lspd/service/ConfigManager.java +++ b/core/src/main/java/io/github/lsposed/lspd/service/ConfigManager.java @@ -85,7 +85,7 @@ public class ConfigManager { @Override public boolean equals(@Nullable Object o) { - if(o instanceof ProcessScope) { + if (o instanceof ProcessScope) { ProcessScope p = (ProcessScope) o; return p.processName.equals(processName) && p.uid == uid; } @@ -110,16 +110,16 @@ public class ConfigManager { private final ConcurrentHashMap> cachedScope = new ConcurrentHashMap<>(); public static boolean shouldSkipSystemServer() { - try(Cursor cursor = db.query("scope", new String[]{"mid"}, "app_pkg_name=?", new String[]{"android"}, null, null, null)){ + try (Cursor cursor = db.query("scope", new String[]{"mid"}, "app_pkg_name=?", new String[]{"android"}, null, null, null)) { return cursor == null || !cursor.moveToNext(); } } public static String[] getModulesPathForSystemServer() { HashSet modules = new HashSet<>(); - try(Cursor cursor = db.query("scope INNER JOIN modules ON scope.mid = modules.mid", new String[]{"apk_path"}, "app_pkg_name=?", new String[]{"android"}, null, null, null)){ + try (Cursor cursor = db.query("scope INNER JOIN modules ON scope.mid = modules.mid", new String[]{"apk_path"}, "app_pkg_name=?", new String[]{"android"}, null, null, null)) { int apkPathIdx = cursor.getColumnIndex("apk_path"); - while(cursor.moveToNext()) { + while (cursor.moveToNext()) { modules.add(cursor.getString(apkPathIdx)); } } @@ -210,7 +210,7 @@ public class ConfigManager { PackageInfo pkgInfo = PackageService.getPackageInfo(app.packageName, 0, app.userId); List processes = new ArrayList<>(); if (pkgInfo != null && pkgInfo.applicationInfo != null) { - for(String process: PackageService.getProcessesForUid(pkgInfo.applicationInfo.uid)){ + for (String process : PackageService.getProcessesForUid(pkgInfo.applicationInfo.uid)) { processes.add(new ProcessScope(process, pkgInfo.applicationInfo.uid)); } } diff --git a/core/src/main/java/io/github/lsposed/lspd/service/LSPManagerService.java b/core/src/main/java/io/github/lsposed/lspd/service/LSPManagerService.java index 3a66c726..29d6bd42 100644 --- a/core/src/main/java/io/github/lsposed/lspd/service/LSPManagerService.java +++ b/core/src/main/java/io/github/lsposed/lspd/service/LSPManagerService.java @@ -4,6 +4,9 @@ import android.content.pm.PackageInfo; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.RemoteException; +import android.util.Log; + +import java.util.List; import de.robv.android.xposed.XposedBridge; import io.github.lsposed.lspd.BuildConfig; @@ -11,6 +14,8 @@ import io.github.lsposed.lspd.ILSPManagerService; import io.github.lsposed.lspd.Application; import io.github.lsposed.lspd.utils.ParceledListSlice; +import static io.github.lsposed.lspd.service.ServiceManager.TAG; + public class LSPManagerService extends ILSPManagerService.Stub { LSPManagerService() { @@ -60,7 +65,9 @@ public class LSPManagerService extends ILSPManagerService.Stub { @Override public ParceledListSlice getModuleScope(String packageName) { - return new ParceledListSlice(ConfigManager.getInstance().getModuleScope(packageName)); + List list = ConfigManager.getInstance().getModuleScope(packageName); + if (list == null) return null; + else return new ParceledListSlice<>(list); } @Override