源码位置:frameworks/base/core/java/android/app/ActivityThread.java
注意ActivityThread继承自ClientTransactionHandler类
-
systemMain方法
7187 @UnsupportedAppUsage 7188 public static ActivityThread systemMain() { 7189 // The system process on low-memory devices do not get to use hardware 7190 // accelerated drawing, since this can add too much overhead to the 7191 // process. 7192 if (!ActivityManager.isHighEndGfx()) { 7193 ThreadedRenderer.disable(true); 7194 } else { 7195 ThreadedRenderer.enableForegroundTrimming(); 7196 } 7197 ActivityThread thread = new ActivityThread(); 7198 thread.attach(true, 0); 7199 return thread; 7200 }
此方法除了SystemServer.java会调用,
frameworks/base/cmds/media/src/com/android/commands/media/Media.java
也会调用到。 -
attach方法
7111 @UnsupportedAppUsage 7112 private void attach(boolean system, long startSeq) { 7113 sCurrentActivityThread = this; 7114 mSystemThread = system; 7115 if (!system) { ... 7147 } else { 7148 // Don't set application object here -- if the system crashes, 7149 // we can't display an alert, we just want to die die die. 7150 android.ddm.DdmHandleAppName.setAppName("system_process", 7151 UserHandle.myUserId()); 7152 try { 7153 mInstrumentation = new Instrumentation(); 7154 mInstrumentation.basicInit(this); 7155 ContextImpl context = ContextImpl.createAppContext( 7156 this, getSystemContext().mPackageInfo); 7157 mInitialApplication = context.mPackageInfo.makeApplication(true, null); 7158 mInitialApplication.onCreate(); 7159 } catch (Exception e) { 7160 throw new RuntimeException( 7161 "Unable to instantiate Application():" + e.toString(), e); 7162 } 7163 }
-
getSystemContext方法
2390 @UnsupportedAppUsage 2391 public ContextImpl getSystemContext() { 2392 synchronized (this) { 2393 if (mSystemContext == null) { 2394 mSystemContext = ContextImpl.createSystemContext(this); 2395 } 2396 return mSystemContext; 2397 } 2398 }
-
getSystemUiContext
2400 public ContextImpl getSystemUiContext() { 2401 synchronized (this) { 2402 if (mSystemUiContext == null) { 2403 mSystemUiContext = ContextImpl.createSystemUiContext(getSystemContext()); 2404 } 2405 return mSystemUiContext; 2406 } 2407 }
0 条评论