Replace ParceledListSlice with ParcelableListSlice (#1936)

This commit is contained in:
南宫雪珊 2022-05-14 23:06:18 +08:00 committed by GitHub
parent 2f0de5b7f3
commit b392f331c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 18 deletions

View File

@ -37,6 +37,7 @@ import android.content.Intent;
import android.content.pm.LauncherApps; import android.content.pm.LauncherApps;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager; import android.content.pm.ShortcutManager;
@ -82,7 +83,7 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import hidden.HiddenApiBridge; import hidden.HiddenApiBridge;
import io.github.xposed.xposedservice.utils.ParceledListSlice; import rikka.parcelablelist.ParcelableListSlice;
public class LSPManagerService extends ILSPManagerService.Stub { public class LSPManagerService extends ILSPManagerService.Stub {
// this maybe useful when obtaining the manager binder // this maybe useful when obtaining the manager binder
@ -293,7 +294,7 @@ public class LSPManagerService extends ILSPManagerService.Stub {
final NotificationChannel channel = final NotificationChannel channel =
new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, CHANNEL_IMP); new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, CHANNEL_IMP);
im.createNotificationChannels("android", im.createNotificationChannels("android",
new android.content.pm.ParceledListSlice<>(Collections.singletonList(channel))); new ParceledListSlice<>(Collections.singletonList(channel)));
im.enqueueNotificationWithTag("android", "android", modulePackageName, im.enqueueNotificationWithTag("android", "android", modulePackageName,
pushAndGetNotificationId(modulePackageName, moduleUserId), pushAndGetNotificationId(modulePackageName, moduleUserId),
notification, 0); notification, 0);
@ -586,7 +587,7 @@ public class LSPManagerService extends ILSPManagerService.Stub {
} }
@Override @Override
public ParceledListSlice<PackageInfo> getInstalledPackagesFromAllUsers(int flags, boolean filterNoProcess) throws RemoteException { public ParcelableListSlice<PackageInfo> getInstalledPackagesFromAllUsers(int flags, boolean filterNoProcess) throws RemoteException {
return PackageService.getInstalledPackagesFromAllUsers(flags, filterNoProcess); return PackageService.getInstalledPackagesFromAllUsers(flags, filterNoProcess);
} }
@ -735,7 +736,7 @@ public class LSPManagerService extends ILSPManagerService.Stub {
} }
@Override @Override
public ParceledListSlice<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, int flags, int userId) throws RemoteException { public ParcelableListSlice<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, int flags, int userId) throws RemoteException {
return PackageService.queryIntentActivities(intent, intent.getType(), flags, userId); return PackageService.queryIntentActivities(intent, intent.getType(), flags, userId);
} }

View File

@ -61,7 +61,7 @@ import java.util.Set;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import io.github.xposed.xposedservice.utils.ParceledListSlice; import rikka.parcelablelist.ParcelableListSlice;
public class PackageService { public class PackageService {
@ -135,10 +135,10 @@ public class PackageService {
} }
// Only for manager // Only for manager
public static ParceledListSlice<PackageInfo> getInstalledPackagesFromAllUsers(int flags, boolean filterNoProcess) throws RemoteException { public static ParcelableListSlice<PackageInfo> getInstalledPackagesFromAllUsers(int flags, boolean filterNoProcess) throws RemoteException {
List<PackageInfo> res = new ArrayList<>(); List<PackageInfo> res = new ArrayList<>();
IPackageManager pm = getPackageManager(); IPackageManager pm = getPackageManager();
if (pm == null) return ParceledListSlice.emptyList(); if (pm == null) return ParcelableListSlice.emptyList();
for (var user : UserService.getUsers()) { for (var user : UserService.getUsers()) {
// in case pkginfo of other users in primary user // in case pkginfo of other users in primary user
res.addAll((Build.VERSION.SDK_INT + Build.VERSION.PREVIEW_SDK_INT > Build.VERSION_CODES.S_V2 ? pm.getInstalledPackages((long) flags, user.id) : pm.getInstalledPackages(flags, user.id)) res.addAll((Build.VERSION.SDK_INT + Build.VERSION.PREVIEW_SDK_INT > Build.VERSION_CODES.S_V2 ? pm.getInstalledPackages((long) flags, user.id) : pm.getInstalledPackages(flags, user.id))
@ -154,7 +154,7 @@ public class PackageService {
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }
if (filterNoProcess) { if (filterNoProcess) {
return new ParceledListSlice<>(res.parallelStream().filter(packageInfo -> { return new ParcelableListSlice<>(res.parallelStream().filter(packageInfo -> {
try { try {
PackageInfo pkgInfo = getPackageInfoWithComponents(packageInfo.packageName, MATCH_ALL_FLAGS, packageInfo.applicationInfo.uid / PER_USER_RANGE); PackageInfo pkgInfo = getPackageInfoWithComponents(packageInfo.packageName, MATCH_ALL_FLAGS, packageInfo.applicationInfo.uid / PER_USER_RANGE);
return !fetchProcesses(pkgInfo).isEmpty(); return !fetchProcesses(pkgInfo).isEmpty();
@ -164,7 +164,7 @@ public class PackageService {
} }
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
} }
return new ParceledListSlice<>(res); return new ParcelableListSlice<>(res);
} }
private static Set<String> fetchProcesses(PackageInfo pkgInfo) { private static Set<String> fetchProcesses(PackageInfo pkgInfo) {
@ -283,17 +283,17 @@ public class PackageService {
} }
} }
public static ParceledListSlice<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) throws RemoteException { public static ParcelableListSlice<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) throws RemoteException {
IPackageManager pm = getPackageManager(); IPackageManager pm = getPackageManager();
if (pm == null) return null; if (pm == null) return null;
return new ParceledListSlice<>((Build.VERSION.SDK_INT + Build.VERSION.PREVIEW_SDK_INT > Build.VERSION_CODES.S_V2 ? pm.queryIntentActivities(intent, resolvedType, (long) flags, userId) : pm.queryIntentActivities(intent, resolvedType, flags, userId)).getList()); return new ParcelableListSlice<>((Build.VERSION.SDK_INT + Build.VERSION.PREVIEW_SDK_INT > Build.VERSION_CODES.S_V2 ? pm.queryIntentActivities(intent, resolvedType, (long) flags, userId) : pm.queryIntentActivities(intent, resolvedType, flags, userId)).getList());
} }
public static Intent getLaunchIntentForPackage(String packageName) throws RemoteException { public static Intent getLaunchIntentForPackage(String packageName) throws RemoteException {
Intent intentToResolve = new Intent(Intent.ACTION_MAIN); Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
intentToResolve.addCategory(Intent.CATEGORY_INFO); intentToResolve.addCategory(Intent.CATEGORY_INFO);
intentToResolve.setPackage(packageName); intentToResolve.setPackage(packageName);
ParceledListSlice<ResolveInfo> ris = queryIntentActivities(intentToResolve, intentToResolve.getType(), 0, 0); var ris = queryIntentActivities(intentToResolve, intentToResolve.getType(), 0, 0);
// Otherwise, try to find a main launcher activity. // Otherwise, try to find a main launcher activity.
if (ris == null || ris.getList().size() <= 0) { if (ris == null || ris.getList().size() <= 0) {

2
external/fmt vendored

@ -1 +1 @@
Subproject commit 96930161f918d08a689076f500f128522a237a75 Subproject commit ae963e444fcdf1ad45f662e0c706568f34506528

2
external/lsplant vendored

@ -1 +1 @@
Subproject commit d3cd9313644499c181212dd66602f6ab2aa75ab6 Subproject commit 5867b673803e255c4f0c75b9055fe7da3209e2ae

View File

@ -1,6 +1,6 @@
package org.lsposed.lspd; package org.lsposed.lspd;
import io.github.xposed.xposedservice.utils.ParceledListSlice; import rikka.parcelablelist.ParcelableListSlice;
import org.lsposed.lspd.models.UserInfo; import org.lsposed.lspd.models.UserInfo;
import org.lsposed.lspd.models.Application; import org.lsposed.lspd.models.Application;
@ -14,7 +14,7 @@ interface ILSPManagerService {
String getApi() = 1; String getApi() = 1;
ParceledListSlice<PackageInfo> getInstalledPackagesFromAllUsers(int flags, boolean filterNoProcess) = 2; ParcelableListSlice<PackageInfo> getInstalledPackagesFromAllUsers(int flags, boolean filterNoProcess) = 2;
String[] enabledModules() = 3; String[] enabledModules() = 3;
@ -60,7 +60,7 @@ interface ILSPManagerService {
int startActivityAsUserWithFeature(in Intent intent, int userId) = 30; int startActivityAsUserWithFeature(in Intent intent, int userId) = 30;
ParceledListSlice<ResolveInfo> queryIntentActivitiesAsUser(in Intent intent, int flags, int userId) = 31; ParcelableListSlice<ResolveInfo> queryIntentActivitiesAsUser(in Intent intent, int flags, int userId) = 31;
boolean dex2oatFlagsLoaded() = 32; boolean dex2oatFlagsLoaded() = 32;

@ -1 +1 @@
Subproject commit ac9744ab71bc899c7954239fadbad605521c4b0c Subproject commit 4eea6d5794e046aeae4e57022c6cc1f7201559d5