[core] Add queryIntentActivities and startActivityAsUserWithFeature
This commit is contained in:
parent
a07239eeb1
commit
15775da810
|
|
@ -22,6 +22,7 @@ package org.lsposed.lspd.service;
|
||||||
import android.app.IActivityManager;
|
import android.app.IActivityManager;
|
||||||
import android.app.IApplicationThread;
|
import android.app.IApplicationThread;
|
||||||
import android.app.IServiceConnection;
|
import android.app.IServiceConnection;
|
||||||
|
import android.app.ProfilerInfo;
|
||||||
import android.content.IIntentReceiver;
|
import android.content.IIntentReceiver;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
|
@ -105,19 +106,32 @@ public class ActivityManagerService {
|
||||||
|
|
||||||
public static int bindService(Intent service,
|
public static int bindService(Intent service,
|
||||||
String resolvedType, IServiceConnection connection, int flags,
|
String resolvedType, IServiceConnection connection, int flags,
|
||||||
String callingPackage, int userId) {
|
String callingPackage, int userId) throws RemoteException {
|
||||||
|
|
||||||
IActivityManager am = getActivityManager();
|
IActivityManager am = getActivityManager();
|
||||||
if (am == null || thread == null) return -1;
|
if (am == null || thread == null) return -1;
|
||||||
return am.bindService(thread, token, service, resolvedType, connection, flags, callingPackage, userId);
|
return am.bindService(thread, token, service, resolvedType, connection, flags, callingPackage, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean unbindService(IServiceConnection connection) {
|
public static boolean unbindService(IServiceConnection connection) throws RemoteException {
|
||||||
IActivityManager am = getActivityManager();
|
IActivityManager am = getActivityManager();
|
||||||
if (am == null) return false;
|
if (am == null) return false;
|
||||||
return am.unbindService(connection);
|
return am.unbindService(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int startActivityAsUserWithFeature(IApplicationThread caller, String callingPackage,
|
||||||
|
String callingFeatureId, Intent intent, String resolvedType,
|
||||||
|
IBinder resultTo, String resultWho, int requestCode, int flags,
|
||||||
|
ProfilerInfo profilerInfo, Bundle options, int userId) throws RemoteException {
|
||||||
|
IActivityManager am = getActivityManager();
|
||||||
|
if (am == null || thread == null) return -1;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
return am.startActivityAsUserWithFeature(caller, callingPackage, callingFeatureId, intent, resolvedType, resultTo, resultWho, requestCode, flags, profilerInfo, options, userId);
|
||||||
|
} else {
|
||||||
|
return am.startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo, resultWho, requestCode, flags, profilerInfo, options, userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void onSystemServerContext(IApplicationThread thread, IBinder token) {
|
public static void onSystemServerContext(IApplicationThread thread, IBinder token) {
|
||||||
ActivityManagerService.thread = thread;
|
ActivityManagerService.thread = thread;
|
||||||
ActivityManagerService.token = token;
|
ActivityManagerService.token = token;
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ public class PackageService {
|
||||||
return result[0];
|
return result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int installExistingPackageAsUser(String packageName, int userId) {
|
public static int installExistingPackageAsUser(String packageName, int userId) throws RemoteException {
|
||||||
IPackageManager pm = getPackageManager();
|
IPackageManager pm = getPackageManager();
|
||||||
Log.d(TAG, "about to install existing package " + packageName + "/" + userId);
|
Log.d(TAG, "about to install existing package " + packageName + "/" + userId);
|
||||||
if (pm == null) return INSTALL_FAILED_INTERNAL_ERROR;
|
if (pm == null) return INSTALL_FAILED_INTERNAL_ERROR;
|
||||||
|
|
@ -269,6 +269,12 @@ public class PackageService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static android.content.pm.ParceledListSlice queryIntentActivities(android.content.Intent intent, java.lang.String resolvedType, int flags, int userId) throws RemoteException {
|
||||||
|
IPackageManager pm = getPackageManager();
|
||||||
|
if (pm == null) return null;
|
||||||
|
return pm.queryIntentActivities(intent, resolvedType, flags, userId);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("JavaReflectionMemberAccess")
|
@SuppressWarnings("JavaReflectionMemberAccess")
|
||||||
public static synchronized boolean installManagerIfAbsent(String packageName, File apkFile) {
|
public static synchronized boolean installManagerIfAbsent(String packageName, File apkFile) {
|
||||||
IPackageManager pm = getPackageManager();
|
IPackageManager pm = getPackageManager();
|
||||||
|
|
|
||||||
|
|
@ -63,22 +63,22 @@ public interface IActivityManager extends IInterface {
|
||||||
IBinder resultTo, String resultWho, int requestCode, int flags,
|
IBinder resultTo, String resultWho, int requestCode, int flags,
|
||||||
ProfilerInfo profilerInfo, Bundle options, int userId) throws RemoteException;
|
ProfilerInfo profilerInfo, Bundle options, int userId) throws RemoteException;
|
||||||
|
|
||||||
void forceStopPackage(String packageName, int userId);
|
void forceStopPackage(String packageName, int userId) throws RemoteException;
|
||||||
|
|
||||||
boolean startUserInBackground(int userid);
|
boolean startUserInBackground(int userid) throws RemoteException;
|
||||||
|
|
||||||
Intent registerReceiver(IApplicationThread caller, String callerPackage,
|
Intent registerReceiver(IApplicationThread caller, String callerPackage,
|
||||||
IIntentReceiver receiver, IntentFilter filter,
|
IIntentReceiver receiver, IntentFilter filter,
|
||||||
String requiredPermission, int userId, int flags);
|
String requiredPermission, int userId, int flags);
|
||||||
Intent registerReceiverWithFeature(IApplicationThread caller, String callerPackage,
|
Intent registerReceiverWithFeature(IApplicationThread caller, String callerPackage,
|
||||||
String callingFeatureId, IIntentReceiver receiver, IntentFilter filter,
|
String callingFeatureId, IIntentReceiver receiver, IntentFilter filter,
|
||||||
String requiredPermission, int userId, int flags);
|
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);
|
String callingPackage, int userId) throws RemoteException;
|
||||||
|
|
||||||
boolean unbindService(IServiceConnection connection);
|
boolean unbindService(IServiceConnection connection) throws RemoteException;
|
||||||
|
|
||||||
abstract class Stub extends Binder implements IActivityManager {
|
abstract class Stub extends Binder implements IActivityManager {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,13 @@ public interface IPackageManager extends IInterface {
|
||||||
IPackageInstaller getPackageInstaller() throws RemoteException;
|
IPackageInstaller getPackageInstaller() throws RemoteException;
|
||||||
|
|
||||||
int installExistingPackageAsUser(String packageName, int userId, int installFlags,
|
int installExistingPackageAsUser(String packageName, int userId, int installFlags,
|
||||||
int installReason);
|
int installReason) throws RemoteException;;
|
||||||
|
|
||||||
@RequiresApi(29)
|
@RequiresApi(29)
|
||||||
int installExistingPackageAsUser(String packageName, int userId, int installFlags,
|
int installExistingPackageAsUser(String packageName, int userId, int installFlags,
|
||||||
int installReason, List<String> whiteListedPermissions);
|
int installReason, List<String> whiteListedPermissions) throws RemoteException;;
|
||||||
|
|
||||||
|
android.content.pm.ParceledListSlice queryIntentActivities(android.content.Intent intent, java.lang.String resolvedType, int flags, int userId) throws RemoteException;
|
||||||
|
|
||||||
abstract class Stub extends Binder implements IPackageManager {
|
abstract class Stub extends Binder implements IPackageManager {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue