[core] Check system properties (#732)

This commit is contained in:
LoveSy 2021-06-05 14:03:38 +08:00 committed by GitHub
parent 4cb731c1fb
commit 9c8f9beb49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 41 additions and 2 deletions

View File

@ -266,6 +266,14 @@ public class ConfigManager {
}
}
public static boolean dex2oatFlagsLoaded() {
try {
return LSPManagerServiceClient.dex2oatFlagsLoaded();
} catch (Throwable e) {
return false;
}
}
public static int startActivityAsUserWithFeature(Intent intent, int userId) {
try {
return LSPManagerServiceClient.startActivityAsUserWithFeature(intent, userId);

View File

@ -181,4 +181,9 @@ public class LSPManagerServiceClient {
ensureService();
return service.queryIntentActivitiesAsUser(intent, flags, userId);
}
public static boolean dex2oatFlagsLoaded() throws RemoteException, NullPointerException {
ensureService();
return service.dex2oatFlagsLoaded();
}
}

View File

@ -61,6 +61,9 @@ public class InfoDialogBuilder extends BlurBehindDialogBuilder {
} else if (!ConfigManager.systemServerRequested()) {
binding.note.setVisibility(View.VISIBLE);
binding.note.setText(HtmlCompat.fromHtml(context.getString(R.string.system_inject_fail), HtmlCompat.FROM_HTML_MODE_LEGACY));
} else if (!ConfigManager.dex2oatFlagsLoaded()) {
binding.note.setVisibility(View.VISIBLE);
binding.note.setText(HtmlCompat.fromHtml(context.getString(R.string.system_prop_incorrect), HtmlCompat.FROM_HTML_MODE_LEGACY));
}
setView(binding.getRoot());

View File

@ -113,6 +113,11 @@ public class HomeFragment extends BaseFragment {
cardBackgroundColor = ResourcesKt.resolveColor(activity.getTheme(), R.attr.colorWarning);
binding.statusIcon.setImageResource(R.drawable.ic_warning);
binding.statusSummary.setText(R.string.system_inject_fail_summary);
} else if (!ConfigManager.dex2oatFlagsLoaded()) {
binding.statusTitle.setText(R.string.partial_activated);
cardBackgroundColor = ResourcesKt.resolveColor(activity.getTheme(), R.attr.colorWarning);
binding.statusIcon.setImageResource(R.drawable.ic_warning);
binding.statusSummary.setText(R.string.system_prop_incorrect_summary);
} else {
binding.statusTitle.setText(R.string.activated);
cardBackgroundColor = ResourcesKt.resolveColor(activity.getTheme(), R.attr.colorNormal);

View File

@ -43,6 +43,8 @@
<string name="selinux_policy_not_loaded"><![CDATA[<b>警告:</b>SEPolicy 未被正确加载,作用于系统框架的模块将不起作用。<br>请将此报告给 <a href="https://github.com/topjohnwu/Magisk/issues"><b>Magisk</b></a> 开发者。]]></string>
<string name="system_inject_fail_summary">系统框架注入失败</string>
<string name="system_inject_fail"><![CDATA[<b>警告:</b>系统注入失败。<br/>这是极罕见的情况,可能是由 <b>Magisk</b> 或低质 Magisk 模块导致。<br/>请尝试禁用除 Riru 和 LSPosed 外的 Magisk 模块,或向开发者提供完整日志。]]></string>
<string name="system_prop_incorrect_summary">系统属性异常</string>
<string name="system_prop_incorrect"><![CDATA[<b>警告:</b>系统属性异常。<br/>一些必须的系统属性被删除或被修改。<br/>模块可能会随机失效。]]></string>
<string name="info_api_version">API 版本</string>
<string name="info_framework_version">框架版本</string>
<string name="info_manager_version">管理器版本</string>

View File

@ -43,6 +43,8 @@
<string name="selinux_policy_not_loaded"><![CDATA[<b>WARNING:</b> SEPolicy is not loaded properly, modules that hook System Framework will not work.<br/>Please report this to <a href="https://github.com/topjohnwu/Magisk/issues"><b>Magisk</b></a> developer.]]></string>
<string name="system_inject_fail_summary">System Framework injection failed</string>
<string name="system_inject_fail"><![CDATA[<b>WARNING:</b> System Framework inject failed.<br/>This is rare and may be caused by <b>Magisk</b> or some low-quality Magisk modules.<br/>Please try to disable Magisk modules other than Riru and LSPosed or submit full log to developers.]]></string>
<string name="system_prop_incorrect_summary">System prop incorrect</string>
<string name="system_prop_incorrect"><![CDATA[<b>WARNING:</b> System prop incorrect.<br/>Some necessary system properties deleted or modified.<br/>Modules may invalidate occasionally.]]></string>
<string name="info_api_version">API version</string>
<string name="info_framework_version">Framework version</string>
<string name="info_manager_version">Manager version</string>

View File

@ -38,7 +38,7 @@ val commitCount = Git(repo).log().add(refId).call().count()
val defaultManagerPackageName by extra("org.lsposed.manager")
val verCode by extra(commitCount + 4200)
val verName by extra("v1.4.4")
val verName by extra("v1.4.5")
val androidTargetSdkVersion by extra(30)
val androidMinSdkVersion by extra(27)
val androidBuildToolsVersion by extra("30.0.3")

View File

@ -32,6 +32,7 @@ import android.content.pm.VersionedPackage;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.util.Log;
import org.lsposed.lspd.BuildConfig;
@ -50,6 +51,9 @@ public class LSPManagerService extends ILSPManagerService.Stub {
public Object guard = null;
private static final String PROP_NAME = "dalvik.vm.dex2oat-flags";
private static final String PROP_VALUE = "--inline-max-code-units=0";
public class ManagerGuard implements IBinder.DeathRecipient {
private final IBinder binder;
private final IServiceConnection connection = new IServiceConnection.Stub() {
@ -203,7 +207,7 @@ public class LSPManagerService extends ILSPManagerService.Stub {
}
@Override
public boolean isSepolicyLoaded() throws RemoteException {
public boolean isSepolicyLoaded() {
return ConfigManager.getInstance().isSepolicyLoaded();
}
@ -253,4 +257,12 @@ public class LSPManagerService extends ILSPManagerService.Stub {
public ParceledListSlice<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, int flags, int userId) throws RemoteException {
return PackageService.queryIntentActivities(intent, intent.getType(), flags, userId);
}
@Override
public boolean dex2oatFlagsLoaded() {
// var splitFlags = new ArrayList<>(Arrays.asList(flags.split(" ")));
// splitFlags.add(PROP_VALUE);
// SystemProperties.set(PROP_NAME, String.join(" ", splitFlags));
return SystemProperties.get(PROP_NAME).contains(PROP_VALUE);
}
}

View File

@ -57,4 +57,6 @@ interface ILSPManagerService {
int startActivityAsUserWithFeature(in Intent intent, int userId) = 30;
ParceledListSlice<ResolveInfo> queryIntentActivitiesAsUser(in Intent intent, int flags, int userId) = 31;
boolean dex2oatFlagsLoaded() = 32;
}