SystemUI分析
SystemUI是安卓的一个系统APP,负责的内容有系统通知栏,状态栏,最近应用程序,锁屏,壁纸,屏保,系统对话框,截屏,录屏等功能。
Apk的路径位于/system/priv-app,源码code位于frameworks/base/packages/SystemUI。
1.Android.mk
2.AndroidManifest.xml配置文件表明了APP要求的权限,特征以及四大组件。
3.初始化流程
1.SystemUI启动
@Override
public void run() {
startSystemUi(context);
} catch (Throwable e) {
reportWtf("starting System UI", e);
}
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.systemui",
"com.android.systemui.SystemUIService"));
//Slog.d(TAG, "Starting service: " + intent);
context.startServiceAsUser(intent, UserHandle.OWNER);
}
2.SystemUI Services启动
@Override
public void onCreate() {
super.onCreate();
((SystemUIApplication) getApplication()).startServicesIfNeeded();
}
* Application class for SystemUI.
*/
public class SystemUIApplication extends Application {
private static final String TAG = "SystemUIService";
private static final boolean DEBUG = false;
/**
* The classes of the stuff to start.
*/
private final Class<?>[] SERVICES = new Class[] {
com.android.systemui.tuner.TunerService.class,
com.android.systemui.keyguard.KeyguardViewMediator.class,
com.android.systemui.recents.Recents.class,
com.android.systemui.volume.VolumeUI.class,
com.android.systemui.statusbar.SystemBars.class,
com.android.systemui.usb.StorageNotification.class,
com.android.systemui.power.PowerUI.class,
com.android.systemui.media.RingtonePlayer.class,
};
- /**
- * Makes sure that all the SystemUI services are running. If they are already running, this is a
- * no-op. This is needed to conditinally start all the services, as we only need to have it in
- * the main process.
- *
- * <p>This method must only be called from the main thread.</p>
- */
- public void startServicesIfNeeded() {
- if (mServicesStarted) {
- return;
- }
- if (!mBootCompleted) {
- // check to see if maybe it was already completed long before we began
- // see ActivityManagerService.finishBooting()
- if ("1".equals(SystemProperties.get("sys.boot_completed"))) {
- mBootCompleted = true;
- if (DEBUG) Log.v(TAG, "BOOT_COMPLETED was already sent");
- }
- }
- Log.v(TAG, "Starting SystemUI services.");
- final int N = SERVICES.length;
- for (int i=0; i<N; i++) {
- Class<?> cl = SERVICES[i];
- if (DEBUG) Log.d(TAG, "loading: " + cl);
- try {
- mServices[i] = (SystemUI)cl.newInstance();
- } catch (IllegalAccessException ex) {
- throw new RuntimeException(ex);
- } catch (InstantiationException ex) {
- throw new RuntimeException(ex);
- }
- mServices[i].mContext = this;
- mServices[i].mComponents = mComponents;
- if (DEBUG) Log.d(TAG, "running: " + mServices[i]);
- mServices[i].start();
- if (mBootCompleted) {
- mServices[i].onBootCompleted();
- }
- }
- mServicesStarted = true;
- }
- @Override
- public void onCreate() {
- super.onCreate();
- // Set the application theme that is inherited by all services. Note that setting the
- // application theme in the manifest does only work for activities. Keep this in sync with
- // the theme set there.
- setTheme(R.style.systemui_theme);
- IntentFilter filter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
- filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
- registerReceiver(new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (mBootCompleted) return;
- if (DEBUG) Log.v(TAG, "BOOT_COMPLETED received");
- unregisterReceiver(this);
- mBootCompleted = true;
- if (mServicesStarted) {
- final int N = mServices.length;
- for (int i = 0; i < N; i++) {
- mServices[i].onBootCompleted();
- }
- }
- }
- }, filter);
- }
SystemUI Services启动后,根据各Services的功能,SystemUI开始各司其职的正常工作起来。
SystemUI分析的更多相关文章
- 第三方apk内置因签名导致SystemUI未启动启动问题案例分析
这个问题是刷完机正常开机后,发现手机无状态栏,下拉通知栏,按音量键也无法出现VolumeDialog,开始看到这个现象感觉是systemUI未编译到版本中去?或者是在systemserver中syst ...
- 【转】android SystemUI 流程分析
android4 SystemUI 流程分析 什么是SystemUI? 对于Phone来说SystemUI指的是:StatusBar(状态栏).NavigationBar(导航栏).而对于Tablet ...
- Android之SystemUI载入流程和NavigationBar的分析
Android之SystemUI载入流程和NavigationBar的分析 本篇仅仅分析SystemUI的载入过程和SystemUI的当中的一个模块StatusBar的小模块NavigationBar ...
- Android8.1 MTK平台 SystemUI源码分析之 网络信号栏显示刷新
SystemUI系列文章 Android8.1 MTK平台 SystemUI源码分析之 Notification流程 Android8.1 MTK平台 SystemUI源码分析之 电池时钟刷新 And ...
- Android8.1 SystemUI源码分析之 电池时钟刷新
SystemUI源码分析相关文章 Android8.1 SystemUI源码分析之 Notification流程 分析之前再贴一下 StatusBar 相关类图 电池图标刷新 从上篇的分析得到电池图标 ...
- Android8.1 SystemUI源码分析之 Notification流程
代码流程 1.先看UI显示,StatuBar加载 CollapsedStatusBarFragment 替换 status_bar_container(状态栏通知显示区域) SystemUI\src\ ...
- Android源码分析(十三)----SystemUI下拉状态栏如何添加快捷开关
一:如何添加快捷开关 源码路径:frameworks/base/packages/SystemUI/res/values/config.xml 添加headset快捷开关,参考如下修改. Index: ...
- Android SystemUI源代码分析和修改
1.在导航栏中添加音量加减button 一些Android音量调节button.或者从保护实体按键的角度考虑,就须要在导航栏的虚拟按键中加入音量加减调节按键. 效果例如以下图所看到的: 实现步骤例如以 ...
- Android ANR 分析解决方法
一:什么是ANR ANR:Application Not Responding,即应用无响应 二:ANR的类型 ANR一般有三种类型: 1. KeyDispatchTimeout(5 seconds) ...
随机推荐
- tar命令: 解压到指定的目录, 解压并删除原tar文件
-f: 置顶文件名, 后面不能再跟其他选项字母了,必须是文件名, 但是再在这个后面又可以跟 -? 选项: -C: 指定解压到的目的目录 不是-c, 小写的-c是创建. -p保留原来文件的属性. tar ...
- js数组,运算符
- 浅谈矩阵加速——以时间复杂度为O(log n)的算法实现裴波那契数列第n项及前n之和使用矩阵加速法的优化求法
首先请连矩阵乘法乘法都还没有了解的同学简单看一下这篇博客: https://blog.csdn.net/weixin_44049566/article/details/88945949 首先直接暴力求 ...
- Java相关面试题总结+答案(六)
[Spring/Spring MVC] 90. 为什么要使用 spring? spring 提供了 IOC 技术,spring 容器会帮你管理依赖的对象,从而不需要自己创建和管理依赖对象了,更轻松的实 ...
- linux中cut命令
cut命令 cut常用参数 cut命令用来显示行中的指定部分,删除文件中指定字段. 说明:该命令有两项功能,其一是用来显示文件的内容,它依次读取由参数file所指明的文件,将它们的内容输出到标准输出上 ...
- BZOJ 1875(DP+矩阵快速幂)
题面 传送门 分析 容易想到根据点来dp,设dp[i][j]表示到i点路径长度为j的方案数 状态转移方程为dp[i][k]=∑(i,j)∈Edp[j][k−1]" role="pr ...
- [常用类]StringBuffer 类,以及 StringBuilder 类
线程安全,可变的字符序列. 字符串缓冲区就像一个String ,但可以修改. 在任何时间点,它包含一些特定的字符序列,但可以通过某些方法调用来更改序列的长度和内容. 字符串缓冲区可以安全地被多个线程使 ...
- exec 命令
source source命令即点(.)命令. 在bash下输入man source,找到source命令解释处,可以看到解释”Read and execute commands from filen ...
- Hystrix (容错,回退,降级,缓存)
Hystrix熔断机制就像家里的保险丝一样,若同时使用高功率的电器,就会烧坏电路,这时候保险丝自动断开就有效的保护了电路.而我们程序中也同样是这样.例如若此时数据库压力太大速度很慢,此时还有不断的请求 ...
- ftp服务端
#coding=utf-8 import SocketServer import json import os class MyTcpHandler(SocketServer.BaseRequestH ...