Android系统的开机画面显示过程分析(13)
-
public class WindowManagerService extends IWindowManager.Stub
-
implements Watchdog.Monitor {
-
......
-
-
public void performEnableScreen() {
-
synchronized(mWindowMap) {
-
if (mDisplayEnabled) {
-
return;
-
}
-
if (!mSystemBooted) {
-
return;
-
}
-
-
......
-
-
mDisplayEnabled = true;
-
......
-
-
try {
-
IBinder surfaceFlinger = ServiceManager.getService("SurfaceFlinger");
-
if (surfaceFlinger != null) {
-
//Slog.i(TAG, "******* TELLING SURFACE FLINGER WE ARE BOOTED!");
-
Parcel data = Parcel.obtain();
-
data.writeInterfaceToken("android.ui.ISurfaceComposer");
-
surfaceFlinger.transact(IBinder.FIRST_CALL_TRANSACTION,
-
data, null, 0);
-
data.recycle();
-
}
-
} catch (RemoteException ex) {
-
Slog.e(TAG, "Boot completed: SurfaceFlinger is dead!");
-
}
-
}
-
-
......
-
}
-
-
......
-
}
WindowManagerService类的另外一个成员变量mDisplayEnabled用来描述WindowManagerService是否已经初始化过系统的屏幕了,只有当它的值等于false,并且系统已经完成启动,即WindowManagerService类的成员变量mSystemBooted等于true的情况下,WindowManagerService类的成员函数performEnableScreen才通知SurfaceFlinger服务停止显示开机动画。
-
class BnSurfaceComposer : public BnInterface<ISurfaceComposer>
-
{
-
public:
-
enum {
-
// Note: BOOT_FINISHED must remain this value, it is called from
-
// Java by ActivityManagerService.
-
BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
-
......
-
};
-
-
virtual status_t onTransact( uint32_t code,
-
const Parcel& data,
-
Parcel* reply,
-
uint32_t flags = 0);
-
};
-
void SurfaceFlinger::bootFinished()
-
{
-
const nsecs_t now = systemTime();
-
const nsecs_t duration = now - mBootTime;
-
LOGI("Boot is finished (%ld ms)", long(ns2ms(duration)) );
-
mBootFinished = true;
-
property_set("ctl.stop", "bootanim");
-
}
-
void handle_control_message(const char *msg, const char *arg)
-
{
-
if (!strcmp(msg,"start")) {
-
msg_start(arg);
-
} else if (!strcmp(msg,"stop")) {
-
msg_stop(arg);
-
} else {
-
ERROR("unknown control msg '%s'\n", msg);
-
}
-
}
-
static void msg_stop(const char *name)
-
{
-
struct service *svc = service_find_by_name(name);
-
-
if (svc) {
-
service_stop(svc);
-
} else {
-
ERROR("no such service '%s'\n", name);
-
}
-
}