android 11 的Window的屏幕的架构图

这个是本人总结的,mkw的framework面试的资料,需要具体的视频和其他的资料,TB店铺 纳新工作室  中找framework 资料就好哈。

在android 11 上面是这样的。

activity和Window之间的关系:

//就是通过addWindow 添加进去Window的。对于一个acivity 来说,它下面可能有很多的window

//window 通过排序,形成图像。通过addWindow 来进行window的添加操作。

Task.java
也就是当前的activity finish 之后它会调用task里面的方法去找下一个符合条件的activity,如果没有找到就在
stack DisplayContent RootWindowImpl 里面去找。
然后设置下一个activity的状态位focus状态,主要是通过函数ActivityTaskManagerService.java  setFocusStack 
去完成的,之后会把这个task和activity moveToFront

/**
 * Finish activity if possible. If activity was resumed - we must first pause it to make the
 * activity below resumed. Otherwise we will try to complete the request immediately by calling
 * {@link #completeFinishing(String)}.
 * @return One of {@link FinishRequest} values:
 * {@link #FINISH_RESULT_REMOVED} if this activity has been removed from the history list.
 * {@link #FINISH_RESULT_REQUESTED} if removal process was started, but it is still in the list
 * and will be removed from history later.
 * {@link #FINISH_RESULT_CANCELLED} if activity is already finishing or in invalid state and the
 * request to finish it was not ignored.
 */
@FinishRequest int finishIfPossible(int resultCode, Intent resultData,
        NeededUriGrants resultGrants, String reason, boolean oomAdj) {
    if (DEBUG_RESULTS || DEBUG_STATES) {
    }}}
/**
 * Find next proper focusable task and make it focused.
 * @param reason The reason of making the adjustment.
 * @param allowFocusSelf Is the focus allowed to remain on the same task.
 * @param moveDisplayToTop Whether to move display to top while making the task focused.
 * @return The root task that now got the focus, {@code null} if none found.
 */
ActivityStack adjustFocusToNextFocusableTask(String reason, boolean allowFocusSelf,
        boolean moveDisplayToTop) {
    ActivityStack focusableTask = (ActivityStack) getNextFocusableTask(allowFocusSelf);
    if (focusableTask == null) {
        focusableTask = mRootWindowContainer.getNextFocusableStack((ActivityStack) this,
                !allowFocusSelf);
    }}}}
    
/** Return the next focusable task by looking from the siblings and parent tasks */
private Task getNextFocusableTask(boolean allowFocusSelf) {
    final WindowContainer parent = getParent();
    if (parent == null) {
        return null;
    }

    final Task focusableTask = parent.getTask((task) -> (allowFocusSelf || task != this)
            && ((ActivityStack) task).isFocusableAndVisible());
    if (focusableTask == null && parent.asTask() != null) {
        return parent.asTask().getNextFocusableTask(allowFocusSelf);
    } else {
        return focusableTask;
    }
}

ActivityTaskManagerService.java 
public void setFocusedTask(int taskId) {
    mAmInternal.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "setFocusedTask()");
    if (DEBUG_FOCUS) Slog.d(TAG_FOCUS, "setFocusedTask: taskId=" + taskId);
    final long callingId = Binder.clearCallingIdentity();
    try {
        synchronized (mGlobalLock) {
            final Task task = mRootWindowContainer.anyTaskForId(taskId,
                    MATCH_TASK_IN_STACKS_ONLY);
            if (task == null) {
                return;
            }
            final ActivityRecord r = task.topRunningActivityLocked();
            if (r != null && r.moveFocusableActivityToTop("setFocusedTask")) {
                mRootWindowContainer.resumeFocusedStacksTopActivities();
            }
        }
    } finally {
        Binder.restoreCallingIdentity(callingId);
    }
}
去将这个task move 到前面然后将focus 放在这个activity中。

对于finish的activity而言,其中后续的处理方式包括:


判断当前activity是否focus的方法:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值