Skip to content

Commit

Permalink
新增: 系统框架-禁用持久检查
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Jun 6, 2024
1 parent 4670370 commit ed59f12
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.sevtinge.hyperceiler.module.hook.systemframework.DisableFreeformBlackList;
import com.sevtinge.hyperceiler.module.hook.systemframework.DisableLowApiCheckForU;
import com.sevtinge.hyperceiler.module.hook.systemframework.DisableMiuiLite;
import com.sevtinge.hyperceiler.module.hook.systemframework.DisablePersistent;
import com.sevtinge.hyperceiler.module.hook.systemframework.DisablePinVerifyPer72h;
import com.sevtinge.hyperceiler.module.hook.systemframework.DisableVerifyCanBeDisabled;
import com.sevtinge.hyperceiler.module.hook.systemframework.FlagSecure;
Expand Down Expand Up @@ -103,7 +104,7 @@ public void handleLoadPackage() {
initHook(new VolumeSeparateControl(), mPrefsMap.getBoolean("system_framework_volume_separate_control"));
initHook(new VolumeSteps(), mPrefsMap.getInt("system_framework_volume_steps", 0) > 0);
initHook(new VolumeMediaSteps(), mPrefsMap.getBoolean("system_framework_volume_media_steps_enable"));
initHook(new VolumeDisableSafe(), mPrefsMap.getBoolean("system_framework_volume_disable_safe"));
initHook(new VolumeDisableSafe(), mPrefsMap.getStringAsInt("system_framework_volume_disable_safe_new", 0) != 0);

// 其他
initHook(new SystemLockApp(), mPrefsMap.getBoolean("system_framework_guided_access"));
Expand Down Expand Up @@ -168,6 +169,7 @@ public void handleLoadPackage() {
initHook(new LinkTurboToast(), mPrefsMap.getBoolean("system_framework_disable_link_turbo_toast"));

initHook(new DisableLowApiCheckForU(), mPrefsMap.getBoolean("system_framework_disable_low_api_check") && isMoreAndroidVersion(34));
initHook(new DisablePersistent(), mPrefsMap.getBoolean("system_framework_disable_persistent") && isMoreAndroidVersion(34));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.sevtinge.hyperceiler.module.hook.systemframework;

import com.hchen.hooktool.callback.IAction;
import com.hchen.hooktool.tool.ParamTool;
import com.sevtinge.hyperceiler.module.base.BaseTool;

public class DisablePersistent extends BaseTool {
private boolean isInstall = false;

@Override
public void doHook() {
hcHook.findClass("pl", "com.android.server.pm.parsing.pkg.PackageImpl")
.getMethod("isPersistent")
.hook(new IAction() {
@Override
public void after(ParamTool param) {
// String pkg = param.getField("packageName");
boolean isPersistent = param.getResult();
if (isPersistent) {
if (isInstall) {
param.setResult(false);
}
}
// logI(TAG, "pkg: " + pkg + " isPersistent: " + param.getResult());
}
})
.findClass("iph", "com.android.server.pm.InstallPackageHelper")
.getMethod("preparePackageLI", "com.android.server.pm.InstallRequest")
.hook(new IAction() {
@Override
public void before(ParamTool param) {
isInstall = true;
// logI(TAG, "start install: " + param.first());
}

@Override
public void after(ParamTool param) {
isInstall = false;
// logI(TAG, "end install: " + param.first());
}
})
;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class SystemFrameworkFragment extends SettingsPreferenceFragment {
SwitchPreference mShareUser;
SwitchPreference mDisableIntegrity;
SwitchPreference mDisableLowApiCheck;
SwitchPreference mDisablePersistent;
Preference mNetwork;

@Override
Expand All @@ -47,12 +48,14 @@ public void initPrefs() {
mShareUser = findPreference("prefs_key_system_framework_core_patch_shared_user");
mDisableIntegrity = findPreference("prefs_key_system_framework_core_patch_disable_integrity");
mDisableLowApiCheck = findPreference("prefs_key_system_framework_disable_low_api_check");
mDisablePersistent = findPreference("prefs_key_system_framework_disable_persistent");
mNetwork = findPreference("prefs_key_system_framework_network");

mDisableIntegrity.setVisible(isMoreAndroidVersion(33) && !mCreak);
mShareUser.setVisible(isMoreAndroidVersion(33)); // 暂时仅开放给 Android 13 及以上使用
mNetwork.setVisible(TelephonyManager.getDefault().isFiveGCapable());
mDisableLowApiCheck.setVisible(isMoreAndroidVersion(34));
mDisablePersistent.setVisible(isMoreAndroidVersion(34));

mDisableCreak.setOnPreferenceChangeListener((preference, o) -> {
if ((boolean) o) {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@
<string name="system_framework_volume_first_press">音量即时调整</string>
<string name="system_framework_volume_separate_control">音量独立控制</string>
<string name="system_framework_volume_disable_safe">移除高音量安全限制</string>
<string name="default_volume_safe_all">对全部情况启用</string>
<string name="default_volume_safe_headset">仅连接耳机时启用</string>
<string name="system_framework_volume_separate_slider">通知音量滑块</string>
<string name="system_framework_volume_media_steps">媒体音量阶数</string>
<string name="system_framework_volume_media_steps_desc">可能会导致音量条的滚动卡顿或蓝牙音量异常</string>
Expand Down Expand Up @@ -466,6 +468,8 @@
<string name="system_framework_core_patch_enhanced_mode_desc">可以解决一些应用内部的完整性校验,一般无需开启</string>
<string name="system_framework_disable_low_api_check">禁用低 API 校验</string>
<string name="system_framework_disable_low_api_check_desc">允许安装 TargetSDK 低于 23 的应用</string>
<string name="system_framework_disable_persistent">禁用持久检查</string>
<string name="system_framework_disable_persistent_more">允许直接更新持久 APP ,比如直接更新系统界面</string>
<!--浏览器-->
<string name="browser">浏览器</string>
<string name="browser_debug_mode">解锁开发者选项</string>
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@
<string name="system_framework_volume_first_press">Instant volume adjustment</string>
<string name="system_framework_volume_separate_control">Independent volume control</string>
<string name="system_framework_volume_disable_safe">Remove high volume safety restrictions</string>
<string name="default_volume_safe_all">Enabled for all cases</string>
<string name="default_volume_safe_headset">Enabled only when headphones are connected</string>
<string name="system_framework_volume_separate_slider">Notification volume slider</string>
<string name="system_framework_volume_media_steps">Media volume level</string>
<string name="system_framework_volume_media_steps_desc">It may cause the scrolling of the volume bar to freeze or the Bluetooth volume to be abnormal</string>
Expand Down Expand Up @@ -459,6 +461,8 @@
<string name="system_framework_core_patch_enhanced_mode_desc">Pass some validation in the application</string>
<string name="system_framework_disable_low_api_check">Disable low API check</string>
<string name="system_framework_disable_low_api_check_desc">Apps with APIs lower than 23 are allowed</string>
<string name="system_framework_disable_persistent">Disable persistent checks</string>
<string name="system_framework_disable_persistent_more">Allows you to update persistent apps directly, such as updating the system interface directly</string>
<!--Browser-->
<string name="browser">Browser</string>
<string name="browser_debug_mode">Unlock developer options</string>
Expand Down Expand Up @@ -734,7 +738,7 @@
<string name="system_ui_statusbar_clock_layout_s">Status Bar Clock</string>
<string name="system_ui_statusbar_clock_layout_b">Notification Bar Big Clock</string>
<string name="system_ui_statusbar_clock_layout_n">Notification Bar Mini Clock</string>
<string name="system_ui_statusbar_clock_editor_s">Status bar clock format</string>
<string name="system_ui_statusbar_clock_editor_s">Status bar clock format</string>
<string name="system_ui_statusbar_clock_editor_n">Notification bar mini clock format</string>
<string name="system_ui_statusbar_clock_style_f">Status bar clock arrangement</string>
<string name="system_ui_statusbar_indicator_battery_title">Power related</string>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/framework.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@
android:summary="@string/system_framework_disable_low_api_check_desc"
android:title="@string/system_framework_disable_low_api_check" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_system_framework_disable_persistent"
android:summary="@string/system_framework_disable_persistent_more"
android:title="@string/system_framework_disable_persistent" />

</PreferenceCategory>

</PreferenceScreen>
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
agp = "8.4.1"
hooktool = "v.0.8.7"
hooktool = "v.0.8.9"
kotlinAndroid = "2.0.0"
lsparanoid = "0.6.0"
#lspluginResopt = "1.6"
Expand Down

0 comments on commit ed59f12

Please sign in to comment.