Android 开机加速优化

Android 开机加速优化

关闭BootLoader的企鹅

# kernel/msm-4.9/arch/arm64/configs/msm8953_defconfig
# kernel/msm-4.9/arch/arm64/configs/msm8953-perf_defconfig

CONFIG_FRAMEBUFFER_CONSOLE、CONFIG_LOGO
第一个编译选项表示内核支持帧缓冲区控制台,它对应的配置菜单项为:
Device Drivers —> Graphics support —> Console display driver support —> Framebuffer Console support。
第二个编译选项表示内核在启动的过程中,需要显示LOGO,它对应的配置菜单项为:
Device Drivers —> Graphics support —> Bootup logo。

内核源码:
/kernel/goldfish/drivers/video/
/kernel/goldfish/drivers/video/logo/

注意:默认没开启企鹅图标

关闭开机动画Android

# system/core/rootdir/init.rc
# cat frameworks/base/cmds/bootanimation/bootanim.rc

service bootanim /system/bin/bootanimation
    class core animation
    user graphics
    group graphics audio
    disabled
    oneshot
    writepid /dev/stune/top-app/tasks

关闭服务
# setprop service.bootanim.exit 0
# start bootanim
注意:没起作用,还是有明暗变化的Android logo

修改:
#  vi frameworks/base/cmds/bootanimation/bootanimation_main.cpp
直接注释main()方法的内容
不显示Android logo,但是没有看到明显的改善

关闭锁屏

# frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<bool name="def_lockscreen_disabled">true</bool>

删除预装APP

查看预装APP

adb shell pm list packages > all.txt
package:com.android.cts.priv.ctsshim
package:com.qualcomm.qti.qms.service.telemetry
package:com.qualcomm.qti.perfdump
package:com.android.internal.display.cutout.emulation.corner
package:com.android.internal.display.cutout.emulation.double
package:com.android.providers.telephony
package:com.verizon.dmclientupdate
package:com.android.providers.calendar
package:com.android.providers.media
package:com.adups.dmc
package:com.qualcomm.qti.modemtestmode
package:com.android.wallpapercropper
package:com.quicinc.cne.CNEService
package:com.android.protips
package:com.android.documentsui
package:com.android.externalstorage
package:com.qualcomm.uimremoteclient
package:com.android.htmlviewer
package:com.qualcomm.qti.uceShimService
package:com.android.companiondevicemanager
package:com.android.mms.service
package:com.qualcomm.qti.qms.service.connectionsecurity
package:com.android.providers.downloads
package:com.qualcomm.qti.callenhancement
package:com.qualcomm.qti.telephonyservice
package:com.qualcomm.qti.auth.fidocryptoservice
package:com.qualcomm.qti.optinoverlay
package:com.android.soundrecorder
package:com.qualcomm.uimremoteserver
package:com.android.defcontainer
package:com.qti.confuridialer
package:com.android.providers.downloads.ui
package:com.android.pacprocessor
package:com.android.simappdialog
package:com.android.settings.overlay.cmcc
package:com.android.internal.display.cutout.emulation.tall
package:com.android.certinstaller
package:com.android.carrierconfig
package:com.android.mms.overlay.cmcc
package:com.qti.qualcomm.datastatusnotification
package:android
package:com.android.contacts
package:org.codeaurora.gallery
package:com.qualcomm.qti.callfeaturessetting
package:com.qualcomm.wfd.service
package:android.ui.overlay.ct
package:com.qti.qualcomm.deviceinfo
package:com.android.egg
package:com.android.mms
package:com.android.mtp
package:com.android.nfc
package:com.android.stk
package:com.android.launcher3
package:com.android.backupconfirm
package:com.qualcomm.qti.server.wigigapp
package:com.android.provision
package:org.codeaurora.ims
package:com.android.statementservice
package:com.android.settings.intelligence
package:com.android.systemui.theme.dark
package:com.qualcomm.qti.dynamicddsservice
package:com.qualcomm.qcrilmsgtunnel
package:com.android.providers.settings
package:com.android.sharedstoragebackup
package:com.android.dreams.basic
package:com.android.webview
package:com.android.se
package:com.android.inputdevices
package:com.android.bips
package:com.qti.dpmserviceapp
package:com.qti.xdivert
package:com.android.systemui.overlay.cmcc
package:com.android.musicfx
package:com.android.cellbroadcastreceiver
package:android.telephony.overlay.cmcc
package:android.ext.shared
package:com.android.onetimeinitializer
package:com.qualcomm.qti.simsettings
package:com.android.server.telecom
package:com.android.backup
package:com.android.keychain
package:com.qualcomm.qti.presenceappSub2
package:com.android.printservice.recommendation
package:com.android.dialer
package:android.ext.services
package:com.qualcomm.qti.qtisystemservice
package:com.android.calllogbackup
package:com.verizon.dmbrowser
package:com.android.packageinstaller
package:com.android.carrierdefaultapp
package:com.dsi.ant.server
package:com.qualcomm.qti.remoteSimlockAuth
package:com.android.proxyhandler
package:com.cyanogenmod.filemanager
package:com.android.inputmethod.latin
package:com.qualcomm.qti.ltedirect
package:com.android.managedprovisioning
package:com.android.dreams.phototable
package:com.qualcomm.qct.dlt
package:com.android.smspush
package:com.android.wallpaper.livepicker
package:com.example.connmgr
package:com.qualcomm.qti.presenceapp
package:com.android.apps.tag
package:com.android.storagemanager
package:com.android.bookmarkprovider
package:com.android.settings
package:com.qualcomm.qti.ims
package:com.qualcomm.qti.lpa
package:com.qualcomm.qti.sva
package:com.qualcomm.qti.uim
package:com.qualcomm.location
package:com.qualcomm.simcontacts
package:com.android.cts.ctsshim
package:com.android.systemui.overlay.ct
package:com.caf.fmradio
package:com.qti.diagservices
package:com.qualcomm.qti.services.secureui
package:com.android.vpndialogs
package:com.qualcomm.location.XT
package:com.android.music
package:com.android.phone
package:com.android.shell
package:com.android.wallpaperbackup
package:com.android.providers.blockednumber
package:org.codeaurora.snapcam
package:com.android.providers.userdictionary
package:com.android.emergency
package:com.android.location.fused
package:com.android.deskclock
package:com.android.systemui
package:com.android.exchange
package:com.android.bluetoothmidiservice
package:com.qualcomm.qti.confdialer
package:com.qualcomm.qti.poweroffalarm
package:com.qualcomm.qti.networksetting
package:com.android.traceur
package:com.qualcomm.qti.qms.service.trustzoneaccess
package:com.android.bluetooth
package:com.qualcomm.timeservice
package:com.qualcomm.atfwd
package:com.qualcomm.embms
package:com.android.providers.contacts
package:com.android.captiveportallogin
package:org.codeaurora.qti.nrNetworkSettingApp

删除编译生成的APK

# test
rm -rf out/target/product/msm8953_64/vendor/app/QSensorTest/QSensorTest.apk
rm -rf out/target/product/msm8953_64/system/app/EmbmsTestApp/EmbmsTestApp.apk
rm -rf out/target/product/msm8953_64/system/app/ModemTestMode/ModemTestMode.apk

# bluetooth
rm -rf out/target/product/msm8953_64/system/app/BluetoothExt/BluetoothExt.apk
rm -rf out/target/product/msm8953_64/system/priv-app/BATestApp/BATestApp.apk
rm -rf out/target/product/msm8953_64/system/app/BTTestApp/BTTestApp.apk
rm -rf out/target/product/msm8953_64/system/app/HidTestApp/HidTestApp.apk

# web
rm -rf out/target/product/msm8953_64/system/app/webview/webview.apk
rm -rf out/target/product/msm8953_64/system/app/HTMLViewer/HTMLViewer.apk

不编译APK

1. 统一配置
去除选项
# build/make/target/product/core.mk
# device/qcom/common/base.mk
2. 修改单个APK的Android.mk
把
LOCAL_MODULE_TAGS := debug # 在debug模式下编译,改成不是debug模式,就不会编译
改成
LOCAL_MODULE_TAGS := samples

# 跳过
LOCAL_OVERRIDES_PACKAGES := APP Name

谷歌APP

# 删除APK
Browser2         # 浏览器
Calendar         # 日历
Email            # 邮件
ExactCalculator  # 精确计算器
PrintSpooler     # 打印
QuickSearchBox   # 谷歌搜索

vi device/qcom/common/base.mk
vi build/make/target/product/core.mk

高通APP

# 查找APK
find out/target/product/msm8953_64/system/app/ -name  "QSensorTest.apk"

# 查找mk文件
find . -type f -name \*.mk | xargs grep TestApp -in
find . -type f -name \*.mk | xargs grep BATestApp -in
find . -type f -name \*.mk | xargs grep QSensorTest -in
find . -type f -name \*.mk | xargs grep EmbmsTestApp -in


# BluetoothExt.apk
cat vendor/qcom/opensource/commonsys/bluetooth/hidtestapp/Android.mk
cat vendor/qcom/opensource/commonsys/bluetooth/bttestapp/Android.mk
cat vendor/qcom/opensource/commonsys/bluetooth_ext/BATestApp/Android.mk

# cat vendor/qcom/proprietary/prebuilt_HY11/target/product/msm8953_64/Android.mk

vendor/qcom/proprietary/sensors/QSensorTest/Android.mk

# vi vendor/qcom/proprietary/common/config/device-vendor.mk
# vi vendor/qcom/proprietary/prebuilt_HY11/target/product/msm8953_64/prebuilt.mk
改成simples

关闭系统服务

# frameworks/base/services/java/com/android/server/SystemServer.java

关闭服务
VibratorService          震动器服务
ClipboardService         粘贴板服务
FingerprintService       指纹

其他服务:
PowerManagerService      电源管理服务
BatteryService           电池服务,当电量不足时发广播
AlarmManagerService      闹钟服务  
WallpaperManagerService  壁纸管理服务
StatusBarManagerService  状态栏管理服务
注意:电源服务无法关闭

修改LOG打印级别

并发加载class和resource等资源

# frameworks/base/core/java/com/android/internal/os/ZygoteInit.java

Thread t1 = new Thread(new Runnable() {
    @Override public void run()
    {
        long startTimeThread = SystemClock.uptimeMillis();

        bootTimingsTraceLog.traceBegin("PreloadResources");
        preloadResources();
        bootTimingsTraceLog.traceEnd(); // PreloadResources

        Log.i(TAG, "thread:" + (SystemClock.uptimeMillis() - startTimeThread) + "ms.");
    }
});

t1.start();

//wait Thread complete.
try
{
    t1.join();
}
catch (InterruptedException e)
{
    e.printStackTrace();
}

注意:

  • 失败,不能创建线程,错误提示:java.lang.InternalError: Cannot create threads in zygote
  • 这里总共耗时2.5s左右

readahead机制预加载

测试

1. 关闭系统服务

操作说明备注
关闭系统服务VibratorService 震动器服务
FingerprintService 指纹服务
ClipboardService 粘贴板服务
其他服务:
AlarmManagerService 闹钟服务
WallpaperManagerService 壁纸管理服务
StatusBarManagerService 状态栏管理服务

2. 显示

操作说明备注
关闭开机动画企鹅LOGO
高通LOGO
Android LOGO
OK
开机显示自定义静态LOGOOK
隐藏状态栏下拉显示OK
隐藏三大按钮上拉显示OK
删除谷歌搜索栏OK
关闭电量显示和电量的监听OK
开机不显示No SIM card 提示OK
屏幕不休眠OK
系统中文显示OK
默认开启以太网OK

3. 删除预装APP

操作说明备注
删除谷歌APPBrowser2.apk 浏览器
Calendar.apk 计算器
ExactCalculator.apk 计算器
Email.apk 邮箱
PrintSpooler.apk 打印
QuickSearchBox.apk 搜索
OK
删除高通APPBluetoothExt.apk 蓝牙
BATestApp.apk 蓝牙
BTTestApp.apk 蓝牙
HidTestApp.apk 蓝牙
QSensorTest
EmbmsTestApp
OK

4. 其它

操作说明备注
修改LOG打印级别4 4 1 4OK
开机显示自定义动画LOGO

作者 [@lhgcs]
2020 年 07月 30日

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值