Skip to content

Commit

Permalink
fix: crash & bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Feb 11, 2025
1 parent 404a8f4 commit c17d8d1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/hook/src/main/java/com/hchen/processor/HookEntrance.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
*/
float targetOS() default -1f;

/**
* 是否是 HyperOS 系统
*/
boolean isHyperOS() default false;

/**
* 是否向下兼容
* */
Expand Down
7 changes: 5 additions & 2 deletions app/hook/src/main/java/com/hchen/processor/HookProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ public class EntranceMap {
public float mTargetOS;
public boolean mDownward;
public boolean mUpward;
public boolean isHyperOS;
public EntranceMap(String targetBrand, String targetPackage, int targetSdk, float targetOS, boolean downward, boolean upward){
public EntranceMap(String targetBrand, String targetPackage, int targetSdk, float targetOS, boolean isHyperOS, boolean downward, boolean upward){
this.mTargetBrand = targetBrand;
this.mTargetPackage = targetPackage;
this.mTargetSdk = targetSdk;
this.mTargetOS = targetOS;
this.isHyperOS = isHyperOS;
this.mDownward = downward;
this.mUpward = upward;
}
Expand All @@ -118,12 +120,13 @@ public void accept(Element element) {
String targetPackage = hookEntrance.targetPackage();
int targetSdk = hookEntrance.targetSdk();
float targetOS = hookEntrance.targetOS();
boolean isHyperOS = hookEntrance.isHyperOS();
boolean downward = hookEntrance.downward();
boolean upward = hookEntrance.upward();
try {
writer.write(" ");
writer.write("dataMap.put(\"" + fullClassName + "\", new EntranceMap(\"" + targetBrand + "\", "
+ "\"" + targetPackage + "\"" + ", " + targetSdk + ", " + targetOS + "f, " + downward + ", " + upward + "));\n");
+ "\"" + targetPackage + "\"" + ", " + targetSdk + ", " + targetOS + "f, " + isHyperOS + ", " + downward + ", " + upward + "));\n");
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/hchen/appretention/HookInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void accept(String s, EntranceMap entranceMap) {
return;
if ("Xiaomi".equals(entranceMap.mTargetBrand)) {
if (entranceMap.mTargetOS != -1) {
if (DeviceTool.getHyperOSVersion() != 0f) {
if (entranceMap.isHyperOS) {
if (!DeviceTool.isHyperOSVersion(entranceMap.mTargetOS) && !entranceMap.mUpward && !entranceMap.mDownward)
return;
if (entranceMap.mUpward && !(DeviceTool.getHyperOSVersion() >= entranceMap.mTargetOS))
Expand All @@ -88,7 +88,7 @@ public void accept(String s, EntranceMap entranceMap) {
return;
if (entranceMap.mDownward && !(DeviceTool.getMiuiVersion() <= entranceMap.mTargetOS))
return;
}
} else return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*
* @author 焕晨HChen
*/
@HookEntrance(targetBrand = "Xiaomi", targetPackage = "android", targetOS = 1.0f)
@HookEntrance(targetBrand = "Xiaomi", targetPackage = "android", targetOS = 1.0f, isHyperOS = true)
public class HyperV1 extends BaseHC {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
*
* @author 焕晨HChen
*/
@HookEntrance(targetBrand = "Xiaomi", targetPackage = "android", targetOS = 2.0f)
@HookEntrance(targetBrand = "Xiaomi", targetPackage = "android", targetOS = 2.0f, isHyperOS = true)
public class HyperV2 extends BaseHC {
@Override
public void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static class KillEventLogRecord {
private static Process mLogcat;

private static void init(Context context) {
if (BuildConfig.DEBUG || Settings.System.getString(context.getContentResolver(), SETTINGS_KILL_EVENT_LOG_RECORD_ENABLE).equals(TRUE)) {
if (BuildConfig.DEBUG || TRUE.equals(Settings.System.getString(context.getContentResolver(), SETTINGS_KILL_EVENT_LOG_RECORD_ENABLE))) {
if (!isKillEventRecording)
startRecord();
else
Expand Down

0 comments on commit c17d8d1

Please sign in to comment.