[core] Detect all StrictMode VmPolicy (#792)
This commit is contained in:
parent
fe5dcbc3a3
commit
cce59d2f43
|
|
@ -22,9 +22,13 @@ 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;
|
||||
|
||||
import com.android.internal.os.BinderInternal;
|
||||
|
|
@ -74,6 +78,7 @@ public class ServiceManager {
|
|||
System.exit(1);
|
||||
});
|
||||
|
||||
Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
|
||||
Looper.prepareMainLooper();
|
||||
mainService = new LSPosedService();
|
||||
moduleService = new LSPModuleService();
|
||||
|
|
@ -83,7 +88,7 @@ public class ServiceManager {
|
|||
|
||||
systemServerService.putBinderForSystemServer();
|
||||
|
||||
android.os.Process.killProcess(android.system.Os.getppid());
|
||||
Process.killProcess(Os.getppid());
|
||||
|
||||
createSystemContext();
|
||||
|
||||
|
|
@ -120,15 +125,8 @@ public class ServiceManager {
|
|||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
}
|
||||
|
||||
//noinspection InfiniteLoopStatement
|
||||
while (true) {
|
||||
try {
|
||||
Looper.loop();
|
||||
} catch (Throwable e) {
|
||||
Log.i(TAG, "server exited with " + Log.getStackTraceString(e));
|
||||
Log.i(TAG, "restarting");
|
||||
}
|
||||
}
|
||||
Looper.loop();
|
||||
throw new RuntimeException("Main thread loop unexpectedly exited");
|
||||
}
|
||||
|
||||
public static LSPModuleService getModuleService() {
|
||||
|
|
@ -158,6 +156,15 @@ public class ServiceManager {
|
|||
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() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue