[core] ParceledSliceList cannot accept null

This commit is contained in:
LoveSy 2021-02-20 00:06:28 +08:00 committed by tehcneko
parent 50c1713306
commit edcd4c2bf0
2 changed files with 13 additions and 6 deletions

View File

@ -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<ProcessScope, Set<String>> 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<String> 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<ProcessScope> 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));
}
}

View File

@ -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<Application> getModuleScope(String packageName) {
return new ParceledListSlice<Application>(ConfigManager.getInstance().getModuleScope(packageName));
List<Application> list = ConfigManager.getInstance().getModuleScope(packageName);
if (list == null) return null;
else return new ParceledListSlice<>(list);
}
@Override