This commit is contained in:
LoveSy 2021-05-25 15:50:57 +08:00 committed by GitHub
parent 4ad1d95915
commit 106aea6da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View File

@ -98,6 +98,11 @@ public class ActivityManagerService {
String requiredPermission, int userId, int flags) throws RemoteException { String requiredPermission, int userId, int flags) throws RemoteException {
IActivityManager am = getActivityManager(); IActivityManager am = getActivityManager();
if (am == null || thread == null) return null; if (am == null || thread == null) return null;
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S || (Build.VERSION.SDK_INT == Build.VERSION_CODES.R && Build.VERSION.PREVIEW_SDK_INT != 0))
return am.registerReceiverWithFeature(thread, callerPackage, callingFeatureId, "null", receiver, filter, requiredPermission, userId, flags);
} catch (Throwable ignored) {
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
return am.registerReceiverWithFeature(thread, callerPackage, callingFeatureId, receiver, filter, requiredPermission, userId, flags); return am.registerReceiverWithFeature(thread, callerPackage, callingFeatureId, receiver, filter, requiredPermission, userId, flags);
} else { } else {

View File

@ -299,13 +299,17 @@ public class PackageService {
// Install manager // Install manager
IPackageInstaller installerService = pm.getPackageInstaller(); IPackageInstaller installerService = pm.getPackageInstaller();
PackageInstaller installer; PackageInstaller installer = null;
// S Preview // S Preview
if (Build.VERSION.SDK_INT > 30 || Build.VERSION.SDK_INT == 30 && Build.VERSION.PREVIEW_SDK_INT != 0) { if (Build.VERSION.SDK_INT > 30 || Build.VERSION.SDK_INT == 30 && Build.VERSION.PREVIEW_SDK_INT != 0) {
try {
Constructor<PackageInstaller> installerConstructor = PackageInstaller.class.getConstructor(IPackageInstaller.class, String.class, String.class, int.class); Constructor<PackageInstaller> installerConstructor = PackageInstaller.class.getConstructor(IPackageInstaller.class, String.class, String.class, int.class);
installerConstructor.setAccessible(true); installerConstructor.setAccessible(true);
installer = installerConstructor.newInstance(installerService, null, null, 0); installer = installerConstructor.newInstance(installerService, null, null, 0);
} else { } catch (Throwable ignored) {
}
}
if (installer == null) {
Constructor<PackageInstaller> installerConstructor = PackageInstaller.class.getConstructor(IPackageInstaller.class, String.class, int.class); Constructor<PackageInstaller> installerConstructor = PackageInstaller.class.getConstructor(IPackageInstaller.class, String.class, int.class);
installerConstructor.setAccessible(true); installerConstructor.setAccessible(true);
installer = installerConstructor.newInstance(installerService, null, 0); installer = installerConstructor.newInstance(installerService, null, 0);

View File

@ -77,6 +77,11 @@ public interface IActivityManager extends IInterface {
String callingFeatureId, IIntentReceiver receiver, IntentFilter filter, String callingFeatureId, IIntentReceiver receiver, IntentFilter filter,
String requiredPermission, int userId, int flags) throws RemoteException; String requiredPermission, int userId, int flags) throws RemoteException;
@RequiresApi(31)
Intent registerReceiverWithFeature(IApplicationThread caller, String callerPackage, String callingFeatureId,
String receiverId, IIntentReceiver receiver, IntentFilter filter,
String requiredPermission, int userId, int flags) throws RemoteException;
int bindService(IApplicationThread caller, IBinder token, Intent service, int bindService(IApplicationThread caller, IBinder token, Intent service,
String resolvedType, IServiceConnection connection, int flags, String resolvedType, IServiceConnection connection, int flags,
String callingPackage, int userId) throws RemoteException; String callingPackage, int userId) throws RemoteException;