android virtual mobile cloud 5: support multiple applications in the front desk

General Post Ad locum.

Support multiple applications in the foreground

Let's start with the background. Many apps are tested in the front desk. I can see the test methods of the front desk and the back desk This blog

One key point is onPause. In short, if onPause does not callback, the App will switch to the background without awareness, and the success rate will be 80%.
When making changes, Android's window management mechanism is involved, but the most essential change is in ActivityStack.java

frameworks/base/services/core/java/com/android/server/am/ActivityStack.java

The key modified function is this

/**
 * Pause all activities in either all of the stacks or just the back stacks.
 * @param userLeaving Passed to pauseActivity() to indicate whether to call onUserLeaving().
 * @return true if any activity was paused as a result of this call.
 */
boolean pauseBackStacks(boolean userLeaving, boolean resuming, boolean dontWait) {
    boolean someActivityPaused = false;
    for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
        ArrayList<ActivityStack> stacks = mActivityDisplays.valueAt(displayNdx).mStacks;
        for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) {
            final ActivityStack stack = stacks.get(stackNdx);
            if (/* Add by chenyongqiang */ !isOnOtherStack(stack) && /* Add by chenyongqiang end.*/ !isFrontStack(stack) && stack.mResumedActivity != null) {
                if (DEBUG_STATES) Slog.d(TAG_STATES, "pauseBackStacks: stack=" + stack +
                        " mResumedActivity=" + stack.mResumedActivity);
                someActivityPaused |= stack.startPausingLocked(userLeaving, false, resuming,
                        dontWait);
            }
        }
    }
    return someActivityPaused;
}

// TODO
//I'm going to hang up. I'll make it up later

Tags: Java Android

Posted on Wed, 01 Apr 2020 06:35:51 -0700 by jesse_james