#!/system/bin/sh
MODDIR=${0%/*}
# 开机执行

sleep 5

am kill logd
killall -9 logd

am kill logd.rc
killall -9 logd.rc

#开机释放缓存（尝试清理）（来自酷安@风雪如花剑如霜 ）
sleep 10
echo 3 > /proc/sys/vm/drop_caches
echo 1 > /proc/sys/vm/compact_memory

#利用fstrim对设备读写进行优化（来自酷安@风雪如花剑如霜）
sleep 30
if
echo 'fstrim /system'
/sbin/.magisk/busybox/fstrim /system
then 
echo "完成"
fi

if
echo 'fstrim /data'
/sbin/.magisk/busybox/fstrim /data
then
echo "完成"
fi

if
echo 'fstrim /cache'
/sbin/.magisk/busybox/fstrim /cache
then 
echo "完成"
echo '命令已执行'
fi

#everything编译
cmd package compile -m everything  -f com.miui.home
cmd package compile -m everything  -f com.android.systemui


#禁用耗电
pm disable com.tencent.mobileqq/com.tencent.proxyinner.plugin.loader.PluginToolProcessService
pm disable com.tencent.mobileqq/com.tencent.av.service.AVServiceForQQ
pm disable com.tencent.mobileqq/com.tencent.av.service.UtilsServiceForAV
pm disable com.tencent.mobileqq/cooperation.qzone.QzonePluginProxyService
pm disable com.tencent.mobileqq/cooperation.qzone.video.QzoneVideoPluginProxyService
pm disable com.tencent.mobileqq/cooperation.qzone.remote.logic.QzoneWebPluginProxyService
pm disable com.tencent.mobileqq/cooperation.qzone.QzonePluginPublishQueueProxyService
pm disable com.tencent.mobileqq/cooperation.qzone.QzonePictureViewerProxyService
pm disable com.tencent.mobileqq/com.tencent.mobileqq.music.QQPlayerService
pm disable com.tencent.mobileqq/cooperation.qwallet.plugin.QWalletPluginProxyService
pm disable com.tencent.mobileqq/cooperation.groupvideo.GVideoProxyService
pm disable com.tencent.mobileqq/cooperation.groupvideo.GVideoSmallScreenProxyService
pm disable com.tencent.mobileqq/cooperation.groupvideo.GVideoProxyUtilService
pm disable com.tencent.mobileqq/com.tencent.mobileqq.mini.app.InternalAppBrandTaskPreloadReceiver
pm disable com.tencent.mobileqq/com.tencent.mobileqq.mini.app.AppBrandTaskPreloadReceiver
pm disable com.tencent.mobileqq/com.tencent.mobileqq.mini.app.AppBrandTaskPreloadReceiver1
pm disable com.tencent.mobileqq/com.tencent.mobileqq.mini.app.AppBrandTaskPreloadReceiver2
pm disable com.tencent.mobileqq/com.tencent.mobileqq.mini.app.AppBrandTaskPreloadReceiver3
pm disable com.tencent.mobileqq/com.tencent.mobileqq.mini.app.AppBrandTaskPreloadReceiver4
pm disable com.tencent.mobileqq/com.tencent.mobileqq.mini.app.AppBrandTaskPreloadReceiver5
pm disable com.tencent.mobileqq/com.tencent.mobileqq.mini.app.AppBrandTaskPreloadReceiver6
pm disable com.tencent.mobileqq/com.tencent.mobileqq.mini.app.AppBrandTaskPreloadReceiver7
pm disable com.tencent.mobileqq/com.tencent.mobileqq.ar.ArConfigService
pm disable com.tencent.mobileqq/com.tencent.mobileqq.ar.ARGlobalConfigService
pm disable com.tencent.mobileqq/cooperation.qzone.plugin.QZonePatchService
pm disable com.tencent.mm/com.tencent.mm.sandbox.updater.AppUpdaterUI
pm disable com.tencent.mm/com.tencent.mm.sandbox.updater.AppInstallerUI
pm disable com.tencent.mm/com.tencent.mm.plugin.nfc_open.ui.NfcWebViewUI
pm disable com.tencent.mm/com.tencent.mm.plugin.appbrand.task.AppBrandTaskPreloadReceiver
pm disable com.tencent.mm/com.tencent.mm.plugin.appbrand.task.AppBrandTaskPreloadReceiver1
pm disable com.tencent.mm/com.tencent.mm.plugin.appbrand.task.AppBrandTaskPreloadReceiver2
pm disable com.tencent.mm/com.tencent.mm.plugin.appbrand.task.AppBrandTaskPreloadReceiver3
pm disable com.tencent.mm/com.tencent.mm.plugin.appbrand.task.AppBrandTaskPreloadReceiver4
pm disable com.tencent.mm/com.tencent.mm.booter.MMReceivers$SandBoxProcessReceiver

#冻结应用
pm disable com.miui.analytics
pm disable com.miui.systemAdSolution
pm disable com.google.android.gms
pm disable com.google.android.gsf
pm disable com.android.vending
pm disable com.google.android.syncadapters.contacts
pm disable com.google.android.onetimeinitializer

#app清理＋去广告来(自酷安@风雪如花剑如霜)
C=/sbin/.magisk/busybox/rm
#清理内容
D=/data/media/0
$C -rf $D/360
$C -rf $D/tad
$C -rf $D/mivideo
$C -rf $D/MT2/.temp/*
$C -rf $D/MiMarket
$C -rf $D/OSSLog
$C -rf $D/QQBrowser
$C -rf $D/bytedance
$C -rf $D/cache
$C -rf $D/dctp
$C -rf $D/did
$C -rf $D/duilite
$C -rf $D/tbs
$C -rf $D/tga
$C -rf $D/ttscache
$C -rf $D/txrtmp
$C -rf $D/.cc
$C -rf $D/.com.taobao.dp
$C -rf $D/.DataStorage
$C -rf $D/.gs_file
$C -rf $D/.OAIDSystemConfigh
$C -rf $D/.OAIDSystemConfig
$C -rf $D/.tbs
$C -rf $D/.turingdebug
$C -rf $D/.UTSystemConfig
$C -rf $D/.vivo
$C -rf $D/umeng_cache
$C -rf $D/.gs_fs0
$C -rf $D/.gs_fs3
$C -rf $D/.gs_fs6
$C -rf $D/mipush
$C -rf $D/.turing.dat
$C -rf $D/.zzz
$C -rf $D/.um
$C -rf $D/.a.dat
$C -rf $D/.a.dat
$C -rf $D/.uxx
$C -rf $D/.*Trash*
$C -rf $D/.Android
$C -rf $D/.BD_SAPI_CACHE
$C -rf $D/.ColombiaMedia
$C -rf $D/.volley.cache
$C -rf $D/at
$C -rf $D/baidu
$C -rf $D/libs
$C -rf $D/setup
$C -rf $D/sitemp
$C -rf $D/Subtitles
$C -rf $D/GX_Download
$C -rf $D/1
$C -rf $D/.UTSystemConfig
$C -rf $D/.turingdebug
$C -rf $D/.Trusfort
$C -rf $D/.pzir
$C -rf $D/.protected_image
$C -rf $D/.mm_sdk_source
$C -rf $D/.lm_device
$C -rf $D/.INSTALLATION
$C -rf $D/.Download
$C -rf $D/.dlprovider
$C -rf $D/.andro
$C -rf $D/miad
$C -rf $D/sina/weibo/imageMapper_cache
$C -rf $D/logs
$C -rf $D/logger
$C -rf $D/eg.a
$C -rf $D/Download/.cu
$C -rf /proc/sys/debug/*
$C -rf /sys/kernel/debug/*
$C -rf /data/system/dropbox/*
$C -rf /dev/fscklogs/*
$C -rf /data/system/package_cache/*
$C -rf /data/tombstones/*
$C -rf /data/local/*
$C -rf /data/system/nativedebug/*
$C - rf  /data/media/0/.com.android.providers.downloads.ui/*
$C - rf  /data/media/0/.com.android.providers.downloads/*
find $D/ -name '.td-3' -type f -print -exec rm -rf {} \;
find $D/ -name '.tdck' -type f -print -exec rm -rf {} \;
find $D/ -name '*.log' -type f -print -exec rm -rf {} \;
find $D/ -name '*.tmp' -type f -print -exec rm -rf {} \;
find $D/ -name '*.log.*' -type f -print -exec rm -rf {} \;
find $D/ -name '*._log.*' -type f -print -exec rm -rf {} \;
K=/sbin/.magisk/busybox/chattr
#禁用广告
touch $D/sina/weibo/imageMapper_cache
touch $D/tad
touch $D/GX_Download
touch $D/miad
touch $D/umeng_cache
$K +i $D/tad
$K +i $D/GX_Download
$K +i $D/miad
$K +i $D/umeng_cache
$K +i $D/sina/weibo/imageMapper_cache


#UFS(来自酷安@风雪如花剑如霜)
#禁用I/O统计
echo 0 > /sys/block/sda/queue/iostats
echo 0 > /sys/block/sda/queue/iostats
echo 0 > /sys/block/sdb/queue/iostats
echo 0 > /sys/block/sdc/queue/iostats
echo 0 > /sys/block/sdd/queue/iostats
echo 0 > /sys/block/sde/queue/iostats
echo 0 > /sys/block/sdf/queue/iostats

#禁用(存储I/O)调试帮助
echo 0 > /sys/block/sda/queue/nomerges
echo 0 > /sys/block/sdb/queue/nomerges
echo 0 > /sys/block/sdc/queue/nomerges
echo 0 > /sys/block/sdd/queue/nomerges
echo 0 > /sys/block/sde/queue/nomerges
echo 0 > /sys/block/sdf/queue/nomerges

#EMMC
#禁用I/O 统计(EMMC)
echo 0 > /sys/block/mmcblk0/queue/iostats
echo 0 > /sys/block/mmcblk0rpmb/queue/iostats

#禁用(存储I/O)调试帮助
echo 0 > /sys/block/mmcblk0/queue/nomerges
echo 0 > /sys/block/mmcblk0rpmb/queue/iostats


#禁用I/O调试，UFS 和EMMC皆可用
echo 0 > /sys/block/loop0/queue/iostats
echo 0 > /sys/block/loop1/queue/iostats
echo 0 > /sys/block/loop2/queue/iostats
echo 0 > /sys/block/loop3/queue/iostats
echo 0 > /sys/block/loop4/queue/iostats
echo 0 > /sys/block/loop5/queue/iostats
echo 0 > /sys/block/loop6/queue/iostats
echo 0 > /sys/block/loop7/queue/iostats
echo 0 > /sys/block/loop8/queue/iostats
echo 0 > /sys/block/loop9/queue/iostats
echo 0 > /sys/block/loop10/queue/iostats
echo 0 > /sys/block/loop11/queue/iostats
echo 0 > /sys/block/loop12/queue/iostats
echo 0 > /sys/block/loop13/queue/iostats
echo 0 > /sys/block/loop14/queue/iostats
echo 0 > /sys/block/loop15/queue/iostats

#关闭RAMDUMP
echo 0 > /sys/module/subsystem_restart/parameters/enable_ramdumps
echo 0 > /sys/module/subsystem_restart/parameters/enable_mini_ramdumps

# 禁用驱动程序调试(和i/o无关)
echo 0 > /sys/module/binder/parameters/debug_mask
echo 0 > /sys/module/binder_alloc/parameters/debug_mask
echo 0 > /sys/module/msm_show_resume_irq/parameters/debug_mask
echo 0 > /sys/module/millet_core/parameters/millet_debug
echo 0 > /proc/sys/migt/migt_sched_debug
echo N > /sys/kernel/debug/debug_enabled

#60s将所有应用移除白名单
sleep 60s
noDozes=`pm list packages -e | sed "s/package:/-/g"`$noDozes
dumpsys deviceidle whitelist $noDozes

#CPU&八核调度（来源酷安@温亮平）
echo 1 > /dev/cpuset/sched_relax_domain_level
echo 1 > /dev/cpuset/system-background/sched_relax_domain_level
echo 1 > /dev/cpuset/background/sched_relax_domain_level
echo 1 > /dev/cpuset/foreground/sched_relax_domain_level
echo 1 > /dev/cpuset/top-app/sched_relax_domain_level

