Skip to content

Commit

Permalink
feat: analytics - remove guard
Browse files Browse the repository at this point in the history
from gykkuo/MIUI_NoGuard
#818
  • Loading branch information
Sevtinge committed Aug 24, 2024
1 parent 4b825ed commit 2607937
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of HyperCeiler.
*
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/

package com.sevtinge.hyperceiler.module.app;

import com.sevtinge.hyperceiler.module.base.BaseModule;
import com.sevtinge.hyperceiler.module.base.HookExpand;
import com.sevtinge.hyperceiler.module.hook.analytics.FuckMiuiUpload;

@HookExpand(pkg = "com.miui.analytics", isPad = false, tarAndroid = 33)
public class Analytics extends BaseModule {
@Override
public void handleLoadPackage() {
initHook(new FuckMiuiUpload(), mPrefsMap.getBoolean("analytics_fuck_guard"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* This file is part of HyperCeiler.
*
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/

package com.sevtinge.hyperceiler.module.hook.analytics;

import android.content.Context;

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

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;

// from https://github.com/gykkuo/MIUI_NoGuard/blob/master/app/src/main/java/cn/fyyr/noguardpls/MainHook.java
public class FuckMiuiUpload extends BaseHook {
@Override
public void init() throws NoSuchMethodException {
int needmod = 0;
Class<?> classs = null;
// com.miui.analytics.onetrack.p.u.w
try {
classs = XposedHelpers.findClass("com.miui.analytics.onetrack.p.u", lpparam.classLoader);
XposedHelpers.findAndHookMethod(classs, "w", long.class, long.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// XposedBridge.log("com.miui.analytics:执行拦截! --- 1");
param.setResult(null);
}
});

needmod++;
} catch (XposedHelpers.ClassNotFoundError | NoSuchMethodError err) {
logD(TAG, lpparam.packageName, err.toString());
}
// com.miui.analytics.c.f.k.y
try {
classs = XposedHelpers.findClass("com.miui.analytics.c.f.k", lpparam.classLoader);
XposedHelpers.findAndHookMethod(classs, "y", long.class, long.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// XposedBridge.log("com.miui.analytics:执行拦截! --- 2");
param.setResult(null);
}
});
needmod++;
} catch (XposedHelpers.ClassNotFoundError | NoSuchMethodError err) {
logD(TAG, lpparam.packageName, err.toString());
}
try {
classs = XposedHelpers.findClass("com.miui.analytics.onetrack.q.c", lpparam.classLoader);
// com.miui.analytics.onetrack.q.c.a
try {
XposedHelpers.findAndHookMethod(classs, "a", Context.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// XposedBridge.log("com.miui.analytics:执行拦截! --- 3");
param.setResult(0);
}
});
needmod++;
} catch (XposedHelpers.ClassNotFoundError | NoSuchMethodError err) {
logD(TAG, lpparam.packageName, err.toString());
}
// com.miui.analytics.onetrack.q.c.b
try {
XposedHelpers.findAndHookMethod(classs, "b", Context.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// XposedBridge.log("com.miui.analytics:执行拦截! --- 4");
param.setResult("NONE");
}
});
needmod++;
} catch (XposedHelpers.ClassNotFoundError | NoSuchMethodError err) {
logD(TAG, lpparam.packageName, err.toString());
}
// com.miui.analytics.onetrack.q.c.c
try {
XposedHelpers.findAndHookMethod(classs, "c", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// XposedBridge.log("com.miui.analytics:执行拦截! --- 5");
param.setResult(false);
}
});
needmod++;
} catch (XposedHelpers.ClassNotFoundError | NoSuchMethodError err) {
logD(TAG, lpparam.packageName, err.toString());
}
} catch (XposedHelpers.ClassNotFoundError | NoSuchMethodError err) {
logD(TAG, lpparam.packageName, err.toString());
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This file is part of HyperCeiler.
*
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/

package com.sevtinge.hyperceiler.ui.fragment;

import android.view.View;

import com.sevtinge.hyperceiler.R;
import com.sevtinge.hyperceiler.ui.base.BaseSettingsActivity;
import com.sevtinge.hyperceiler.ui.fragment.base.SettingsPreferenceFragment;

public class AnalyticsFragment extends SettingsPreferenceFragment {
@Override
public int getContentResId() {
return R.xml.analytics;
}

@Override
public View.OnClickListener addRestartListener() {
return view -> ((BaseSettingsActivity)getActivity()).showRestartDialog(
getResources().getString(R.string.analytics),
"com.miui.analytics"
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ public static void getAllMods(Context context, boolean force) {
"com.sevtinge.hyperceiler.ui.fragment.SystemSettingsFragment");

// 其他杂项
parsePrefXml(context, R.xml.analytics,
"com.sevtinge.hyperceiler.ui.fragment.AnalyticsFragment");

parsePrefXml(context, R.xml.browser,
"com.sevtinge.hyperceiler.ui.fragment.BrowserFragment");

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,9 @@
<string name="weather_card_display_type_title">卡片显示样式</string>
<string name="weather_card_display_type_title_2">浅色模式</string>
<string name="weather_card_display_type_title_3">深色模式</string>
<!--Analytics-->
<string name="analytics">Analytics</string>
<string name="analytics_fuck_guard">禁止收集遥测数据</string>
<!--小爱翻译-->
<string name="aiasst">小爱翻译</string>
<string name="aiasst_ai_captions">强制启用实时字幕</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<item>com.duokan.phone.remotecontroller</item> <!--万能遥控-->
<item>com.lbe.security.miui</item> <!--权限管理服务-->
<item>com.milink.service</item> <!--投屏-->
<item>com.miui.analytics</item> <!--Analytics-->
<item>com.miui.aod</item> <!--万象息屏-->
<item>com.miui.backup</item> <!--备份-->
<!--<item>com.miui.cleanmaster</item>--> <!--垃圾清理-->
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,9 @@
<string name="weather_card_display_type_title">Card display type</string>
<string name="weather_card_display_type_title_2">Light mode</string>
<string name="weather_card_display_type_title_3">Dark mode</string>
<!--Analytics-->
<string name="analytics">Analytics</string>
<string name="analytics_fuck_guard">Remove guard</string>
<!--AI Translate-->
<string name="aiasst">Mi AI Translate</string>
<string name="aiasst_ai_captions">Force enabled AI captions</string>
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/res/xml/analytics.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ This file is part of HyperCeiler.
~
~ HyperCeiler is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
~
~ Copyright (C) 2023-2024 HyperCeiler Contributions
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:myLocation="@string/analytics">
<PreferenceCategory>
<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_analytics_fuck_guard"
android:title="@string/analytics_fuck_guard" />
</PreferenceCategory>

</PreferenceScreen>
7 changes: 7 additions & 0 deletions app/src/main/res/xml/prefs_about_use.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@
android:action="android.intent.action.VIEW"
android:data="https://github.com/RC1844/MIUI_IME_Unlock" />
</Preference>
<Preference
android:summary="gykkuo | GPL-3.0"
android:title="MIUI NoGuard">
<intent
android:action="android.intent.action.VIEW"
android:data="https://github.com/gykkuo/MIUI_NoGuard" />
</Preference>
<Preference
android:summary="chsbuffer | No License"
android:title="MIUIQOL">
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/prefs_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@
android:summary="com.milink.service"
android:title="@string/milink" />

<com.sevtinge.hyperceiler.prefs.PreferenceHeader
android:fragment="com.sevtinge.hyperceiler.ui.fragment.AnalyticsFragment"
android:icon="@drawable/ic_default_icon"
android:key="prefs_key_analytics"
android:summary="com.miui.analytics"
android:title="@string/analytics" />

<com.sevtinge.hyperceiler.prefs.PreferenceHeader
android:fragment="com.sevtinge.hyperceiler.ui.fragment.AodFragment"
android:icon="@drawable/ic_aod"
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/xml/prefs_set_homepage_entrance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@
android:summary="com.milink.service"
android:title="@string/milink" />

<SwitchPreference
android:defaultValue="true"
android:icon="@drawable/ic_default_icon"
android:key="prefs_key_analytics_state"
android:layout="@layout/preference_header"
android:summary="com.miui.analytics"
android:title="@string/analytics" />

<SwitchPreference
android:defaultValue="true"
android:icon="@drawable/ic_aod"
Expand Down

0 comments on commit 2607937

Please sign in to comment.