Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
新增:安全模式 (#506)
Browse files Browse the repository at this point in the history
* 推送安全模式测试

* test

* 是船新的安全模式!

* 更改计数

* Update MainActivity.java

* 新增 系统界面-锁屏-允许使用三方应用锁屏时使用人脸及指纹识别

* Update AllowThirdLockScreenUseFace.java

* Update SystemUI.java

* Update AllowThirdLockScreenUseFace.java

* 同步

* test

* 同步

* test

* Update MultiActionSettings.java

* 优化AlertDialog布局

* 安全模式线同步上游

* 更新Shell执行

* 同步上游

* 完善安全模式核心逻辑

* 完善安全模式核心逻辑

* update theme

* 完善安全模式

* 同步上游

* 更新检查的作用域

---------

Co-authored-by: 绀漓丨Sevtinge <[email protected]>
Co-authored-by: MoralNorm <[email protected]>
  • Loading branch information
3 people authored Mar 31, 2024
1 parent 898ecd6 commit 8ec6705
Show file tree
Hide file tree
Showing 18 changed files with 896 additions and 47 deletions.
34 changes: 33 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,36 @@
android:name=".ui.MainActivity"
android:exported="true"
android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity">
tools:ignore="DiscouragedApi,LockedOrientationActivity"
android:theme="@style/Theme.HyperCeiler.SystemBarBackgrounds">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" />
</intent-filter>
</activity>

<activity
android:name=".safe.CrashReportActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:excludeFromRecents="true"
android:exported="true"
android:finishOnTaskLaunch="true"
android:launchMode="singleTask"
android:theme="@style/Theme.HyperCeiler.Translucent.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.Crash" />
<category android:name="android.intent.category.CrashDailog" />
</intent-filter>
</activity>
<!--<activity
android:name=".ui.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" />
</intent-filter>
</activity>-->

<activity-alias
android:name=".ui.LauncherActivity"
android:exported="true"
Expand Down Expand Up @@ -135,6 +158,15 @@
<meta-data
android:name="xposedscope"
android:resource="@array/xposed_scope" />

<service
android:name="com.sevtinge.hyperceiler.safe.CrashService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.sevtinge.hyperceiler.crash.Service" />
</intent-filter>
</service>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.sevtinge.hyperceiler.module.app;

import com.sevtinge.hyperceiler.module.base.BaseModule;
import com.sevtinge.hyperceiler.module.hook.demo.CrashDemo;
import com.sevtinge.hyperceiler.module.hook.demo.ToastTest;

public class Demo extends BaseModule {
@Override
public void handleLoadPackage() {
initHook(new ToastTest(), true);
initHook(new CrashDemo(), true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,32 @@
import com.sevtinge.hyperceiler.XposedInit;
import com.sevtinge.hyperceiler.module.base.dexkit.DexKit;
import com.sevtinge.hyperceiler.module.base.dexkit.InitDexKit;
import com.sevtinge.hyperceiler.safe.CrashData;
import com.sevtinge.hyperceiler.utils.ContextUtils;
import com.sevtinge.hyperceiler.utils.PropUtils;
import com.sevtinge.hyperceiler.utils.api.ProjectApi;
import com.sevtinge.hyperceiler.utils.log.XposedLogUtils;
import com.sevtinge.hyperceiler.utils.prefs.PrefsMap;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public abstract class BaseModule implements IXposedHook {

public LoadPackageParam mLoadPackageParam = null;
public String TAG = getClass().getSimpleName();
public final PrefsMap<String, Object> mPrefsMap = XposedInit.mPrefsMap;
private static HashMap<String, String> swappedMap = CrashData.swappedData();

public void init(LoadPackageParam lpparam) {
if (swappedMap.isEmpty()) swappedMap = CrashData.swappedData();
if (needIntercept(lpparam.packageName)) {
XposedLogUtils.logI(TAG, "进入安全模式: " + lpparam.packageName);
return;
}
EzXHelper.initHandleLoadPackage(lpparam);
EzXHelper.setLogTag(TAG);
EzXHelper.setToastTag(TAG);
Expand Down Expand Up @@ -73,6 +85,26 @@ public void init(LoadPackageParam lpparam) {
}
}

private boolean needIntercept(String pkg) {
ArrayList<String> report = getReportCrashProp();
for (String s : report) {
String mPkg = swappedMap.get(s);
if (mPkg != null) {
return mPkg.equals(pkg);
}
}
return false;
}

private ArrayList<String> getReportCrashProp() {
String data = PropUtils.getProp("persist.hyperceiler.crash.report", "");
if (data.isEmpty()) {
return new ArrayList<>();
}
String[] sp = data.split(",");
return new ArrayList<>(Arrays.asList(sp));
}

@Override
public void initZygote() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package com.sevtinge.hyperceiler.module.base;

import static com.sevtinge.hyperceiler.callback.ITAG.TAG;
import static com.sevtinge.hyperceiler.utils.Helpers.getPackageVersionCode;
import static com.sevtinge.hyperceiler.utils.Helpers.getPackageVersionName;
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.getAndroidVersion;
Expand All @@ -26,6 +27,7 @@
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreAndroidVersion;
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreHyperOSVersion;
import static com.sevtinge.hyperceiler.utils.log.LogManager.logLevelDesc;
import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logE;
import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logI;

import androidx.annotation.CallSuper;
Expand Down Expand Up @@ -82,8 +84,8 @@
import com.sevtinge.hyperceiler.module.app.VoiceAssist;
import com.sevtinge.hyperceiler.module.app.Weather;
import com.sevtinge.hyperceiler.module.base.tool.ResourcesTool;
import com.sevtinge.hyperceiler.safe.CrashHook;
import com.sevtinge.hyperceiler.utils.api.ProjectApi;
import com.sevtinge.hyperceiler.utils.log.AndroidLogUtils;
import com.sevtinge.hyperceiler.utils.log.XposedLogUtils;
import com.sevtinge.hyperceiler.utils.prefs.PrefsMap;
import com.sevtinge.hyperceiler.utils.prefs.PrefsUtils;
Expand Down Expand Up @@ -190,7 +192,7 @@ public void setXSharedPrefs() {
mPrefsMap.putAll(allPrefs);
}
} catch (Throwable t) {
AndroidLogUtils.logD("setXSharedPrefs", t);
XposedLogUtils.logE("setXSharedPrefs", t);
}
}
}
Expand All @@ -208,12 +210,12 @@ public void init(LoadPackageParam lpparam) {
mSystemFramework.init(lpparam);
mVariousSystemApps.init(lpparam);
}
// try {
// new CrashHook(lpparam);
// logI(TAG.TAG, "Success Hook Crash");
// } catch (Exception e) {
// logE(TAG.TAG, "Hook Crash E: " + e);
// }
try {
new CrashHook(lpparam);
logI(TAG, "Success Hook Crash");
} catch (Exception e) {
logE(TAG, "Hook Crash E: " + e);
}
}
case "com.android.systemui" -> {
if (isSystemUIModuleEnable() && isMoreAndroidVersion(33)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.sevtinge.hyperceiler.module.hook.demo;

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

import de.robv.android.xposed.XposedHelpers;

public class CrashDemo extends BaseHook {
@Override
public void init() throws NoSuchMethodException {
XposedHelpers.findAndHookMethod("com.hchen.demo.MainActivity", lpparam.classLoader,
"crash", int.class, new MethodHook() {
@Override
protected void before(MethodHookParam param) throws Throwable {
int o = (int) param.args[0];
param.args[0] = 0;
logE(TAG, "int: " + o);
}
}
);
}
}
Loading

0 comments on commit 8ec6705

Please sign in to comment.