android启动简记

Linux启动
1、Linux内核加载→init进程(Linux内核启动的第一个用户级进程,进程号1)→init.rc配置脚本→启动系统服务(多媒体服务、网络服务、音量服务、蓝牙服务、USB服务、日志服务、电话服务、事件服务、Zygote服务)
2、系统服务由init进程使用socket长连接守护。init进程read()一直处于阻塞状态,当read()不再被阻塞,重新启动系统服务进程。
3、但是init进程不对系统服务的子进程负责。
4、自定义android 系统服务:可在init.rc中添加自定义服务

App启动
1、Zygote启动→启动SystemServer进程→启动framework层服务→PMS扫描/data/app中的apk→PackageParse解析AndroidManifest.xml→组件存档→保存到Packages缓存中心

2、ActivityManagerService 启动完成→launcher启动→用户点击图标(StartActivity)→AMS根据启动的类名信息查找PMS组件存档中心→ActivityThread反射机制得到Activity对象,启动activity→添加到Activity缓存中心(ArrayMap)

  //SystemServer.java
  startBootstrapServices(); //引导服务
  startCoreServices(); //核心服务
  startOtherServices(); /其他服务

Launcher启动源码简析

//SystemServer.java
private void startOtherServices() {
  .................
  mActivityManagerService.systemReady(() -> {
            Slog.i(TAG, "Making services ready");
            traceBeginAndSlog("StartActivityManagerReadyPhase");
            mSystemServiceManager.startBootPhase(
                    SystemService.PHASE_ACTIVITY_MANAGER_READY);
            traceEnd();
            traceBeginAndSlog("StartObservingNativeCrashes");
            try {
                mActivityManagerService.startObservingNativeCrashes();
            } catch (Throwable e) {
                reportWtf("observing native crashes", e);
            }
            traceEnd();
            ...............
  }
  ...............
}
 //ActivityManagerService.java
  public void systemReady(final Runnable goingCallback, TimingsTraceLog traceLog) {
   ...............
   mStackSupervisor.resumeFocusedStackTopActivityLocked();
   ...............
  }
     //ActivityStackSupervisor.java
    boolean resumeFocusedStackTopActivityLocked(
            ActivityStack targetStack, ActivityRecord target, ActivityOptions targetOptions) {

        if (!readyToResume()) {
            return false;
        }

        if (targetStack != null && isFocusedStack(targetStack)) {
            return targetStack.resumeTopActivityUncheckedLocked(target, targetOptions);
        }

        final ActivityRecord r = mFocusedStack.topRunningActivityLocked();
        if (r == null || !r.isState(RESUMED)) {
            mFocusedStack.resumeTopActivityUncheckedLocked(null, null);
        } else if (r.isState(RESUMED)) {
            // Kick off any lingering app transitions form the MoveTaskToFront operation.
            mFocusedStack.executeAppTransition(targetOptions);
        }

        return false;
    }
     //ActivityStack.java
boolean resumeTopActivityUncheckedLocked(ActivityRecord prev, ActivityOptions options) {
        if (mStackSupervisor.inResumeTopActivity) {
            // Don't even start recursing.
            return false;
        }

        boolean result = false;
        try {
            // Protect against recursion.
            mStackSupervisor.inResumeTopActivity = true;
            result = resumeTopActivityInnerLocked(prev, options);

            // When resuming the top activity, it may be necessary to pause the top activity (for
            // example, returning to the lock screen. We suppress the normal pause logic in
            // {@link #resumeTopActivityUncheckedLocked}, since the top activity is resumed at the
            // end. We call the {@link ActivityStackSupervisor#checkReadyForSleepLocked} again here
            // to ensure any necessary pause logic occurs. In the case where the Activity will be
            // shown regardless of the lock screen, the call to
            // {@link ActivityStackSupervisor#checkReadyForSleepLocked} is skipped.
            final ActivityRecord next = topRunningActivityLocked(true /* focusableOnly */);
            if (next == null || !next.canTurnScreenOn()) {
                checkReadyForSleep();
            }
        } finally {
            mStackSupervisor.inResumeTopActivity = false;
        }

        return result;
    }
   //ActivityStack.java
  @GuardedBy("mService")
    private boolean resumeTopActivityInnerLocked(ActivityRecord prev, ActivityOptions options) {
        if (!mService.mBooting && !mService.mBooted) {
            // Not ready yet!
            return false;
        }

        // Find the next top-most activity to resume in this stack that is not finishing and is
        // focusable. If it is not focusable, we will fall into the case below to resume the
        // top activity in the next focusable task.
        final ActivityRecord next = topRunningActivityLocked(true /* focusableOnly */);

        final boolean hasRunningActivity = next != null;

        // TODO: Maybe this entire condition can get removed?
        if (hasRunningActivity && !isAttached()) {
            return false;
        }

        mStackSupervisor.cancelInitializingActivities();

        // Remember how we'll process this pause/resume situation, and ensure
        // that the state is reset however we wind up proceeding.
        boolean userLeaving = mStackSupervisor.mUserLeaving;
        mStackSupervisor.mUserLeaving = false;

        if (!hasRunningActivity) {
            // There are no activities left in the stack, let's look somewhere else.
            return resumeTopActivityInNextFocusableStack(prev, options, "noMoreActivities");
        }

        next.delayedResume = false;
        ..................
 }
   //ActivityStack.java
    private boolean resumeTopActivityInNextFocusableStack(ActivityRecord prev,
            ActivityOptions options, String reason) {
        if (adjustFocusToNextFocusableStack(reason)) {
            // Try to move focus to the next visible stack with a running activity if this
            // stack is not covering the entire screen or is on a secondary display (with no home
            // stack).
            return mStackSupervisor.resumeFocusedStackTopActivityLocked(
                    mStackSupervisor.getFocusedStack(), prev, null);
        }

        // Let's just start up the Launcher...
        ActivityOptions.abort(options);
        if (DEBUG_STATES) Slog.d(TAG_STATES,
                "resumeTopActivityInNextFocusableStack: " + reason + ", go home");
        if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked();
        // Only resume home if on home display
        return isOnHomeDisplay() &&
                mStackSupervisor.resumeHomeStackTask(prev, reason);
    }
 //ActivityStackSupervisor.java
  boolean resumeHomeStackTask(ActivityRecord prev, String reason) {
        if (!mService.mBooting && !mService.mBooted) {
            // Not ready yet!
            return false;
        }

        mHomeStack.moveHomeStackTaskToTop();
        ActivityRecord r = getHomeActivity();
        final String myReason = reason + " resumeHomeStackTask";

        // Only resume home activity if isn't finishing.
        if (r != null && !r.finishing) {
            moveFocusableActivityStackToFrontLocked(r, myReason);
            return resumeFocusedStackTopActivityLocked(mHomeStack, prev, null);
        }
        return mService.startHomeActivityLocked(mCurrentUser, myReason);
    }
//ActivityManagerService.java
    boolean startHomeActivityLocked(int userId, String reason) {
        if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL
                && mTopAction == null) {
            // We are running in factory test mode, but unable to find
            // the factory test app, so just sit around displaying the
            // error message and don't try to start anything.
            return false;
        }
        Intent intent = getHomeIntent();
        ActivityInfo aInfo = resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
        if (aInfo != null) {
            intent.setComponent(new ComponentName(aInfo.applicationInfo.packageName, aInfo.name));
            // Don't 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);
            }
        } else {
            Slog.wtf(TAG, "No home screen found for " + intent, new Throwable());
        }

        return true;
    }

记:
DVM虚拟机: 将class字节码加载到内存,DVM虚拟机转换成本地指令,送给cpu运行。运行慢。(5.0之前)
ART虚拟机:安装apk时,将class字节码转换成本地指令。安装耗时,存储空间大,运行快。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 等保2.0标准中对技术安全要求主要包括信息安全类要求(简记为x)、服务保证类要求(简记为s)、其他安全保护类要求(简记为g)和数据设备类要求(简记为f)。 a. 信息安全类要求(x)是等保2.0标准中的一项重要要求,它涉及了信息系统的安全保护、安全管理和信息安全技术的实施要求,包括身份认证、访问控制、审计、加密等内容。 b. 服务保证类要求(s)也是等保2.0标准中的一项重要要求,它主要围绕着信息系统的可用性、可靠性和稳定性进行要求,包括灾备备份、容灾恢复、业务连续性等内容。 c. 其他安全保护类要求(g)是等保2.0标准中的一项综合要求,主要涉及到对软硬件安全配置、网络安全和物理环境安全等方面的要求,包括网络隔离、漏洞修复、环境监控等内容。 d. 数据设备类要求(f)是等保2.0标准中专门对数据安全进行要求的一项内容,它主要包括数据备份、数据恢复、数据存储、数据传输等方面的安全要求。 综上所述,a、b、c、d选项所描述的等保2.0标准中对技术安全要求的分工是正确的。 ### 回答2: 等保2.0标准中对技术安全要求主要包含了信息安全类要求、服务保证类要求、其他安全保护类要求和数据设备类要求。 a. 信息安全类要求指的是对信息系统的各种组成部分、信息传输和处理过程以及相关的信息安全协议、算法等进行安全要求和控制。这是等保2.0标准中非常重要的一部分。 b. 服务保证类要求主要涉及系统的可用性、可靠性、灾备能力、响应能力等方面的要求。这些要求旨在确保信息系统随时可用,并且能够及时处理异常情况。 c. 其他安全保护类要求主要包括物理环境安全、人员安全、网络安全、应用软件安全等方面的要求。这些要求涉及到信息系统运行环境的各个方面和安全管理控制的要求。 d. 数据设备类要求主要涉及到数据的存储、传输、备份、还原等方面的要求。这些要求着重保护重要数据的安全性和完整性。 所以以上说法都正确,它们都是等保2.0标准中对技术安全方面的要求的不同分类。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值