Skip to content

Commit

Permalink
opt: delete InitPackageResources (fix: some apps crash, like global h…
Browse files Browse the repository at this point in the history
…ome)
  • Loading branch information
Sevtinge committed Mar 31, 2024
1 parent 8c30b50 commit afc8cc5
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 49 deletions.
28 changes: 1 addition & 27 deletions app/src/main/java/com/sevtinge/hyperceiler/XposedInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class XposedInit extends BaseXposedInit implements IXposedHookInitPackageResources, IXposedHookZygoteInit, IXposedHookLoadPackage {
public class XposedInit extends BaseXposedInit implements IXposedHookZygoteInit, IXposedHookLoadPackage {
private final String TAG = "HyperCeiler";

@Override
Expand Down Expand Up @@ -72,30 +72,4 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th
init(lpparam);
new SystemFrameworkForCorePatch().handleLoadPackage(lpparam);
}

@Override
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable {
switch (resparam.packageName) {
case "com.miui.tsmclient":
if (mPrefsMap.getBoolean("tsmclient_auto_nfc")) {
AutoNfc.INSTANCE.initResource(resparam);
}
break;

case "com.miui.home":
if (mPrefsMap.getBoolean("home_other_icon_monet_color")) {
EnableIconMonetColor.INSTANCE.initResource(resparam);
}
if (mPrefsMap.getBoolean("home_other_allow_share_apk")) {
new AllowShareApk().initResource(resparam);
}
break;

case "com.miui.securitycenter":
if (mPrefsMap.getBoolean("security_center_sidebar_line_color")) {
SidebarLineCustom.INSTANCE.initResource(resparam);
}
break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
import com.sevtinge.hyperceiler.module.hook.home.title.DisableHideFile;
import com.sevtinge.hyperceiler.module.hook.home.title.DisableHideTheme;
import com.sevtinge.hyperceiler.module.hook.home.title.DownloadAnimation;
import com.sevtinge.hyperceiler.module.hook.home.title.EnableIconMonetColor;
import com.sevtinge.hyperceiler.module.hook.home.title.EnableIconMonoChrome;
import com.sevtinge.hyperceiler.module.hook.home.title.FakeNonDefaultIcon;
import com.sevtinge.hyperceiler.module.hook.home.title.FixAnimation;
Expand Down Expand Up @@ -300,6 +301,10 @@ public void handleLoadPackage() {
initHook(EnableMoreSetting.INSTANCE, mMoreSetting);
initHook(EnableHideGestureLine.INSTANCE, mMoreSetting);
}

//reshook
initHook(EnableIconMonetColor.INSTANCE, mPrefsMap.getBoolean("home_other_icon_monet_color"));
initHook(new AllowShareApk(), mPrefsMap.getBoolean("home_other_allow_share_apk"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,8 @@ public void handleLoadPackage() {

// initHook(new EnableGameSpeed(), mPrefsMap.getBoolean("security_center_game_speed"));

//reshook
initHook(SidebarLineCustom.INSTANCE, mPrefsMap.getBoolean("security_center_sidebar_line_color"));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@

import android.content.Context;

import com.sevtinge.hyperceiler.R;
import com.sevtinge.hyperceiler.module.base.BaseHook;

import de.robv.android.xposed.callbacks.XC_InitPackageResources;

public class AllowShareApk extends BaseHook{
@Override
public void init() throws NoSuchMethodException {
Expand All @@ -51,13 +48,4 @@ protected void before(MethodHookParam param) {
//mResHook.setResReplacement("com.miui.home", "XML", "file_paths", R.xml.hook_home_file_paths);

}

public void initResource(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable {
try {
resparam.res.setReplacement("com.miui.home", "xml", "file_paths", R.xml.hook_home_file_paths);
//resparam.res.setReplacement("com.miui.home", "xml", "launcher_settings", R.xml.hook_home_launcher_settings);
} catch (Exception e) {
logE(String.valueOf(e));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,29 @@ package com.sevtinge.hyperceiler.module.hook.home.title

import android.annotation.SuppressLint
import android.content.res.Resources
import android.graphics.*
import com.sevtinge.hyperceiler.module.base.BaseHook
import com.sevtinge.hyperceiler.module.base.BaseXposedInit
import de.robv.android.xposed.callbacks.XC_InitPackageResources

object EnableIconMonetColor : BaseHook() {

override fun init() {}

@SuppressLint("DiscouragedApi")
override fun init() {
val monet = "system_accent1_100"
val monoColorId = Resources.getSystem().getIdentifier(monet, "color", "android")
var monoColor = Resources.getSystem().getColor(monoColorId, null)
if (BaseXposedInit.mPrefsMap.getBoolean("home_other_use_edit_color")) {
monoColor = mPrefsMap.getInt("home_other_your_color_qwq", -1)
}
mResHook.setObjectReplacement(
"com.miui.home",
"color",
"monochrome_default",
Color.valueOf(monoColor)
)
}
/*
@SuppressLint("DiscouragedApi")
fun initResource(resParam: XC_InitPackageResources.InitPackageResourcesParam) {
val monet = "system_accent1_100"
Expand All @@ -50,5 +65,5 @@ object EnableIconMonetColor : BaseHook() {
// ColorEntries.toString(),
// "Monet"
// )
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,40 @@ import de.robv.android.xposed.callbacks.XC_InitPackageResources

object SidebarLineCustom : BaseHook() {

override fun init() {}

override fun init() {
val mSidebarLineColorDefault =
mPrefsMap.getInt("security_center_sidebar_line_color_default", -1294740525)
val mSidebarLineColorDark =
mPrefsMap.getInt("security_center_sidebar_line_color_dark", -6842473)
val mSidebarLineColorLight =
mPrefsMap.getInt("security_center_sidebar_line_color_light", -872415232)
logI(
TAG,
"com.miui.securitycenter",
"mSidebarLineColorDefault is $mSidebarLineColorDefault"
)
logI(TAG, "com.miui.securitycenter", "mSidebarLineColorDark is $mSidebarLineColorDark")
logI(TAG, "com.miui.securitycenter", "mSidebarLineColorLight is $mSidebarLineColorLight")
mResHook.setResReplacement(
"com.miui.securitycenter",
"color",
"sidebar_line_color",
mSidebarLineColorDefault
)
mResHook.setResReplacement(
"com.miui.securitycenter",
"color",
"sidebar_line_color_dark",
mSidebarLineColorLight
)
mResHook.setResReplacement(
"com.miui.securitycenter",
"color",
"sidebar_line_color_light",
mSidebarLineColorDark
)
}
/*
fun initResource(resParam: XC_InitPackageResources.InitPackageResourcesParam) {
val mSidebarLineColorDefault =
mPrefsMap.getInt("security_center_sidebar_line_color_default", -1294740525)
Expand Down Expand Up @@ -58,7 +90,7 @@ object SidebarLineCustom : BaseHook() {
"sidebar_line_color_light",
mSidebarLineColorDark
)
}
}*/


}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public void init() throws NoSuchMethodException {
int mNavigationHandleDarkColor =
mPrefsMap.getInt("system_ui_navigation_handle_custom_color_dark", -1);
mResHook.setObjectReplacement("com.android.systemui", "color",
"navigation_bar_home_handle_dark_color", mNavigationHandleDarkColor);
"navigation_bar_home_handle_dark_color", mNavigationHandleLightColor);
mResHook.setObjectReplacement("com.android.systemui", "color",
"navigation_bar_home_handle_light_color", mNavigationHandleLightColor);
"navigation_bar_home_handle_light_color", mNavigationHandleDarkColor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,20 @@ object AutoNfc : BaseHook() {
}
}
}
mResHook.setResReplacement(
"com.miui.tsmclient",
"string",
"nfc_off_hint",
R.string.tsmclient_nfc_turning_on
)
mResHook.setResReplacement(
"com.miui.tsmclient",
"string",
"immediately_open",
R.string.tsmclient_nfc_turn_on_manually
)
}

/*
fun initResource(resparam: XC_InitPackageResources.InitPackageResourcesParam) {
val moduleRes = XModuleResources.createInstance(mModulePath, resparam.res)
resparam.res.setReplacement(
Expand All @@ -88,7 +100,7 @@ object AutoNfc : BaseHook() {
"immediately_open",
moduleRes.fwd(R.string.tsmclient_nfc_turn_on_manually)
)
}
}*/

private suspend fun waitNFCEnable(context: Context, nfcAdapter: NfcAdapter) {
repeat(15) {
Expand Down

0 comments on commit afc8cc5

Please sign in to comment.