[core] Enable debug of ParceledSliceList
This commit is contained in:
parent
e668f7821a
commit
8f76679a38
|
|
@ -240,7 +240,6 @@ namespace lspd {
|
||||||
InstallInlineHooks();
|
InstallInlineHooks();
|
||||||
Init(env);
|
Init(env);
|
||||||
LOGD("Done prepare");
|
LOGD("Done prepare");
|
||||||
// TODO: cache this method
|
|
||||||
FindAndCall(env, "forkAndSpecializePost",
|
FindAndCall(env, "forkAndSpecializePost",
|
||||||
"(Ljava/lang/String;Ljava/lang/String;Landroid/os/IBinder;)V",
|
"(Ljava/lang/String;Ljava/lang/String;Landroid/os/IBinder;)V",
|
||||||
app_data_dir_, nice_name_,
|
app_data_dir_, nice_name_,
|
||||||
|
|
|
||||||
|
|
@ -37,37 +37,37 @@ import static io.github.lsposed.lspd.service.ServiceManager.TAG;
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
static ConfigManager instance = null;
|
static ConfigManager instance = null;
|
||||||
|
|
||||||
static final private File basePath = new File("/data/adb/lspd");
|
private static final File basePath = new File("/data/adb/lspd");
|
||||||
static final private File configPath = new File(basePath, "config");
|
private static final File configPath = new File(basePath, "config");
|
||||||
static final private SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(new File(configPath, "modules_config.db"), null);
|
private static final SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(new File(configPath, "modules_config.db"), null);
|
||||||
|
|
||||||
boolean packageStarted = false;
|
boolean packageStarted = false;
|
||||||
|
|
||||||
static final private File resourceHookSwitch = new File(configPath, "enable_resources");
|
private static final File resourceHookSwitch = new File(configPath, "enable_resources");
|
||||||
private boolean resourceHook = false;
|
private boolean resourceHook = false;
|
||||||
|
|
||||||
static final private File variantSwitch = new File(configPath, "variant");
|
private static final File variantSwitch = new File(configPath, "variant");
|
||||||
private int variant = -1;
|
private int variant = -1;
|
||||||
|
|
||||||
static final private File verboseLogSwitch = new File(configPath, "verbose_log");
|
private static final File verboseLogSwitch = new File(configPath, "verbose_log");
|
||||||
private boolean verboseLog = false;
|
private boolean verboseLog = false;
|
||||||
|
|
||||||
static final private String DEFAULT_MANAGER_PACKAGE_NAME = "io.github.lsposed.manager";
|
private static final String DEFAULT_MANAGER_PACKAGE_NAME = "io.github.lsposed.manager";
|
||||||
|
|
||||||
static final private File managerPath = new File(configPath, "manager");
|
private static final File managerPath = new File(configPath, "manager");
|
||||||
private String manager = null;
|
private String manager = null;
|
||||||
private int managerUid = -1;
|
private int managerUid = -1;
|
||||||
|
|
||||||
static final private File miscFile = new File(basePath, "misc_path");
|
private static final File miscFile = new File(basePath, "misc_path");
|
||||||
private String miscPath = null;
|
private String miscPath = null;
|
||||||
|
|
||||||
static final private File selinuxPath = new File("/sys/fs/selinux/enforce");
|
private static final File selinuxPath = new File("/sys/fs/selinux/enforce");
|
||||||
// only check on boot
|
// only check on boot
|
||||||
final private boolean isPermissive;
|
private final boolean isPermissive;
|
||||||
|
|
||||||
static final private File logPath = new File(basePath, "log");
|
private static final File logPath = new File(basePath, "log");
|
||||||
static final private File modulesLogPath = new File(logPath, "modules.log");
|
private static final File modulesLogPath = new File(logPath, "modules.log");
|
||||||
static final private File verboseLogPath = new File(logPath, "all.log");
|
private static final File verboseLogPath = new File(logPath, "all.log");
|
||||||
|
|
||||||
final FileObserver configObserver = new FileObserver(configPath, FileObserver.MODIFY | FileObserver.DELETE | FileObserver.CREATE | FileObserver.MOVED_TO) {
|
final FileObserver configObserver = new FileObserver(configPath, FileObserver.MODIFY | FileObserver.DELETE | FileObserver.CREATE | FileObserver.MOVED_TO) {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -101,14 +101,14 @@ public class ConfigManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static private final SQLiteStatement createModulesTable = db.compileStatement("CREATE TABLE IF NOT EXISTS modules (" +
|
private final static SQLiteStatement createModulesTable = db.compileStatement("CREATE TABLE IF NOT EXISTS modules (" +
|
||||||
"mid integer PRIMARY KEY AUTOINCREMENT," +
|
"mid integer PRIMARY KEY AUTOINCREMENT," +
|
||||||
"module_pkg_name text NOT NULL UNIQUE," +
|
"module_pkg_name text NOT NULL UNIQUE," +
|
||||||
"apk_path text NOT NULL, " +
|
"apk_path text NOT NULL, " +
|
||||||
"enabled BOOLEAN DEFAULT 0 " +
|
"enabled BOOLEAN DEFAULT 0 " +
|
||||||
"CHECK (enabled IN (0, 1))" +
|
"CHECK (enabled IN (0, 1))" +
|
||||||
");");
|
");");
|
||||||
static private final SQLiteStatement createScopeTable = db.compileStatement("CREATE TABLE IF NOT EXISTS scope (" +
|
private static final SQLiteStatement createScopeTable = db.compileStatement("CREATE TABLE IF NOT EXISTS scope (" +
|
||||||
"mid integer," +
|
"mid integer," +
|
||||||
"app_pkg_name text NOT NULL," +
|
"app_pkg_name text NOT NULL," +
|
||||||
"user_id integer NOT NULL," +
|
"user_id integer NOT NULL," +
|
||||||
|
|
@ -135,11 +135,11 @@ public class ConfigManager {
|
||||||
return modules.toArray(new String[0]);
|
return modules.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static private String readText(@NonNull File file) throws IOException {
|
private static String readText(@NonNull File file) throws IOException {
|
||||||
return new String(Files.readAllBytes(file.toPath())).trim();
|
return new String(Files.readAllBytes(file.toPath())).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
static private String readText(@NonNull File file, String defaultValue) {
|
private static String readText(@NonNull File file, String defaultValue) {
|
||||||
try {
|
try {
|
||||||
if (!file.exists()) return defaultValue;
|
if (!file.exists()) return defaultValue;
|
||||||
return readText(file);
|
return readText(file);
|
||||||
|
|
@ -149,7 +149,7 @@ public class ConfigManager {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private void writeText(@NonNull File file, String value) {
|
private static void writeText(@NonNull File file, String value) {
|
||||||
try {
|
try {
|
||||||
Files.write(file.toPath(), value.getBytes(), StandardOpenOption.CREATE);
|
Files.write(file.toPath(), value.getBytes(), StandardOpenOption.CREATE);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -157,7 +157,7 @@ public class ConfigManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static private int readInt(@NonNull File file, int defaultValue) {
|
private static int readInt(@NonNull File file, int defaultValue) {
|
||||||
try {
|
try {
|
||||||
if (!file.exists()) return defaultValue;
|
if (!file.exists()) return defaultValue;
|
||||||
return Integer.parseInt(readText(file));
|
return Integer.parseInt(readText(file));
|
||||||
|
|
@ -167,7 +167,7 @@ public class ConfigManager {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private void writeInt(@NonNull File file, int value) {
|
private static void writeInt(@NonNull File file, int value) {
|
||||||
writeText(file, String.valueOf(value));
|
writeText(file, String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -342,7 +342,7 @@ public class ConfigManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setModuleScope(String packageName, List<Application> scopes) {
|
public boolean setModuleScope(String packageName, List<Application> scopes) {
|
||||||
if (scopes.isEmpty()) return false;
|
if (scopes == null) return false;
|
||||||
int mid = getModuleId(packageName);
|
int mid = getModuleId(packageName);
|
||||||
if (mid == -1) return false;
|
if (mid == -1) return false;
|
||||||
Application self = new Application();
|
Application self = new Application();
|
||||||
|
|
@ -507,11 +507,15 @@ public class ConfigManager {
|
||||||
return miscPath + File.separator + "prefs" + File.separator + fileName;
|
return miscPath + File.separator + "prefs" + File.separator + fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void grantManagerPermission() {
|
public static void grantManagerPermission() {
|
||||||
try {
|
try {
|
||||||
PackageService.grantRuntimePermission(readText(managerPath, DEFAULT_MANAGER_PACKAGE_NAME), "android.permission.INTERACT_ACROSS_USERS", 0);
|
PackageService.grantRuntimePermission(readText(managerPath, DEFAULT_MANAGER_PACKAGE_NAME), "android.permission.INTERACT_ACROSS_USERS", 0);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, Log.getStackTraceString(e));
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class PackageService {
|
||||||
public static ParceledListSlice<PackageInfo> getInstalledPackagesFromAllUsers(int flags) throws RemoteException {
|
public static ParceledListSlice<PackageInfo> getInstalledPackagesFromAllUsers(int flags) throws RemoteException {
|
||||||
ArrayList<PackageInfo> res = new ArrayList<>();
|
ArrayList<PackageInfo> res = new ArrayList<>();
|
||||||
IPackageManager pm = getPackageManager();
|
IPackageManager pm = getPackageManager();
|
||||||
if (pm == null) return new ParceledListSlice<>(res);
|
if (pm == null) return ParceledListSlice.emptyList();
|
||||||
for (int userId : UserService.getUsers()) {
|
for (int userId : UserService.getUsers()) {
|
||||||
res.addAll(pm.getInstalledPackages(flags, userId).getList());
|
res.addAll(pm.getInstalledPackages(flags, userId).getList());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ public class ServiceManager {
|
||||||
public static void start() {
|
public static void start() {
|
||||||
Log.i(TAG, "starting server...");
|
Log.i(TAG, "starting server...");
|
||||||
|
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler((t, e)->{
|
||||||
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
|
});
|
||||||
|
|
||||||
Looper.prepare();
|
Looper.prepare();
|
||||||
mainService = new LSPosedService();
|
mainService = new LSPosedService();
|
||||||
moduleService = new LSPModuleService();
|
moduleService = new LSPModuleService();
|
||||||
|
|
@ -62,10 +66,6 @@ public class ServiceManager {
|
||||||
Log.e(TAG, Log.getStackTraceString(e));
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler((t, e)->{
|
|
||||||
Log.e(TAG, Log.getStackTraceString(e));
|
|
||||||
});
|
|
||||||
|
|
||||||
//noinspection InfiniteLoopStatement
|
//noinspection InfiniteLoopStatement
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,4 @@ if [[ -f "${MODDIR}/reboot_twice_flag" ]]; then
|
||||||
reboot
|
reboot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/system/bin/app_process -Djava.class.path=/data/adb/lspd/framework/lspd.dex /system/bin --nice-name=lspd io.github.lsposed.lspd.core.Main
|
/system/bin/app_process -Djava.class.path=/data/adb/lspd/framework/lspd.dex /system/bin --nice-name=lspd io.github.lsposed.lspd.core.Main &
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,11 @@ import android.os.Parcelable;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.github.lsposed.lspd.managerservice.BuildConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transfer a large list of Parcelable objects across an IPC. Splits into
|
* Transfer a large list of Parcelable objects across an IPC. Splits into
|
||||||
* multiple transactions if needed.
|
* multiple transactions if needed.
|
||||||
|
|
@ -36,7 +40,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
abstract class BaseParceledListSlice<T> implements Parcelable {
|
abstract class BaseParceledListSlice<T> implements Parcelable {
|
||||||
private static String TAG = "ParceledListSlice";
|
private static String TAG = "ParceledListSlice";
|
||||||
private static boolean DEBUG = false;
|
private static boolean DEBUG = BuildConfig.DEBUG;
|
||||||
/*
|
/*
|
||||||
* TODO get this number from somewhere else. For now set it to a quarter of
|
* TODO get this number from somewhere else. For now set it to a quarter of
|
||||||
* the 1MB limit.
|
* the 1MB limit.
|
||||||
|
|
@ -46,8 +50,12 @@ abstract class BaseParceledListSlice<T> implements Parcelable {
|
||||||
private int mInlineCountLimit = Integer.MAX_VALUE;
|
private int mInlineCountLimit = Integer.MAX_VALUE;
|
||||||
|
|
||||||
public BaseParceledListSlice(List<T> list) {
|
public BaseParceledListSlice(List<T> list) {
|
||||||
|
if(list == null) {
|
||||||
|
mList = Collections.emptyList();
|
||||||
|
} else {
|
||||||
mList = list;
|
mList = list;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
BaseParceledListSlice(Parcel p, ClassLoader loader) {
|
BaseParceledListSlice(Parcel p, ClassLoader loader) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue