现象:
Android S上,更新同年四月份gms包后,launcher应用列表上方多出一行图标。
{相册、时钟、比机、Gmail、YouTube、设置}
通过studio自带的Layout Inspector查看,这一部分界面属于all_apps_header。也就是应用列表的头信息布局中。
相关代码:
launcher view层:
多出的一行应用:Launcherquickstepsrccomandroidlauncher3apppredictionPredictionRowView.java这里面初始化最上面一行图标,可以设置图标文字颜色。
分割线:Launcherquickstepsrccomandroidlauncher3apppredictionAppsDividerView.java这里面设置分割线的颜色
多嘴一句,应用列表图标适配器:Launchersrccomandroidlauncher3allappsAllAppsGridAdapter.java 这里面标准的adapter,包含多类
型,根据不同类型显示不同的内容。onCreateViewHolder、onBindViewHolder初始化图标view、设置应用列表图标文字颜色等等。
launcher model层:
Launcherquickstepsrccomandroidlauncher3modelQuickstepModelDelegate.java注册registerPredictor监听,有更新回调时调用
private void registerPredictor(PredictorState state, AppPredictor predictor) {state.predictor = predictor;isterPredictionUpdates(MODEL_EXECUTOR, t -> handleUpdate(state, t));questPredictionUpdate();}
PredictionUpdateTask更新数据
Launcherquickstepsrccomandroidlauncher3modelPredictionUpdateTask.java更新数据、更新界面信息。
framework层:—没用太深入的研究,简单看看
//framework边的注册
frameworksbasecorejavaandroidapppredictionAppPredictor.java
registerPredictionUpdates
//
frameworksbaseservicesapppredictionjavacomandroidserverapppredictionAppPredictionManagerService.java #
registerPredictionUpdates、registerPredictionUpdatesLocked、resolveService
//
frameworksbasecorejavaandroidserviceapppredictionAppPredictionService.java
registerPredictionUpdates
manager和service2部分,通过aidl通讯。service负责数据更新和回调。
AppPredictionPerUserService.java
resolveService里执行service内容,获取应用列表
SystemServer.java中判断是否配置相关config,来启动对应的service。
config相关:
<!-- The package name for the system's app prediction service.This service must be trusted, as it can be activated without explicit consent of the user.Example: "com.android.intelligence/.AppPredictionService"
-->
<string name="config_defaultAppPredictionService" translatable="false"></string>
源码里默认的PredictionService
packagesappsOnDeviceAppPredictionsrccomandroidapppredictionservicePredictionService.java
service需要继承framework里的extends AppPredictionService,实现数据、调用更新方法
public class PredictionService extends AppPredictionService {@Overridepublic void onCreate() {Create();...postPredictionUpdateToAllClients();}private void postPredictionUpdateToAllClients() {for (AppPredictionSessionId session : activeLauncherSessions) {postPredictionUpdate(session);}}private void postPredictionUpdate(AppPredictionSessionId sessionId) {//调用更新,参数传入更新列表//一堆回调,最终调用launcher里更新,也就是launcher注册监听时传入的回调方法handleUpdateupdatePredictions(sessionId, mAppSuggestionsEnabled ? predictionList : emptyList());}
}
gms包:
新增应用:AndroidSystemIntelligence_Features.apk 包名le.android.as
新增覆盖:GmsConfigOverlayASI,包名le.sconfig.asi,rro技术覆盖framework下面的config文件配置。
反编译google apk 发现AiAiPredictionService也是extends AppPredictionService的
string name="config_defaultAppPredictionService" translatable="false"&le.android.le.android.apps.miphone.aiai.app.AiAiPredictionService</string>
========================================================================================================================================
接上篇15,重新写了一篇
本文主要补充说明一下prediction。
prediction的类型:
目前有主菜单应用、hotseat应用、widget三种
Launcher端相关的类:
Launcherquickstepsrccomandroidlauncher3uioverridesPredictedAppIcon.java
Launcherquickstepsrccomandroidlauncher3uioverridesPredictedAppIconInflater.java
Launcherquickstepsrccomandroidlauncher3apppredictionPredictionRowView.java
Launcherquickstepsrccomandroidlauncher3modelPredictionUpdateTask.java
Launcherquickstepsrccomandroidlauncher3hybridhotseatHotseatPredictionController.java
Launcherquickstepsrccomandroidlauncher3hybridhotseatHotseatPredictionModel.java
Launcherquickstepsrccomandroidlauncher3modelWidgetsPredictionUpdateTask.java
未完待续
本文发布于:2024-02-01 04:06:37,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170673159933735.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |