Android 5.0 native bug and repair methods, android5.0bug

Source: Internet
Author: User

Android 5.0 native bug and repair methods, android5.0bug

Android 5.0 has already been released. This version is greatly changed, and it also means that more bugs will be hidden in it. In this article, I will keep updating the native bugs and fixing methods I have encountered.

1. bug1

Symptom:

ActivityManagerService in 5.0. the keyguardWaitingForActivityDrawn () interface replaces ActivityManagerService in 4.4. dismissKeyguardOnNextActivity () interface, but it brings a display bug. The phenomenon is that the activity window is not displayed after keyguard is hidden. The launcher interface is first seen before the target activity window is displayed.

Cause analysis:

5.0 triggered the call of ActivityStackSupervisor. policyactivitydrawnforkeyguard () in advance.

Solution:

Comment out the call to the policyactivitydrawnforkeyguard () function in the ActivityStack. completeResumeLocked () function.

Frameworks \ base \ services \ java \ com \ android \ server \ am \ ActivityStack. java

Private void completeResumeLocked (ActivityRecord next) {next. idle = false; next. results = null; next. newIntents = null; if (next. isHomeActivity () & next. isNotResolverActivity () {ProcessRecord app = next. task. mActivities. get (0 ). app; if (app! = Null & app! = MService. mHomeProcess) {mService. mHomeProcess = app;} if (next. nowVisible) {// We won't get a call to reportActivityVisibleLocked () so dismiss lockscreen now. // mStackSupervisor. notifyActivityDrawnForKeyguard (); // comment out}

2. bug2

Symptom:

A parent window has two subwindows, And the type of the subwindows are the same. The two subwindows are added in the sequence before and after they are displayed. When both subwindows are displayed simultaneously, press the home Key to enter the background, start the application from the desktop and you will find that the two subwindows are opposite to the upper and lower positions.

Cause analysis:

There are two reasons: one is that the type of the subwindow should not be consistent, and the other is that the logic of WindowManagerService is not sound when the type of the two subwindows is consistent.

Solution:

Method 1: change the type of two subwindows;

Method 2: Add logic in the window for modifying the child of the WindowState constructor;

Frameworks \ base \ services \ java \ com \ android \ server \ am \ WindowState. java

    WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,           WindowState attachedWindow, int appOp, int seq, WindowManager.LayoutParams a,           int viewVisibility, final DisplayContent displayContent) {            ..............            if (children_size == 0) {                mAttachedWindow.mChildWindows.add(this);            } else {                for (int i = 0; i < children_size; i++) {                    WindowState child = (WindowState)mAttachedWindow.mChildWindows.get(i);                    if (this.mSubLayer < child.mSubLayer) {                        mAttachedWindow.mChildWindows.add(i, this);                        break;                    } else if (this.mSubLayer > child.mSubLayer) {                        continue;                    }                    if (this.mBaseLayer <= child.mBaseLayer) {                        mAttachedWindow.mChildWindows.add(i, this);                        break;                    } else {                        continue;                    }                }                if (children_size == mAttachedWindow.mChildWindows.size()) {                    mAttachedWindow.mChildWindows.add(this);                }            }         ..........}

3. bug3

Symptom:

Intent. FLAG_ACTIVITY_REORDER_TO_FRONT flag is added during the jump between the two activities. After A --> B --> A jumps, press the back key, which will cause launcher ANR.

Cause analysis:

Add Intent. after FLAG_ACTIVITY_REORDER_TO_FRONT performs A --> B --> A jump, because the focused activity is not updated to A, the focused window in WMS is null, if the focused window cannot be found for key event reporting, the key event cannot be distributed, resulting in launcher ANR.

Solution:

In the ActivityStackSupervisor. startActivityUncheckedLocked () function, add the mService. setFocusedActivityLocked (targetStack. topRunningActivityLocked (null); statement.
Frameworks/base/services/java/com/android/server/am/ActivityStackSupervisor. java

Final int startActivityUncheckedLocked (ActivityRecord r, ActivityRecord sourceRecord, int startFlags, boolean doResume, Bundle options) {...... else if (! AddingToTask & (launchFlags & Intent. FLAG_ACTIVITY_REORDER_TO_FRONT )! = 0) {// In this case, we are launching an activity in our own task // that may already be running somewhere in the history, and // we want to shuffle it to the front of the stack if so. final ActivityRecord top = sourceTask. findActivityInHistoryLocked (r); if (top! = Null) {final TaskRecord task = top. task. moveActivityToFrontLocked (top); ActivityStack. logStartActivity (EventLogTags. AM_NEW_INTENT, r, task); top. updateOptionsLocked (options); top. deliverNewIntentLocked (callingUid, r. intent); targetStack. mLastPausedActivity = null; if (doResume) {targetStack. resumeTopActivityLocked (null); mService. setFocusedActivityLocked (targetStack. topRunningActivityLocked (null); // Add the statement;} return ActivityManager. START_DELIVERED_TO_TOP ;}}..........}

To be continued.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.