网站名称是什么意思网页设计与网站建设案例教程
2026/2/11 20:20:07 网站建设 项目流程
网站名称是什么意思,网页设计与网站建设案例教程,网站建设佰金手指科杰三,国内咨询公司排名前十名1、LauncherLauncher作为Android系统的桌面#xff0c;它的作用有两点#xff1a; 作为Android系统的启动器#xff0c;用于启动应用程序#xff1b; 作为Android系统的桌面#xff0c;用于显示和管理应用程序的快捷图标或者其它桌面组件#xff1b;2、Launcher进程启动流…1、LauncherLauncher作为Android系统的桌面它的作用有两点作为Android系统的启动器用于启动应用程序作为Android系统的桌面用于显示和管理应用程序的快捷图标或者其它桌面组件2、Launcher进程启动流程2.1、SystemServer调用在SystemServer进程启动之后执行其run()函数在里面执行了大量的配置设置操作并且启动了各种引导服务、核心服务以及其他服务等包括AMS、PMS、WMS、电量管理服务等一系列服务以及创建主线程Looper并循环等待消息其中在启动引导服务方法中启动了ActivityManagerService并且在启动其他服务的方法中调用AMS的systemReady()方法Launcher进程就是从这儿开始启动的public final class SystemServer { private void run() { ... startBootstrapServices(); startOtherServices(); ... } private void startBootstrapServices() { ... mActivityManagerService mSystemServiceManager.startService(ActivityManagerService.Lifecycle.class).getService(); mActivityManagerService.setSystemServiceManager(mSystemServiceManager); mActivityManagerService.setInstaller(installer); ... } private void startOtherServices() { ... mActivityManagerService.systemReady(() - { }, BOOT_TIMINGS_TRACE_LOG); } }在SystemServer启动的时候执行startOtherServices()方法中里面调用了AMS的systemReady()方法通过该方法来启动Launcher// Tag for timing measurement of main thread. private static final String SYSTEM_SERVER_TIMING_TAG SystemServerTiming; private static final TimingsTraceLog BOOT_TIMINGS_TRACE_LOG new TimingsTraceLog(SYSTEM_SERVER_TIMING_TAG, Trace.TRACE_TAG_SYSTEM_SERVER); private void startOtherServices() { ... mActivityManagerService.systemReady(() - { Slog.i(TAG, Making services ready); traceBeginAndSlog(StartActivityManagerReadyPhase); mSystemServiceManager.startBootPhase(SystemService.PHASE_ACTIVITY_MANAGER_READY); ... }, BOOT_TIMINGS_TRACE_LOG); }2.2、AMS执行在AMS中执行systemReady()方法在其中执行startHomeActivityLocked()方法传入当前用户IDpublic void systemReady(final Runnable goingCallback, TimingsTraceLog traceLog) { ... synchronized (this) { ... startHomeActivityLocked(currentUserId, systemReady); ... } ... }2.2.1、获取Launcher的Intent在startHomeActivityLocked()方法中首先通过getHomeIntent()方法获取到要启动的HomeActivity的intent对象其中mTopAction默认为INTENT.ACTION_MAIN并添加CATEGORY_HOME的category标志得到Intent对象通过PackageManager去获取对应符合的Activity获取对应的ActivityInfo并获取对应的进程记录此时对应的进程还没启动后面继续执行为intent添加FLAG_ACTIVITY_NEW_TASK启动参数开启新栈随后调用ActivityStartController类的startHomeActivity()方法去执行启动boolean startHomeActivityLocked(int userId, String reason) { ... Intent intent getHomeIntent(); ActivityInfo aInfo resolveActivityInfo(intent, STOCK_PM_FLAGS, userId); if (aInfo ! null) { intent.setComponent(new ComponentName(aInfo.applicationInfo.packageName, aInfo.name)); // Dont do this if the home app is currently being instrumented. aInfo new ActivityInfo(aInfo); aInfo.applicationInfo getAppInfoForUser(aInfo.applicationInfo, userId); ProcessRecord app getProcessRecordLocked(aInfo.processName, aInfo.applicationInfo.uid, true); if (app null || app.instr null) { intent.setFlags(intent.getFlags() | FLAG_ACTIVITY_NEW_TASK); final int resolvedUserId UserHandle.getUserId(aInfo.applicationInfo.uid); // For ANR debugging to verify if the user activity is the one that actually launched. final String myReason reason : userId : resolvedUserId; mActivityStartController.startHomeActivity(intent, aInfo, myReason); } } ... return true; } Intent getHomeIntent() { Intent intent new Intent(mTopAction, mTopData ! null ? Uri.parse(mTopData) : null); intent.setComponent(mTopComponent); intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING); if (mFactoryTest ! FactoryTest.FACTORY_TEST_LOW_LEVEL) { intent.addCategory(Intent.CATEGORY_HOME); } return intent; }2.2.2、启动Launcher在startHomeActivity()方法中调用obtainStarter()方法获取到一个ActivityStarter对象setCallingUid()方法设置当前调用的Uid0然后执行其execute()方法void startHomeActivity(Intent intent, ActivityInfo aInfo, String reason) { mSupervisor.moveHomeStackTaskToTop(reason); mLastHomeActivityStartResult obtainStarter(intent, startHomeActivity: reason) .setOutActivity(tmpOutRecord) .setCallingUid(0) .setActivityInfo(aInfo) .execute(); mLastHomeActivityStartRecord tmpOutRecord[0]; if (mSupervisor.inResumeTopActivity) { // If we are in resume section already, home activity will be initialized, but not // resumed (to avoid recursive resume) and will stay that way until something pokes it // again. We need to schedule another resume. mSupervisor.scheduleResumeTopActivities(); } }在ActivityStarter的execute()方法中mayWait默认为false执行startActivity()方法int execute() { try { // TODO(b/64750076): Look into passing request directly to these methods to allow // for transactional diffs and preprocessing. if (mRequest.mayWait) { return startActivityMayWait(mRequest.caller, mRequest.callingUid, ...); } else { return startActivity(mRequest.caller, mRequest.intent, mRequest.ephemeralIntent, ...); } } finally { onExecutionComplete(); } }这里进入了Activity的启动流程Launcher本身就是一个系统APP用于显示桌面等LauncherApp启动之后会执行其生命周期方法初始化桌面布局2.3、初始化桌面图标2.3.1、执行onCreate()方法Override protected void onCreate(Bundle savedInstanceState) { ... LauncherAppState app LauncherAppState.getInstance(this); ... }获取LauncherAppState通过LauncherAppState的getInstance()方法获取该方法里面会判断当前线程是否为主线程在主线程时还会直接new出对象不在主线程时通过MainThreadExecutor的submit()方法向主线程提交一个任务去获取该对象// We do not need any synchronization for this variable as its only written on UI thread. private static LauncherAppState INSTANCE; public static LauncherAppState getInstance(final Context context) { if (INSTANCE null) { if (Looper.myLooper() Looper.getMainLooper()) { INSTANCE new LauncherAppState(context.getApplicationContext()); } else { try { return new MainThreadExecutor().submit(new CallableLauncherAppState() { Override public LauncherAppState call() throws Exception { return LauncherAppState.getInstance(context); } }).get(); } catch (InterruptedException|ExecutionException e) { throw new RuntimeException(e); } } } return INSTANCE; }2.3.2、读取安装APP信息在LauncherAppState的构造方法中会新建InvariantDeviceProfile对象这个类主要是存储App的基本配置信息例如App图标的尺寸大小文字大小每个工作空间或文件夹能显示多少App等在LauncherAppState的构造方法中会获取WindowManager并获取屏幕的尺寸解析桌面布局文件获取默认尺寸信息等TargetApi(23) public InvariantDeviceProfile(Context context) { WindowManager wm (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display wm.getDefaultDisplay(); DisplayMetrics dm new DisplayMetrics(); display.getMetrics(dm); ... ArrayListInvariantDeviceProfile closestProfiles findClosestDeviceProfiles(minWidthDps, minHeightDps, getPredefinedDeviceProfiles(context)); ... } ArrayListInvariantDeviceProfile getPredefinedDeviceProfiles(Context context) { ArrayListInvariantDeviceProfile profiles new ArrayList(); try (XmlResourceParser parser context.getResources().getXml(R.xml.device_profiles)) { final int depth parser.getDepth(); int type; while (((type parser.next()) ! XmlPullParser.END_TAG || parser.getDepth() depth) type ! XmlPullParser.END_DOCUMENT) { if ((type XmlPullParser.START_TAG) profile.equals(parser.getName())) { TypedArray a context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.InvariantDeviceProfile); int numRows a.getInt(R.styleable.InvariantDeviceProfile_numRows, 0); int numColumns a.getInt(R.styleable.InvariantDeviceProfile_numColumns, 0); float iconSize a.getFloat(R.styleable.InvariantDeviceProfile_iconSize, 0); profiles.add(new InvariantDeviceProfile( a.getString(R.styleable.InvariantDeviceProfile_name), a.getFloat(R.styleable.InvariantDeviceProfile_minWidthDps, 0), a.getFloat(R.styleable.InvariantDeviceProfile_minHeightDps, 0), numRows, numColumns, a.getInt(R.styleable.InvariantDeviceProfile_numFolderRows, numRows), a.getInt(R.styleable.InvariantDeviceProfile_numFolderColumns, numColumns), iconSize, a.getFloat(R.styleable.InvariantDeviceProfile_landscapeIconSize, iconSize), a.getFloat(R.styleable.InvariantDeviceProfile_iconTextSize, 0), a.getInt(R.styleable.InvariantDeviceProfile_numHotseatIcons, numColumns), a.getResourceId(R.styleable.InvariantDeviceProfile_defaultLayoutId, 0), a.getResourceId(R.styleable.InvariantDeviceProfile_demoModeLayoutId, 0))); a.recycle(); } } } catch (IOException|XmlPullParserException e) { throw new RuntimeException(e); } return profiles; }2.3.3、注册Intent广播新建LauncherModel对象该对象是一个BroadcastReceiver并添加App变化的回调以及设置Filter并注册广播用于监听桌面App的变化private LauncherAppState(Context context) { ... mModel new LauncherModel(this, mIconCache, AppFilter.newInstance(mContext)); LauncherAppsCompat.getInstance(mContext).addOnAppsChangedCallback(mModel); // Register intent receivers IntentFilter filter new IntentFilter(); filter.addAction(Intent.ACTION_LOCALE_CHANGED); // For handling managed profiles filter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED); filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); ... mContext.registerReceiver(mModel, filter); ... } public class LauncherModel extends BroadcastReceiver ... {}2.3.4、解析Launcher布局继续回到Launcher的onCreate()方法将Launcher添加到LauncherModel中是以弱引用的方式添加初始化一些其工作解析Launcher的布局2.3.5、加载桌面onCreate()方法中通过LauncherModel的startLoader()来加载桌面AppOverride protected void onCreate(Bundle savedInstanceState) { ... if (!mModel.startLoader(currentScreen)) { if (!internalStateHandled) { // If we are not binding synchronously, show a fade in animation when // the first page bind completes. mDragLayer.getAlphaProperty(ALPHA_INDEX_LAUNCHER_LOAD).setValue(0); } } else { // Pages bound synchronously. mWorkspace.setCurrentPage(currentScreen); setWorkspaceLoading(true); } ... }在LauncherModel的startLoader()方法中新建了一个LoaderResults对象并通过startLoaderForResults()方法创建出一个LoaderTask的Runnable任务将其在工作线程中执行起来public boolean startLoader(int synchronousBindPage) { ... synchronized (mLock) { // Dont bother to start the thread if we know its not going to do anything if (mCallbacks ! null mCallbacks.get() ! null) { ... LoaderResults loaderResults new LoaderResults(mApp, sBgDataModel, mBgAllAppsList, synchronousBindPage, mCallbacks); if (mModelLoaded !mIsLoaderTaskRunning) { ... return true; } else { startLoaderForResults(loaderResults); } } } return false; } public void startLoaderForResults(LoaderResults results) { synchronized (mLock) { stopLoader(); mLoaderTask new LoaderTask(mApp, mBgAllAppsList, sBgDataModel, results); runOnWorkerThread(mLoaderTask); } } private static void runOnWorkerThread(Runnable r) { if (sWorkerThread.getThreadId() Process.myTid()) { r.run(); } else { // If we are not on the worker thread, then post to the worker handler sWorker.post(r); } }在LoaderTask的run()方法中去加载手机已安装的App的信息查询数据库获取已安装的App的相关信息加载Launcher布局并将数据转化为View绑定到界面上由此我们就可以看到桌面显示的宫格列表的桌面图标了public void run() { ... try (LauncherModel.LoaderTransaction transaction mApp.getModel().beginLoader(this)) { // 查询数据库整理App信息转化为View绑定到界面 loadWorkspace(); mResults.bindWorkspace(); loadAllApps(); mResults.bindAllApps(); loadDeepShortcuts(); mResults.bindDeepShortcuts(); mBgDataModel.widgetsModel.update(mApp, null); mResults.bindWidgets(); transaction.commit(); } catch (CancellationException e) { // Loader stopped, ignore TraceHelper.partitionSection(TAG, Cancelled); } TraceHelper.endSection(TAG); }AI大模型学习福利作为一名热心肠的互联网老兵我决定把宝贵的AI知识分享给大家。 至于能学习到多少就看你的学习毅力和能力了 。我已将重要的AI大模型资料包括AI大模型入门学习思维导图、精品AI大模型学习书籍手册、视频教程、实战学习等录播视频免费分享出来。一、全套AGI大模型学习路线AI大模型时代的学习之旅从基础到前沿掌握人工智能的核心技能因篇幅有限仅展示部分资料需要点击文章最下方名片即可前往获取二、640套AI大模型报告合集这套包含640份报告的合集涵盖了AI大模型的理论研究、技术实现、行业应用等多个方面。无论您是科研人员、工程师还是对AI大模型感兴趣的爱好者这套报告合集都将为您提供宝贵的信息和启示。因篇幅有限仅展示部分资料需要点击文章最下方名片即可前往获三、AI大模型经典PDF籍随着人工智能技术的飞速发展AI大模型已经成为了当今科技领域的一大热点。这些大型预训练模型如GPT-3、BERT、XLNet等以其强大的语言理解和生成能力正在改变我们对人工智能的认识。 那以下这些PDF籍就是非常不错的学习资源。因篇幅有限仅展示部分资料需要点击文章最下方名片即可前往获四、AI大模型商业化落地方案因篇幅有限仅展示部分资料需要点击文章最下方名片即可前往获作为普通人入局大模型时代需要持续学习和实践不断提高自己的技能和认知水平同时也需要有责任感和伦理意识为人工智能的健康发展贡献力量

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询