parent
4ad1d95915
commit
106aea6da8
|
|
@ -98,6 +98,11 @@ public class ActivityManagerService {
|
|||
String requiredPermission, int userId, int flags) throws RemoteException {
|
||||
IActivityManager am = getActivityManager();
|
||||
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) {
|
||||
return am.registerReceiverWithFeature(thread, callerPackage, callingFeatureId, receiver, filter, requiredPermission, userId, flags);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -299,13 +299,17 @@ public class PackageService {
|
|||
|
||||
// Install manager
|
||||
IPackageInstaller installerService = pm.getPackageInstaller();
|
||||
PackageInstaller installer;
|
||||
PackageInstaller installer = null;
|
||||
// S Preview
|
||||
if (Build.VERSION.SDK_INT > 30 || Build.VERSION.SDK_INT == 30 && Build.VERSION.PREVIEW_SDK_INT != 0) {
|
||||
Constructor<PackageInstaller> installerConstructor = PackageInstaller.class.getConstructor(IPackageInstaller.class, String.class, String.class, int.class);
|
||||
installerConstructor.setAccessible(true);
|
||||
installer = installerConstructor.newInstance(installerService, null, null, 0);
|
||||
} else {
|
||||
try {
|
||||
Constructor<PackageInstaller> installerConstructor = PackageInstaller.class.getConstructor(IPackageInstaller.class, String.class, String.class, int.class);
|
||||
installerConstructor.setAccessible(true);
|
||||
installer = installerConstructor.newInstance(installerService, null, null, 0);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
if (installer == null) {
|
||||
Constructor<PackageInstaller> installerConstructor = PackageInstaller.class.getConstructor(IPackageInstaller.class, String.class, int.class);
|
||||
installerConstructor.setAccessible(true);
|
||||
installer = installerConstructor.newInstance(installerService, null, 0);
|
||||
|
|
|
|||
|
|
@ -77,6 +77,11 @@ public interface IActivityManager extends IInterface {
|
|||
String callingFeatureId, IIntentReceiver receiver, IntentFilter filter,
|
||||
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,
|
||||
String resolvedType, IServiceConnection connection, int flags,
|
||||
String callingPackage, int userId) throws RemoteException;
|
||||
|
|
|
|||
Loading…
Reference in New Issue