[core] No more system context (#872)
This commit is contained in:
parent
ad5cd87d4a
commit
1d9210ee34
|
|
@ -19,15 +19,12 @@
|
||||||
|
|
||||||
package org.lsposed.lspd.service;
|
package org.lsposed.lspd.service;
|
||||||
|
|
||||||
import android.app.ActivityThread;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.ddm.DdmHandleAppName;
|
import android.ddm.DdmHandleAppName;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.IServiceManager;
|
import android.os.IServiceManager;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.StrictMode;
|
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
@ -36,6 +33,7 @@ import com.android.internal.os.BinderInternal;
|
||||||
import org.lsposed.lspd.BuildConfig;
|
import org.lsposed.lspd.BuildConfig;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import hidden.HiddenApiBridge;
|
import hidden.HiddenApiBridge;
|
||||||
|
|
||||||
public class ServiceManager {
|
public class ServiceManager {
|
||||||
|
|
@ -44,7 +42,6 @@ public class ServiceManager {
|
||||||
private static LSPApplicationService applicationService = null;
|
private static LSPApplicationService applicationService = null;
|
||||||
private static LSPManagerService managerService = null;
|
private static LSPManagerService managerService = null;
|
||||||
private static LSPSystemServerService systemServerService = null;
|
private static LSPSystemServerService systemServerService = null;
|
||||||
private static Context systemContext = null;
|
|
||||||
public static final String TAG = "LSPosedService";
|
public static final String TAG = "LSPosedService";
|
||||||
|
|
||||||
private static void waitSystemService(String name) {
|
private static void waitSystemService(String name) {
|
||||||
|
|
@ -90,7 +87,7 @@ public class ServiceManager {
|
||||||
|
|
||||||
Process.killProcess(Os.getppid());
|
Process.killProcess(Os.getppid());
|
||||||
|
|
||||||
createSystemContext();
|
DdmHandleAppName.setAppName("lspd", 0);
|
||||||
|
|
||||||
waitSystemService("package");
|
waitSystemService("package");
|
||||||
waitSystemService("activity");
|
waitSystemService("activity");
|
||||||
|
|
@ -151,23 +148,4 @@ public class ServiceManager {
|
||||||
return systemServerService.systemServerRequested();
|
return systemServerService.systemServerRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createSystemContext() {
|
|
||||||
ActivityThread activityThread = ActivityThread.systemMain();
|
|
||||||
systemContext = activityThread.getSystemContext();
|
|
||||||
systemContext.setTheme(android.R.style.Theme_DeviceDefault_Light_DarkActionBar);
|
|
||||||
DdmHandleAppName.setAppName("lspd", 0);
|
|
||||||
var vmPolicy = new StrictMode.VmPolicy.Builder();
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
vmPolicy.detectAll().penaltyLog();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
||||||
vmPolicy.penaltyListener(systemContext.getMainExecutor(),
|
|
||||||
v -> Log.w(TAG, v.getMessage(), v));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StrictMode.setVmPolicy(vmPolicy.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Context getSystemContext() {
|
|
||||||
return systemContext;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue