Skip to content

Commit

Permalink
优化: 自动安全模式减少生效范围
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Apr 21, 2024
1 parent d84130b commit 2cf773c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</activity>

<activity
android:name=".safe.CrashReportActivity"
android:name=".safe.CrashActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:excludeFromRecents="true"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class BaseModule implements IXposedHook {

public void init(LoadPackageParam lpparam) {
if (swappedMap.isEmpty()) swappedMap = CrashData.swappedData();
if (CrashData.needIntercept(lpparam.packageName)) {
if (CrashData.toPkgList(lpparam.packageName)) {
XposedLogUtils.logI(TAG, "进入安全模式: " + lpparam.packageName);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void init(LoadPackageParam lpparam) {
if (hookDone) {
mVariousSystemApps.init(lpparam);
if ("android".equals(packageName)) {
XposedBridge.log("[HyperCeiler][I]: Log level is " + logLevelDesc());
try {
new CrashHook(lpparam);
logI(TAG, "Success Hook Crash");
Expand Down Expand Up @@ -187,10 +188,6 @@ private boolean invokeHookInit(LoadPackageParam lpparam) {
int android = hookExpand.tarAndroid();
boolean skip = hookExpand.skip();
if (skip) continue;
if (mPkgName.equals("android")) {
XposedBridge.log("[HyperCeiler][I]: Log level is " + logLevelDesc());
continue;
}
if (mPkgName.equals(mPkg)) {
// 需要限制安卓版本和设备取消这些注释,并删除下面的invoke方法。
// if (!isAndroidVersion(android)) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import moralnorm.appcompat.app.AppCompatActivity;

public class CrashReportActivity extends AppCompatActivity {
public class CrashActivity extends AppCompatActivity {

TextView mMessageTv;
TextView mCrashRecordTv;
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/java/com/sevtinge/hyperceiler/safe/CrashData.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ public class CrashData {
*/
public static HashMap<String, String> scopeData() {
if (scopeMap.isEmpty()) {
scopeMap.put("android", "android");
scopeMap.put("com.android.systemui", "systemui");
scopeMap.put("com.android.settings", "settings");
scopeMap.put("com.miui.home", "home");
scopeMap.put("com.miui.securitycenter", "center");
scopeMap.put("com.hchen.demo", "demo");
/*scopeMap.put("android", "android");
scopeMap.put("com.android.browser", "browser");
scopeMap.put("com.android.camera", "camera");
scopeMap.put("com.android.calendar", "calendar");
Expand Down Expand Up @@ -78,7 +83,7 @@ public static HashMap<String, String> scopeData() {
scopeMap.put("com.xiaomi.mtb", "mtb");
scopeMap.put("com.xiaomi.scanner", "scanner");
scopeMap.put("com.xiaomi.trustservice", "trust");
scopeMap.put("com.hchen.demo", "demo");
scopeMap.put("com.hchen.demo", "demo");*/
return scopeMap;
}
return scopeMap;
Expand All @@ -99,7 +104,7 @@ public static HashMap<String, String> swappedData() {
return swappedMap;
}

public static boolean needIntercept(String pkg) {
public static boolean toPkgList(String pkg) {
ArrayList<String> report = getReportCrashProp();
for (String s : report) {
String mPkg = swappedData().get(s);
Expand All @@ -110,7 +115,7 @@ public static boolean needIntercept(String pkg) {
return false;
}

public static ArrayList<String> needIntercept() {
public static ArrayList<String> toPkgList() {
ArrayList<String> appCrash = new ArrayList<>();
ArrayList<String> report = getReportCrashProp();
for (String s : report) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {

@NonNull
private Intent getIntent(String abbr) {
Intent intent1 = new Intent(this, CrashReportActivity.class);
Intent intent1 = new Intent(this, CrashActivity.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent1.putExtra("key_longMsg", longMsg);
intent1.putExtra("key_stackTrace", stackTrace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void onCreate(Bundle savedInstanceState) {
ShellInit.init(this);
PropUtils.setProp("persist.hyperceiler.log.level",
(ProjectApi.isRelease() ? def : ProjectApi.isCanary() ? (def == 0 ? 3 : 4) : def));
appCrash = CrashData.needIntercept();
appCrash = CrashData.toPkgList();
handler.postDelayed(() -> {
if (haveCrashReport()) {
new AlertDialog.Builder(MainActivity.this)
Expand Down

0 comments on commit 2cf773c

Please sign in to comment.