Fix module service not constructed
This commit is contained in:
parent
42aad76b53
commit
b83c0f4169
|
|
@ -22,6 +22,7 @@ package org.lsposed.lspd.service;
|
|||
import static org.lsposed.lspd.service.ServiceManager.TAG;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ContentProviderHolder;
|
||||
import android.app.IActivityManager;
|
||||
import android.app.IApplicationThread;
|
||||
import android.app.IServiceConnection;
|
||||
|
|
@ -188,11 +189,13 @@ public class ActivityManagerService {
|
|||
public static IContentProvider getContentProvider(String auth, int userId) throws RemoteException {
|
||||
IActivityManager am = getActivityManager();
|
||||
if (am == null) return null;
|
||||
ContentProviderHolder holder;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
return am.getContentProviderExternal(auth, userId, token, null).provider;
|
||||
holder = am.getContentProviderExternal(auth, userId, token, null);
|
||||
} else {
|
||||
return am.getContentProviderExternal(auth, userId, token).provider;
|
||||
holder = am.getContentProviderExternal(auth, userId, token);
|
||||
}
|
||||
return holder != null ? holder.provider : null;
|
||||
}
|
||||
|
||||
public static void registerUidObserver(IUidObserver observer, int which, int cutpoint, String callingPackage) throws RemoteException {
|
||||
|
|
|
|||
|
|
@ -541,6 +541,7 @@ public class ConfigManager {
|
|||
var module = new Module();
|
||||
module.packageName = packageName;
|
||||
module.apkPath = apkPath;
|
||||
module.service = new LSPInjectedModuleService(module);
|
||||
modules.add(module);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,17 +15,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
public class LSPInjectedModuleService extends ILSPInjectedModuleService.Stub {
|
||||
private final Module loadedModule;
|
||||
private final LSPModuleService moduleService;
|
||||
|
||||
Map<String, Set<IRemotePreferenceCallback>> callbacks = new ConcurrentHashMap<>();
|
||||
|
||||
LSPInjectedModuleService(Module module) {
|
||||
loadedModule = module;
|
||||
moduleService = new LSPModuleService(module);
|
||||
}
|
||||
|
||||
LSPModuleService getModuleService() {
|
||||
return moduleService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import io.github.libxposed.service.IXposedScopeCallback;
|
||||
|
|
@ -49,8 +50,8 @@ public class LSPModuleService extends IXposedService.Stub {
|
|||
|
||||
private final static String TAG = "LSPosedModuleService";
|
||||
|
||||
|
||||
private final static Set<Integer> uidSet = ConcurrentHashMap.newKeySet();
|
||||
private final static Map<Module, LSPModuleService> serviceMap = new WeakHashMap<>();
|
||||
|
||||
private final @NonNull
|
||||
Module loadedModule;
|
||||
|
|
@ -60,7 +61,8 @@ public class LSPModuleService extends IXposedService.Stub {
|
|||
uidSet.add(uid);
|
||||
var module = ConfigManager.getInstance().getModule(uid);
|
||||
if (module != null) {
|
||||
((LSPInjectedModuleService) module.service).getModuleService().sendBinder(uid);
|
||||
var service = serviceMap.computeIfAbsent(module, LSPModuleService::new);
|
||||
service.sendBinder(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import static org.lsposed.lspd.service.ServiceManager.getExecutorService;
|
|||
|
||||
import android.app.IApplicationThread;
|
||||
import android.app.IUidObserver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.IIntentReceiver;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
|
@ -374,6 +373,10 @@ public class LSPosedService extends ILSPosedService.Stub {
|
|||
|
||||
private void registerUidObserver() {
|
||||
try {
|
||||
var which = HiddenApiBridge.ActivityManager_UID_OBSERVER_ACTIVE()
|
||||
| HiddenApiBridge.ActivityManager_UID_OBSERVER_GONE()
|
||||
| HiddenApiBridge.ActivityManager_UID_OBSERVER_IDLE()
|
||||
| HiddenApiBridge.ActivityManager_UID_OBSERVER_CACHED();
|
||||
ActivityManagerService.registerUidObserver(new IUidObserver.Stub() {
|
||||
@Override
|
||||
public void onUidActive(int uid) {
|
||||
|
|
@ -394,7 +397,7 @@ public class LSPosedService extends ILSPosedService.Stub {
|
|||
public void onUidGone(int uid, boolean disabled) {
|
||||
LSPModuleService.uidGone(uid);
|
||||
}
|
||||
}, HiddenApiBridge.ActivityManager_UID_OBSERVER_ACTIVE() | HiddenApiBridge.ActivityManager_UID_OBSERVER_GONE() | HiddenApiBridge.ActivityManager_UID_OBSERVER_IDLE() | HiddenApiBridge.ActivityManager_UID_OBSERVER_CACHED(), HiddenApiBridge.ActivityManager_PROCESS_STATE_UNKNOWN(), null);
|
||||
}, which, HiddenApiBridge.ActivityManager_PROCESS_STATE_UNKNOWN(), null);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "registerUidObserver", e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,11 +115,9 @@ public interface IActivityManager extends IInterface {
|
|||
void setActivityController(IActivityController watcher, boolean imAMonkey) throws RemoteException;
|
||||
|
||||
@RequiresApi(29)
|
||||
ContentProviderHolder getContentProviderExternal(String name, int userId,
|
||||
IBinder token, String tag);
|
||||
ContentProviderHolder getContentProviderExternal(String name, int userId, IBinder token, String tag) throws RemoteException;
|
||||
|
||||
ContentProviderHolder getContentProviderExternal(String name, int userId,
|
||||
IBinder token);
|
||||
ContentProviderHolder getContentProviderExternal(String name, int userId, IBinder token) throws RemoteException;
|
||||
|
||||
Configuration getConfiguration() throws RemoteException;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue