1.系统中所有的应用和服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# pm list packages
package:com.android.cts.priv.ctsshim # tailor
package:com.qualcomm.qti.qms.service.telemetry
package:com.iflytek.autofly.accountcenter
package:com.iflytek.autofly.systemserver
package:com.android.car.messenger
package:com.android.internal.display.cutout.emulation.corner
package:com.gxatek.multiinstanceservice
package:com.qualcomm.qti.improvetouch.service
package:com.android.internal.display.cutout.emulation.double
package:com.android.providers.telephony
package:com.android.providers.calendar # 日历程序支持服务
package:com.iflytek.autofly.naviselect
package:com.gxatek.cockpit.diagnostic
package:com.android.providers.media
package:com.qti.service.colorservice
package:com.android.wallpapercropper # tailor
package:com.android.car.media
package:com.quicinc.cne.CNEService
package:com.android.car.radio
package:com.android.car.trust
package:com.core.system.service
package:com.gxa.car.timesync
package:com.android.protips # tailor
package:com.gxatek.cockpit.atmospherelampservice
package:com.qiyi.video.pad
package:com.android.documentsui # tailor
package:com.android.externalstorage
package:com.qualcomm.uimremoteclient
package:com.android.htmlviewer # tailor
package:com.gxatek.cockpit.launcher
package:com.android.companiondevicemanager
package:com.android.quicksearchbox # tailor
package:com.android.mms.service # tailor
package:com.gxa.car.externalkey
package:com.gxa.service.account
package:com.qualcomm.qti.qms.service.connectionsecurity
package:com.android.providers.downloads # tailor
package:com.gxatek.cockpit.vicelauncher
package:com.desay_svautomotive.svcarinfo
package:com.gxa.car.qnxapp
package:com.gxatek.cockpit.gallery
package:com.android.soundrecorder # tailor
package:android.car.cluster.loggingrenderer
package:com.gxa.service.carusbupdate
package:com.qualcomm.uimremoteserver
package:com.android.defcontainer # 应用安装相关的应用,删除可能无法启动
package:com.qti.confuridialer
package:com.desay_svautomotive.service.projectionservice
package:com.android.car.mapsplaceholder
package:com.android.providers.downloads.ui # tailor
package:com.android.pacprocessor
package:com.android.simappdialog # tailor 插入sim卡的弹窗
package:com.iflytek.cutefly.speechclient.hmi
package:com.android.internal.display.cutout.emulation.tall
package:com.android.certinstaller # tailor 证书安装
package:com.android.carrierconfig # tailor 可用网络的默认配置
package:android
package:com.android.contacts
package:com.android.camera2
package:com.qualcomm.wfd.service
package:com.gxatek.cockpit.schedule
package:com.android.car.systemupdater
package:com.gxa.car.engineMode
package:com.gxatek.cockpit.msgcenter
package:com.android.car
package:com.android.egg # tailor 彩蛋
package:com.android.mtp # ? usb传输协议相关的
package:com.android.nfc # tailor
package:com.android.stk
package:com.android.backupconfirm
package:com.gxatek.appservice.cluster
package:com.gxa.service.devicemanager
package:com.android.provision #系统初始化引导程序,写入一个DEVICE_PROVISIONED标记
package:com.android.statementservice
package:com.android.settings.intelligence
package:com.android.calendar # tailor日历
package:com.android.systemui.theme.dark
package:com.gxatek.cockpit.carlife
package:com.gxatek.cockpit.carplay
package:com.gxa.car.ncm.overlay
package:com.iflytek.auto.mall.hmi
package:com.android.car.settings
package:com.iflytek.autofly.h5
package:com.qualcomm.qti.dynamicddsservice
package:com.gxa.service.ebcall
package:com.android.car.hvac
package:com.qualcomm.qcrilmsgtunnel
package:com.android.providers.settings
package:com.android.sharedstoragebackup
package:com.gxatek.cockpit.carsettings
package:com.android.printspooler
package:com.qualcomm.qti.improvetouch
package:com.android.dreams.basic
package:com.gxatek.cockpit.applet
package:com.android.webview
package:com.gxatek.cockpit.btcall
package:com.android.se
package:com.android.inputdevices
package:com.android.support.car.lenspicker
package:com.gxa.service.ota
package:com.android.bips
package:com.iflytek.autofly.mediax
package:com.qti.dpmserviceapp
package:com.google.android.car.defaultstoragemonitoringcompanionapp
package:com.android.musicfx # 原生音效
package:com.gxatek.cockpit.scenesengine
package:com.gxa.car.ncm
package:com.android.cellbroadcastreceiver # 小区广播
package:android.ext.shared
package:com.android.onetimeinitializer # 首次启动用于装谷歌app的
package:com.android.server.telecom
package:com.android.keychain
package:com.qti.snapdragon.qdcm_ff
package:com.ts.appservice.kanzikotanimationservice
package:com.gxatek.cockpit.weather
package:com.gxa.service.messagecenter
package:com.android.printservice.recommendation
package:com.android.dialer # 原生拨号盘
package:com.android.gallery3d # 相机相框
package:android.ext.services
package:com.desay_svautomotive.multiscreen
package:com.android.calllogbackup #手机通话记录备份工具
package:com.gxatek.cockpit.testcarlife
package:com.gxatek.cockpit.testcarplay
package:com.android.packageinstaller
package:com.android.carrierdefaultapp # 运营商默认流量服务
package:com.gac.cloud.app
package:com.android.car.media.localmediaplayer
package:com.android.proxyhandler # 自动配置代理
package:com.gxa.car.procmanagement
package:com.android.inputmethod.latin # 原生输入法
package:com.gxa.appservice.caradapter
package:org.chromium.webview_shell
package:android.car.usb.handler
package:com.gxa.service.cluster
package:com.gxa.service.settings
package:com.android.managedprovisioning #工作组资料设置 ?
package:com.gxa.service.mediacenterservice
package:com.android.dreams.phototable # PhotoTable屏保
package:com.gxa.cockpit.hvac
package:cn.gaei.appstore
package:com.desaysv.otaservice
package:com.gxa.firewall
package:com.gxatek.cockpit.voicecarctrl
package:com.android.smspush # 短信推送
package:com.android.wallpaper.livepicker # 动态墙纸选择器
package:com.gxa.service.weather
package:com.google.android.car.vms.subscriber
package:com.qti.snapdragon.qdcm_mobile
package:com.gxa.appservice.platformadapter.adaptermainservice
package:com.gxa.service.systemui
package:com.android.storagemanager
package:com.android.bookmarkprovider # 书签
package:com.gxatek.cockpit.miniprogram
package:com.android.settings
package:com.qualcomm.qti.sva
package:com.gxatek.cockpit.carservice
package:com.gxatek.cockpit.avdc
package:com.android.calculator2 # 计算器
package:com.gxa.service.bluetooth
package:com.gxatek.cockpit.settings
package:com.android.cts.ctsshim # cts
package:com.gxa.car.audio
package:com.gxa.car.power
package:com.gxa.car.scene
package:com.iflytek.inputmethod
package:com.qti.diagservices
package:com.iflytek.autofly.dms
package:com.android.vpndialogs # VPN
package:com.iflytek.autofly.platformservice
package:com.android.email # 原生email
package:com.android.music # 原生music
package:com.android.phone # 原生phone
package:com.android.shell # ?
package:com.android.wallpaperbackup # 墙纸备份
package:com.android.providers.blockednumber
package:com.android.providers.userdictionary # 用户词典Content Provider
package:com.android.emergency # 急救信息
package:com.gxa.car.wifi.service
package:com.android.location.fused
package:com.android.deskclock # 自带闹钟
package:com.android.systemui
package:com.android.bluetoothmidiservice
package:com.qualcomm.qti.poweroffalarm
package:com.gxatek.cockpit.vpamultimode
package:com.gxa.permission
package:com.guangqi.chezaiapp
package:com.gxa.car.hardkey
package:com.android.traceur
package:com.gxatek.cockpit.screensaver
package:com.qualcomm.qti.qms.service.trustzoneaccess
package:com.desaysv.ftpserver
package:com.android.bluetooth
package:com.qualcomm.timeservice
package:com.android.providers.contacts
package:com.gxatek.cockpit.dvr
package:com.android.captiveportallogin # 网络连通信测试
package:com.google.android.car.vms.publisher
package:com.gxatek.cockpit.globalsearch
package:org.codeaurora.qti.nrNetworkSettingApp
package:com.gxatek.cockpit.account

一共有201个应用。

2.可裁剪应用

根据包名搜索应用依赖,没有依赖的可以支持裁掉编译版本试试功能。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 使用来删减不需要编入到系统的模块
PRODUCT_DELETE_PACKAGES += \
modulename

PRODUCT_DELETE_PACKAGES += \
Email \
Music \
TeleService \
CtsShimPrivPrebuilt \
WallpaperCropper \
DocumentsUI \
HTMLViewer \
Protips \
QuickSearchBox \
DownloadProvider \
SoundRecorder \
DownloadProviderUi \
SimAppDialog \
CertInstaller \
CarrierConfig \
EasterEgg \
NfcNci \
Calendar \
MusicFX \
CellBroadcastReceiver \
OneTimeInitializer \
Dialer \
Gallery2 \
CarrierDefaultApp \
ProxyHandler \
ManagedProvisioning \
CarLatinIME \
WAPPushManager \
LiveWallpapersPicker \
BookmarkProvider \
ExactCalculator \
CtsShimPrebuilt \
VpnDialogs \
WallpaperBackup \
UserDictionaryProvider \
EmergencyInfo \
DeskClock \
CaptivePortalLogin \
CalendarProvider
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 或者使用如下Android.mk来裁剪模块
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := CarExcludePackages

LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := FAKE
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

LOCAL_OVERRIDES_PACKAGES += \
Launcher2 \
Launcher3 \
CarLauncher

include $(BUILD_SYSTEM)/base_rules.mk

$(LOCAL_BUILT_MODULE):
$(hide) echo "Fake: $@"
$(hide) mkdir -p $(dir $@)
$(hide) touch $@

PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))

首先通过pm path 包名找到对应编译时的LOCAL_MODULE 或者 LOCAL_PACKAGE_NAME, 然后通过包的名字或者模块名字找到对应的mk, 把模块名字加到PRODUCT_DELETE_PACKAGES下。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# packages/apps/Email/Android.mk
com.android.email # 原生email

# packages/apps/Music/Android.mk
com.android.music # 原生music

# packages/services/Telephony/Android.mk
com.android.phone # 原生phone

# frameworks/base/packages/CtsShim/Android.mk
com.android.cts.priv.ctsshim # 原生cts app

# frameworks/base/packages/WallpaperCropper/Android.mk
com.android.wallpapercropper # 壁纸

# packages/apps/Protips/Android.mk
com.android.protips # 提示小绿人

# packages/apps/DocumentsUI/Android.mk
com.android.documentsui # 处理文档权限的组件控制对特定文件的访问

# packages/apps/HTMLViewer/Android.mk
com.android.htmlviewer # HTML查看器

# packages/apps/QuickSearchBox/Android.mk
# device/qcom/common/base.mk 配置加入
# device/qcom/qssi/base.mk 配置加入
# build/make/target/product/core.mk 配置加入
com.android.quicksearchbox # 原生全局搜索

# packages/services/Mms/Android.mk
com.android.mms.service # 短信服务

# packages/providers/DownloadProvider/Android.mk
com.android.providers.downloads # 浏览器点链接下载服务

# packages/apps/SoundRecorder/Android.mk
com.android.soundrecorder # 原生录音机

# packages/providers/DownloadProvider/ui/Android.mk
com.android.providers.downloads.ui

# frameworks/base/packages/SimAppDialog/Android.mk
com.android.simappdialog # sim插入弹窗
# =========== 正常 ==================

# packages/apps/CertInstaller/Android.mk
com.android.certinstaller # 证书安装服务

# packages/apps/CarrierConfig/Android.mk
com.android.carrierconfig # 可用网络的默认配置

# frameworks/base/packages/services/Proxy/Android.mk
com.android.proxyhandler # 自动配置代理

# build/make/target/product/generic_no_telephony.mk
# build/make/target/product/sdk_base.mk
com.android.egg # 彩蛋

# packages/apps/Nfc/Android.mk
com.android.nfc # nfc服务

# packages/apps/Calendar/Android.mk
com.android.calendar # 日历

# packages/apps/MusicFX/Android.mk
com.android.musicfx # 音效

# packages/apps/CellBroadcastReceiver/Android.mk
com.android.cellbroadcastreceiver # 小区广播

# packages/apps/OneTimeInitializer/Android.mk
com.android.onetimeinitializer # 首次启动用于装谷歌app的

# packages/apps/Dialer/Android.mk
com.android.dialer # 原生拨号盘

# packages/apps/Gallery2/Android.mk
com.android.gallery3d # 相机相框

# frameworks/base/packages/CarrierDefaultApp/Android.mk
com.android.carrierdefaultapp # 运营商默认流量服务

# packages/apps/Car/LatinIME/Android.mk
com.android.inputmethod.latin # 原生输入法

# packages/apps/ManagedProvisioning/Android.mk
com.android.managedprovisioning # 工作组资料设置

# packages/screensavers/PhotoTable/Android.mk
com.android.dreams.phototable # PhotoTable屏保

# frameworks/base/packages/WAPPushManager/Android.mk
com.android.smspush # 短信推送

# packages/wallpapers/LivePicker/Android.mk
com.android.wallpaper.livepicker # 动态墙纸选择器

# packages/providers/BookmarkProvider/Android.mk
com.android.bookmarkprovider # 书签

# packages/apps/ExactCalculator/Android.mk
com.android.calculator2 # 计算器

# frameworks/base/packages/CtsShim/Android.mk
com.android.cts.ctsshim # cts

# frameworks/base/packages/VpnDialogs/Android.mk
com.android.vpndialogs # VPN

# frameworks/base/packages/WallpaperBackup/Android.mk
com.android.wallpaperbackup # 墙纸备份

# packages/providers/UserDictionaryProvider/Android.mk
com.android.providers.userdictionary # 用户词典Content Provider

# packages/apps/EmergencyInfo/Android.mk
com.android.emergency # 急救信息

# packages/apps/DeskClock/Android.mk
com.android.deskclock # 自带闹钟

# frameworks/base/packages/CaptivePortalLogin/Android.mk
com.android.captiveportallogin # 网络连通信测试

# packages/providers/CalendarProvider/Android.mk
com.android.providers.calendar # 日历程序支持服务

3.修改编译脚本

1
2
3
4
5
6
7
8
9
10
# build/core/main.mk
# Filter out the overridden packages before doing expansion
product_MODULES := $(filter-out $(foreach p, $(product_MODULES), \
$(PACKAGES.$(p).OVERRIDES)), $(product_MODULES))
# Filter out executables as well
product_MODULES := $(filter-out $(foreach m, $(product_MODULES), \
$(EXECUTABLES.$(m).OVERRIDES)), $(product_MODULES))

# Filter out PRODUCT_DELETE_PACKAGES标签的模块
product_MODULES := $(filter-out $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DELETE_PACKAGES), $(product_MODULES))

INTERNAL_PRODUCT值是: device/qcom/msmnile_gvmq/msmnile_gvmq.mk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# build/core/product.mk
_product_var_list := \
PRODUCT_NAME \
PRODUCT_MODEL \
PRODUCT_LOCALES \
PRODUCT_AAPT_CONFIG \
PRODUCT_AAPT_PREF_CONFIG \
PRODUCT_AAPT_PREBUILT_DPI \
PRODUCT_PACKAGES \
# 添加PRODUCT_DELETE_PACKAGES标签
PRODUCT_DELETE_PACKAGES \
PRODUCT_PACKAGES_DEBUG \
PRODUCT_PACKAGES_ENG \
PRODUCT_PACKAGES_TESTS \
PRODUCT_DEVICE \
PRODUCT_MANUFACTURER
1
2
3
4
5
6
7
8
# device/qcom/common/base.mk

PRODUCT_PACKAGES += liboemaids_system
PRODUCT_PACKAGES += liboemaids_vendor
PRODUCT_PACKAGES += android.hardware.health@2.0-service

# 加入
include device/qcom/common/tailor.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# device/gxatek/common/tailor.mk
PRODUCT_DELETE_PACKAGES += \
Email \
Music \
TeleService \
CtsShimPrivPrebuilt \
WallpaperCropper \
DocumentsUI \
HTMLViewer \
Protips \
QuickSearchBox \
DownloadProvider \
SoundRecorder \
DownloadProviderUi \
SimAppDialog \
CertInstaller \
CarrierConfig \
EasterEgg \
NfcNci \
Calendar \
MusicFX \
CellBroadcastReceiver \
OneTimeInitializer \
Dialer \
Gallery2 \
CarrierDefaultApp \
ProxyHandler \
ManagedProvisioning \
CarLatinIME \
WAPPushManager \
LiveWallpapersPicker \
BookmarkProvider \
ExactCalculator \
CtsShimPrebuilt \
VpnDialogs \
WallpaperBackup \
UserDictionaryProvider \
EmergencyInfo \
DeskClock \
CaptivePortalLogin \
CalendarProvider

4.优化后结果

优化前启动日志

1
2
3
4
15506 2021/09/02 20:06:50.728475 15.0165 191 ECU1 am_a LOGD 335 log info verbose 1 I/am_activity_launch_time( 732): [0,41558120,com.android.settings/.FallbackHome,902,902]
21304 2021/09/08 21:26:15.593283 335844.3927 221 ECU1 am_a LOGD 335 log info verbose 1 I/am_activity_launch_time( 732): [0,41558120,com.android.settings/.FallbackHome,902,902]
45648 2021/09/08 21:26:29.368316 27.0577 245 ECU1 am_a LOGD 335 log info verbose 1 I/am_activity_launch_time( 732): [0,109419867,com.gxatek.cockpit.launcher/.LauncherActivity,5839,5839]
46331 2021/09/08 21:26:29.804092 28.0021 160 ECU1 am_a LOGD 335 log info verbose 1 I/am_activity_launch_time( 732): [0,143134280,com.gxatek.cockpit.vicelauncher/.MainActivity,1057,1057]

从日志中看到优化前Android启动耗时在28s。

裁剪一半应用

1
2
3
14153 2021/09/02 20:06:50.030267 14.0892 118 ECU1 am_a LOGD 337 log info verbose 1 I/am_activity_launch_time( 739): [0,250243696,com.android.settings/.FallbackHome,933,933]
43483 2021/09/02 20:07:02.283826 27.0223 16 ECU1 am_a LOGD 337 log info verbose 1 I/am_activity_launch_time( 739): [0,141995565,com.gxatek.cockpit.launcher/.LauncherActivity,6054,6054]
44365 2021/09/02 20:07:02.607031 27.0555 130 ECU1 am_a LOGD 337 log info verbose 1 I/am_activity_launch_time( 739): [0,170842785,com.gxatek.cockpit.vicelauncher/.MainActivity,858,858]

从日志中看到优化前Android启动耗时在27s。

裁剪应用之后

1
2
3
4
14475 2021/09/02 20:06:50.375211 13.0238 184 ECU1 am_a LOGD 338 log info verbose 1 I/am_activity_launch_time( 732): [0,54614525,com.android.settings/.FallbackHome,793,793]
19098 2021/09/08 21:52:48.474646 334249.4242 105 ECU1 am_a LOGD 338 log info verbose 1 I/am_activity_launch_time( 732): [0,54614525,com.android.settings/.FallbackHome,793,793]
39476 2021/09/08 21:53:01.071597 25.0651 3 ECU1 am_a LOGD 338 log info verbose 1 I/am_activity_launch_time( 732): [0,64801107,com.gxatek.cockpit.launcher/.LauncherActivity,6039,6039]
39755 2021/09/08 21:53:01.297294 25.0881 26 ECU1 am_a LOGD 338 log info verbose 1 I/am_activity_launch_time( 732): [0,178297624,com.gxatek.cockpit.vicelauncher/.MainActivity,830,830]

从日志中看到优化前Android启动耗时在25s。

总结:根据项目的需求,当车机系统裁掉以上应用后,开机启动耗时可以减少近3s。