Skip to content

Commit

Permalink
新功能开发
Browse files Browse the repository at this point in the history
- PC端修复bug #1
- 预装应用卸载
	- 修正:卸载多个应用时报“超时”的bug
	- 修正:单独卸载系统应用时流程卡死的bug
	- 新增:无`USB调试`权限时,自动获取授权的功能
- 关闭各应用广告
	- 增强:小米帐号 按需显示
	- 新增:系统安全 按需显示
	- 新增:广告服务 按需显示
- 应用管家
	- 新增:自启动管理
	- 新增:应用卸载
	- 删除:应用管理
  • Loading branch information
gucong3000 committed Sep 25, 2022
1 parent b24b812 commit bb9f80d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 35 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{cmd,bat}]
[**/*.{cmd,bat}]
charset = gbk
end_of_line = crlf
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,14 @@ MIUI广告清理工具
- PC端修复bug #1
- 预装应用卸载
- 修正:卸载多个应用时报“超时”的bug
- 修正:单独卸载系统应用时流程卡死的bug
- 新增:无`USB调试`权限时,自动获取授权的功能
- 关闭各应用广告
- 增强:小米帐号 按需显示
- 新增:系统安全 按需显示
- 新增:广告服务 按需显示
- 增强:小米帐号
- 新增:系统安全
- 新增:广告服务
- 新增:小米帐号、系统安全、广告服务三个选项按需显示功能、相关广告已关,或者已通过“修改系统”权限自动关闭后,不显示
-
- 应用管家
- 新增:自启动管理
- 新增:应用卸载
Expand Down
13 changes: 10 additions & 3 deletions src/miui_cleaner_app/offAppAd.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ const cleanerList = [
},
{
// 音乐
// v3.51.1.1 下载 https://xiaoheiya.lanzoum.com/iVMeWnhkh5c
packageName: "com.miui.player",
activity: ".phone.ui.MusicSettings",
// start: function () {
Expand Down Expand Up @@ -752,7 +753,13 @@ function offAppAd () {
"upload_debug_log_pref",
].forEach(key => Settings.Secure.putInt(resolver, key, 0));
} catch (ex) {
console.log("adb shell pm grant com.github.gucong3000.miui.cleaner android.permission.WRITE_SECURE_SETTINGS");
console.error(
[
"调用“修改系统”权限失败,未能直接关闭“网页链接调用服务”、“用户体验改进计划”、自动发送诊断数据、“个性化广告推荐”。赋权方法:",
"adb shell pm grant com.github.gucong3000.miui.cleaner android.permission.WRITE_SECURE_SETTINGS",
"已提供备选方案:通过自动操作设置页面关闭相关功能的选项",
].join("\n"),
);
}

const menuItemList = cleanerList.filter((appInfo) => {
Expand All @@ -763,7 +770,7 @@ function offAppAd () {
}
}
if (appInfo.test) {
return appInfo.test();
return appInfo.test(appInfo);
}
return true;
});
Expand All @@ -785,7 +792,7 @@ function offAppAd () {
}

tasks.forEach(task => {
if (task.test && !task.test()) {
if (task.test && !task.test(task)) {
return;
}
task.fn ? task.fn() : startTask(task);
Expand Down
45 changes: 28 additions & 17 deletions src/miui_cleaner_app/sysAppRm.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,35 @@ const packageNameList = [
"com.xiaomi.aiasst.service",
];

let appList;
// 卸载“纯净模式”
function getInstaller (appList) {
const packageName = "com.miui.packageinstaller";
const packageInfo = context.getPackageManager().getPackageInfo(packageName, 0);
if (!packageInfo || packageInfo.versionCode < 400) {
// 版本号小于400,则不含“纯净模式”
return;
}
const fileName = "MiuiPackageInstaller.apk";
const srcPath = "res/" + fileName;
const copyPath = "/sdcard/Download/" + fileName;
const installPath = "/data/local/tmp/" + fileName;
const appName = app.getAppName(packageInfo.packageName);
files.copy(srcPath, copyPath);
appList.push({
packageName,
name: "纯净模式",
cmd: [
`mv ${copyPath} ${installPath}`,
"pm install -d -g " + installPath,
"rm -rf " + installPath,
].join("\n"),
});
console.log(`发现${appName}(${packageName}),版本号${packageInfo.versionCode},已释放版本号为380的降级安装包到路径:${copyPath}`);
}

const whitelist = /^com\.(miui\.(voiceassist|personalassistant)|android\.(quicksearchbox|chrome))$/;
function getAppList () {
let appList;
appList = packageNameList.map(packageName => ({
appName: app.getAppName(packageName),
checked: whitelist.test(packageName),
Expand All @@ -164,22 +190,7 @@ function getAppList () {
appInfo.appName = app.getAppName(appInfo.packageName);
return appInfo.appName;
});
const fileName = "MiuiPackageInstaller.apk";
const srcPath = "res/" + fileName;
const copyPath = "/sdcard/Download/" + fileName;
const installPath = "/data/local/tmp/" + fileName;
files.copy(srcPath, copyPath);
appList.push({
packageName: "com.miui.packageinstaller",
name: "纯净模式",
cmd: [
`mv ${copyPath} ${installPath}`,
"pm install -d -g " + installPath,
"rm -rf " + installPath,
].join("\n"),
});
console.log(files.isFile("res/MiuiPackageInstaller.apk"));
console.log(files.exists("res/MiuiPackageInstaller.apk"));
getInstaller(appList);
return appList;
}

Expand Down
22 changes: 11 additions & 11 deletions src/miui_cleaner_cmd/main.cmd
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
@echo off
title MiuiCleaner - MIUI广告清理工具
title MiuiCleaner - MIUI�����������

:start
adb shell pm list packages>"%temp%\adb_list_packages.tmp" 2>&1
if %errorlevel%==1 (
findstr /c:"no devices" "%temp%\adb_list_packages.tmp">nul 2>nul && (
echo · 请确保已用数据线连接手机和电脑
echo · 请确保小米手机助手可正常连接手机
echo · 请确保已请确保USB调试模式已打开
echo �� ��ȷ�����������������ֻ��͵���
echo �� ��ȷ��С���ֻ����ֿ����������ֻ�
echo �� ��ȷ������ȷ��USB����ģʽ�Ѵ�
) || findstr /c:"unauthorized" "%temp%\adb_list_packages.tmp">nul 2>nul && (
echo · 请在手机弹出授权提示时点击“确定”
echo �� �����ֻ�������Ȩ��ʾʱ�����ȷ����
) || (
type "%temp%\adb_list_packages.tmp"
)
echo.
echo 请在排除故障后按任意键重试
echo �����ų����Ϻ����������
pause>nul 2>nul
goto:start
) else if %errorlevel% geq 1 (
echo 错误:请将本程序移动到小米手机助手安装目录内再运行,按任意键前往小米手机助手官网
echo �����뽫�������ƶ���С���ֻ����ְ�װĿ¼�������У��������ǰ��С���ֻ����ֹ���
pause>nul 2>nul
start http://zhushou.xiaomi.com/
goto:eof
)

call:pkg_exist "com.github.gucong3000.miui.cleaner" || (
if exist "MiuiCleaner.apk" (
echo 正在手机上安装 MiuiCleaner.apk, 请打开“设置 → 更多设置 → 开发者选项 → USB安装”
echo �����ֻ��ϰ�װ MiuiCleaner.apk, ��򿪡����� �� �������� �� ������ѡ�� �� USB��װ��
call:apk_install
) else (
echo 未在手机上找到“MiuiCleaner”,请将“MiuiCleaner.apk”拷贝至"%CD%"文件夹,或直接安装在手机后,按任意键重试
echo δ���ֻ����ҵ���MiuiCleaner�����뽫��MiuiCleaner.apk��������"%CD%"�ļ��У���ֱ�Ӱ�װ���ֻ��󣬰����������
pause>nul 2>nul
goto:start
)
Expand All @@ -46,8 +46,8 @@ adb shell pm grant com.github.gucong3000.miui.cleaner android.permission.WRITE_S
adb shell pm grant com.github.gucong3000.miui.cleaner android.permission.SYSTEM_ALERT_WINDOW>nul 2>nul
adb shell am start -n com.github.gucong3000.miui.cleaner/com.stardust.auojs.inrt.SplashActivity>nul 2>nul

echo 请在手机上打开“MiuiCleaner”,并在“无障碍”设置页面弹出时,打开“已下载的服务”,找到“MiuiCleaner”,开启它提供的的无障碍服务
echo 正等候手机端发出指令...
echo �����ֻ��ϴ򿪡�MiuiCleaner�������ڡ����ϰ�������ҳ�浯��ʱ���򿪡������صķ��񡱣��ҵ���MiuiCleaner�����������ṩ�ĵ����ϰ�����
echo ���Ⱥ��ֻ��˷���ָ��...

goto:adb_server

Expand Down

0 comments on commit bb9f80d

Please sign in to comment.