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