[core] No more system context (#872)

This commit is contained in:
vvb2060 2021-08-07 22:44:00 +08:00 committed by GitHub
parent ad5cd87d4a
commit 1d9210ee34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 24 deletions

View File

@ -19,15 +19,12 @@
package org.lsposed.lspd.service;
import android.app.ActivityThread;
import android.content.Context;
import android.ddm.DdmHandleAppName;
import android.os.Build;
import android.os.IBinder;
import android.os.IServiceManager;
import android.os.Looper;
import android.os.Process;
import android.os.StrictMode;
import android.system.Os;
import android.util.Log;
@ -36,6 +33,7 @@ import com.android.internal.os.BinderInternal;
import org.lsposed.lspd.BuildConfig;
import java.util.concurrent.ConcurrentHashMap;
import hidden.HiddenApiBridge;
public class ServiceManager {
@ -44,7 +42,6 @@ public class ServiceManager {
private static LSPApplicationService applicationService = null;
private static LSPManagerService managerService = null;
private static LSPSystemServerService systemServerService = null;
private static Context systemContext = null;
public static final String TAG = "LSPosedService";
private static void waitSystemService(String name) {
@ -90,7 +87,7 @@ public class ServiceManager {
Process.killProcess(Os.getppid());
createSystemContext();
DdmHandleAppName.setAppName("lspd", 0);
waitSystemService("package");
waitSystemService("activity");
@ -151,23 +148,4 @@ public class ServiceManager {
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;
}
}