[core] Check loadedApk package name when getting manager binder (#687)

Some OS, like MIUI, inject other loaded apk to manager and will
cause annoying warnings
This commit is contained in:
LoveSy 2021-05-27 22:15:59 +08:00 committed by GitHub
parent c18ec95ce4
commit de98686532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 7 deletions

View File

@ -3,7 +3,7 @@ package org.lsposed.lspd.service;
interface ILSPApplicationService {
IBinder requestModuleBinder() = 2;
IBinder requestManagerBinder() = 3;
IBinder requestManagerBinder(String packageName) = 3;
boolean isResourcesHookEnabled() = 5;

View File

@ -69,9 +69,9 @@ public class LSPApplicationServiceClient implements ILSPApplicationService {
}
@Override
public IBinder requestManagerBinder() {
public IBinder requestManagerBinder(String packageName) {
try {
return service.requestManagerBinder();
return service.requestManagerBinder(packageName);
} catch (RemoteException | NullPointerException ignored) {
}
return null;

View File

@ -28,6 +28,7 @@ import android.content.pm.ApplicationInfo;
import android.content.res.CompatibilityInfo;
import android.os.Environment;
import android.os.IBinder;
import android.os.Process;
import org.lsposed.lspd.config.LSPApplicationServiceClient;
import org.lsposed.lspd.deopt.PrebuiltMethodsDeopter;
@ -102,7 +103,7 @@ public class Main {
XposedInit.startsSystemServer = isSystem;
PrebuiltMethodsDeopter.deoptBootMethods(); // do it once for secondary zygote
installBootstrapHooks(isSystem, appDataDir);
Utils.logI("Loading modules for " + niceName);
Utils.logI("Loading modules for " + niceName + "/" + Process.myUid());
loadModulesSafely();
}

View File

@ -78,7 +78,7 @@ public class LoadedApkGetCLHooker extends XC_MethodHook {
lpparam.appInfo = loadedApk.getApplicationInfo();
lpparam.isFirstApplication = this.isFirstApplication;
IBinder binder = serviceClient.requestManagerBinder();
IBinder binder = loadedApk.getApplicationInfo() != null ? serviceClient.requestManagerBinder(loadedApk.getApplicationInfo().packageName) : null;
if (binder != null) {
if (InstallerVerifier.verifyInstallerSignature(loadedApk.getApplicationInfo())) {
XposedInstallerHooker.hookXposedInstaller(lpparam.classLoader, binder);

View File

@ -101,9 +101,9 @@ public class LSPApplicationService extends ILSPApplicationService.Stub {
}
@Override
public IBinder requestManagerBinder() throws RemoteException {
public IBinder requestManagerBinder(String packageName) throws RemoteException {
ensureRegistered();
if (ConfigManager.getInstance().isManager(getCallingUid())) {
if (ConfigManager.getInstance().isManager(getCallingUid()) && ConfigManager.getInstance().isManager(packageName)) {
var service = ServiceManager.getManagerService();
if (Utils.isMIUI) {
service.new ManagerGuard(handles.get(getCallingPid()));