Detect system framework injection status (#619)
This commit is contained in:
parent
0cb223afea
commit
fd32c3107a
|
|
@ -254,4 +254,12 @@ public class ConfigManager {
|
||||||
return Arrays.stream(System.getenv("PATH").split(File.pathSeparator))
|
return Arrays.stream(System.getenv("PATH").split(File.pathSeparator))
|
||||||
.anyMatch(str -> new File(str, "magisk").exists());
|
.anyMatch(str -> new File(str, "magisk").exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean systemServerRequested() {
|
||||||
|
try {
|
||||||
|
return LSPManagerServiceClient.systemServerRequested();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,8 +158,14 @@ public class LSPManagerServiceClient {
|
||||||
ensureService();
|
ensureService();
|
||||||
return service.getUsers();
|
return service.getUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int installExistingPackageAsUser(String packageName, int userId) throws RemoteException, NullPointerException {
|
public static int installExistingPackageAsUser(String packageName, int userId) throws RemoteException, NullPointerException {
|
||||||
ensureService();
|
ensureService();
|
||||||
return service.installExistingPackageAsUser(packageName, userId);
|
return service.installExistingPackageAsUser(packageName, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean systemServerRequested() throws RemoteException, NullPointerException {
|
||||||
|
ensureService();
|
||||||
|
return service.systemServerRequested();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,11 @@ public class MainActivity extends BaseActivity {
|
||||||
cardBackgroundColor = ResourcesKt.resolveColor(getTheme(), R.attr.colorWarning);
|
cardBackgroundColor = ResourcesKt.resolveColor(getTheme(), R.attr.colorWarning);
|
||||||
binding.statusIcon.setImageResource(R.drawable.ic_warning);
|
binding.statusIcon.setImageResource(R.drawable.ic_warning);
|
||||||
binding.statusSummary.setText(R.string.selinux_policy_not_loaded_summary);
|
binding.statusSummary.setText(R.string.selinux_policy_not_loaded_summary);
|
||||||
|
} else if (!ConfigManager.systemServerRequested()) {
|
||||||
|
binding.statusTitle.setText(R.string.partial_activated);
|
||||||
|
cardBackgroundColor = ResourcesKt.resolveColor(getTheme(), R.attr.colorWarning);
|
||||||
|
binding.statusIcon.setImageResource(R.drawable.ic_warning);
|
||||||
|
binding.statusSummary.setText(R.string.system_inject_fail_summary);
|
||||||
} else {
|
} else {
|
||||||
binding.statusTitle.setText(R.string.activated);
|
binding.statusTitle.setText(R.string.activated);
|
||||||
cardBackgroundColor = ResourcesKt.resolveColor(getTheme(), R.attr.colorNormal);
|
cardBackgroundColor = ResourcesKt.resolveColor(getTheme(), R.attr.colorNormal);
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,11 @@ public class InfoDialogBuilder extends BlurBehindDialogBuilder {
|
||||||
binding.systemAbi.setText(Build.SUPPORTED_ABIS[0]);
|
binding.systemAbi.setText(Build.SUPPORTED_ABIS[0]);
|
||||||
|
|
||||||
if (!ConfigManager.isSepolicyLoaded()) {
|
if (!ConfigManager.isSepolicyLoaded()) {
|
||||||
binding.selinux.setVisibility(View.VISIBLE);
|
binding.note.setVisibility(View.VISIBLE);
|
||||||
binding.selinux.setText(HtmlCompat.fromHtml(context.getString(R.string.selinux_policy_not_loaded), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
binding.note.setText(HtmlCompat.fromHtml(context.getString(R.string.selinux_policy_not_loaded), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||||
|
} 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
setView(binding.getRoot());
|
setView(binding.getRoot());
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/selinux"
|
android:id="@+id/note"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
|
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@
|
||||||
<string name="partial_activated">部分激活</string>
|
<string name="partial_activated">部分激活</string>
|
||||||
<string name="selinux_policy_not_loaded_summary">SEPolicy 未被正确加载</string>
|
<string name="selinux_policy_not_loaded_summary">SEPolicy 未被正确加载</string>
|
||||||
<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="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="info_api_version">API 版本</string>
|
<string name="info_api_version">API 版本</string>
|
||||||
<string name="info_framework_version">框架版本</string>
|
<string name="info_framework_version">框架版本</string>
|
||||||
<string name="info_manager_version">管理器版本</string>
|
<string name="info_manager_version">管理器版本</string>
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@
|
||||||
<string name="not_installed">Not installed</string>
|
<string name="not_installed">Not installed</string>
|
||||||
<string name="partial_activated">Partially activated</string>
|
<string name="partial_activated">Partially activated</string>
|
||||||
<string name="selinux_policy_not_loaded_summary">SEPolicy is not loaded properly</string>
|
<string name="selinux_policy_not_loaded_summary">SEPolicy is not loaded properly</string>
|
||||||
<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="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="info_api_version">API version</string>
|
<string name="info_api_version">API version</string>
|
||||||
<string name="info_framework_version">Framework version</string>
|
<string name="info_framework_version">Framework version</string>
|
||||||
<string name="info_manager_version">Manager version</string>
|
<string name="info_manager_version">Manager version</string>
|
||||||
|
|
|
||||||
|
|
@ -180,4 +180,9 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
||||||
return PackageService.INSTALL_FAILED_INTERNAL_ERROR;
|
return PackageService.INSTALL_FAILED_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean systemServerRequested() throws RemoteException {
|
||||||
|
return ServiceManager.systemServerRequested();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@ public class LSPSystemServerService extends ILSPSystemServerService.Stub impleme
|
||||||
public static final String PROXY_SERVICE_NAME = "serial";
|
public static final String PROXY_SERVICE_NAME = "serial";
|
||||||
|
|
||||||
private IBinder originService = null;
|
private IBinder originService = null;
|
||||||
|
private boolean requested = false;
|
||||||
|
|
||||||
|
public boolean systemServerRequested() {
|
||||||
|
return requested;
|
||||||
|
}
|
||||||
|
|
||||||
public void putBinderForSystemServer() {
|
public void putBinderForSystemServer() {
|
||||||
android.os.ServiceManager.addService(PROXY_SERVICE_NAME, this);
|
android.os.ServiceManager.addService(PROXY_SERVICE_NAME, this);
|
||||||
|
|
@ -48,6 +53,7 @@ public class LSPSystemServerService extends ILSPSystemServerService.Stub impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ILSPApplicationService requestApplicationService(int uid, int pid, String processName, IBinder heartBeat) throws RemoteException {
|
public ILSPApplicationService requestApplicationService(int uid, int pid, String processName, IBinder heartBeat) throws RemoteException {
|
||||||
|
requested = true;
|
||||||
if (ConfigManager.getInstance().shouldSkipSystemServer() || uid != 1000 || heartBeat == null || !"android".equals(processName))
|
if (ConfigManager.getInstance().shouldSkipSystemServer() || uid != 1000 || heartBeat == null || !"android".equals(processName))
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
|
|
@ -77,5 +83,6 @@ public class LSPSystemServerService extends ILSPSystemServerService.Stub impleme
|
||||||
originService.unlinkToDeath(this, 0);
|
originService.unlinkToDeath(this, 0);
|
||||||
originService = null;
|
originService = null;
|
||||||
}
|
}
|
||||||
|
requested = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -134,4 +134,7 @@ public class ServiceManager {
|
||||||
return managerService;
|
return managerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean systemServerRequested() {
|
||||||
|
return systemServerService.systemServerRequested();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,6 @@ interface ILSPManagerService {
|
||||||
int[] getUsers() = 27;
|
int[] getUsers() = 27;
|
||||||
|
|
||||||
int installExistingPackageAsUser(String packageName, int userId) = 28;
|
int installExistingPackageAsUser(String packageName, int userId) = 28;
|
||||||
|
|
||||||
|
boolean systemServerRequested() = 29;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue