Directly launch manager from broadcast without ActivityController (#2625)
This commit is contained in:
parent
1c586fe41f
commit
bc381f4bb5
|
|
@ -163,14 +163,7 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
||||||
if (intent == null) return;
|
if (intent == null) return;
|
||||||
intent = new Intent(intent);
|
intent = new Intent(intent);
|
||||||
intent.setData(withData);
|
intent.setData(withData);
|
||||||
try {
|
ServiceManager.getManagerService().preStartManager(BuildConfig.MANAGER_INJECTED_PKG_NAME, intent, true);
|
||||||
var userInfo = ActivityManagerService.getCurrentUser();
|
|
||||||
if (userInfo == null || userInfo.id != 0) return;
|
|
||||||
ActivityManagerService.startActivityAsUserWithFeature("android", null,
|
|
||||||
intent, intent.getType(), null, null, 0, 0, null, null, 0);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log.e(TAG, "open manager", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("WrongConstant")
|
@SuppressLint("WrongConstant")
|
||||||
|
|
@ -243,7 +236,7 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
||||||
// where starting the target app while the manager is
|
// where starting the target app while the manager is
|
||||||
// still running.
|
// still running.
|
||||||
// We instead let the manager to restart the activity.
|
// We instead let the manager to restart the activity.
|
||||||
synchronized boolean preStartManager(String pkgName, Intent intent) {
|
synchronized boolean preStartManager(String pkgName, Intent intent, boolean doResume) {
|
||||||
// first, check if it's our target app, if not continue the start
|
// first, check if it's our target app, if not continue the start
|
||||||
if (BuildConfig.MANAGER_INJECTED_PKG_NAME.equals(pkgName)) {
|
if (BuildConfig.MANAGER_INJECTED_PKG_NAME.equals(pkgName)) {
|
||||||
Log.d(TAG, "starting target app of parasitic manager");
|
Log.d(TAG, "starting target app of parasitic manager");
|
||||||
|
|
@ -260,6 +253,14 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
||||||
Log.d(TAG, "manager is still running or is on its way");
|
Log.d(TAG, "manager is still running or is on its way");
|
||||||
// there's one running parasitic manager
|
// there's one running parasitic manager
|
||||||
// or it's run by ourself after killing, resume it
|
// or it's run by ourself after killing, resume it
|
||||||
|
if (doResume) {
|
||||||
|
// if doResume is true, we help do the resumption
|
||||||
|
try {
|
||||||
|
ActivityManagerService.startActivityAsUserWithFeature("android", null, intent, intent.getType(), null, null, 0, 0, null, null, 0);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.w(TAG, "resume manager", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (pendingManager) {
|
} else if (pendingManager) {
|
||||||
// Check the flag in case new launch comes before finishing
|
// Check the flag in case new launch comes before finishing
|
||||||
|
|
|
||||||
|
|
@ -468,6 +468,6 @@ public class LSPosedService extends ILSPosedService.Stub {
|
||||||
@Override
|
@Override
|
||||||
public boolean preStartManager(String pkgName, Intent intent) {
|
public boolean preStartManager(String pkgName, Intent intent) {
|
||||||
Log.d(TAG, "checking manager intent");
|
Log.d(TAG, "checking manager intent");
|
||||||
return ServiceManager.getManagerService().preStartManager(pkgName, intent);
|
return ServiceManager.getManagerService().preStartManager(pkgName, intent, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue