Skip to content

Commit

Permalink
Merge pull request #70 from toshi38/stelau/windowmanager
Browse files Browse the repository at this point in the history
Stelau/windowmanager
  • Loading branch information
edsj-sony authored Jan 30, 2020
2 parents 9fdd65b + cc5dc7a commit 2e8ff7b
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 40 deletions.
4 changes: 2 additions & 2 deletions core/src/com/sonyericsson/chkbugreport/Section.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class Section extends Lines {
public static final String DUMP_OF_SERVICE_BATTERYSTATS = "DUMP OF SERVICE batterystats";
public static final String DUMP_OF_SERVICE_MEMINFO = "DUMP OF SERVICE HIGH meminfo";
public static final String DUMP_OF_SERVICE_PACKAGE = "DUMP OF SERVICE package";
public static final String DUMP_OF_SERVICE_SURFACEFLINGER = "DUMP OF SERVICE SurfaceFlinger";
public static final String DUMP_OF_SERVICE_WINDOW = "DUMP OF SERVICE window";
public static final String DUMP_OF_SERVICE_SURFACEFLINGER = "DUMP OF SERVICE CRITICAL SurfaceFlinger";
public static final String DUMP_OF_SERVICE_WINDOW = "DUMP OF SERVICE CRITICAL window";
public static final String DUMPSYS = "DUMPSYS";
public static final String EVENT_LOG = "EVENT LOG";
public static final String FILESYSTEMS_AND_FREE_SPACE = "FILESYSTEMS & FREE SPACE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,15 @@ private boolean loadWindowManagerState(Module br, DumpTree dump) {
line = propNode.getLine();
// If we got here, we need to append more properties to the window
if (line.startsWith("mAttrs=")) {
parseWindowAttr(win, Util.extract(line, "{", "}"));
//Fixme: This actually needs to be capable of multi-line parsing:
parseWindowAttr(win, Util.extract(line, "{", "}\n"));
} else if (line.startsWith("mSurface=")) {
String descr = Util.extract(line, "(", ")");
win.surfaceId = Util.extract(descr, "identity=", " ");
} else if (line.startsWith("mViewVisibility=")) {
win.visibity = Util.parseHex(Util.extract(line, "mViewVisibility=", " "), 0);
} else if (line.startsWith("mBaseLayer=")) {
String value = Util.extract(line, "mAnimLayer=", " ");
value = Util.extract(value, "=", " ");
win.animLayer = Util.parseInt(value, 0);
//Fixme: Handle "mSubLayer="
} else if (line.startsWith("mAttachedWindow=")) {
String descr = Util.extract(line, "{", "}");
int idx = descr.indexOf(' ');
Expand Down Expand Up @@ -236,7 +235,7 @@ private void parseWindowAttr(Window win, String attrs) {
} else if (s.startsWith("or=")) {
win.or = Util.parseInt(Util.extract(attrs, "or=", " "), 0);
} else if (s.startsWith("fmt=")) {
win.fmt = Util.parseInt(Util.extract(attrs, "fmt=", " "), 0);
win.fmt = Util.extract(attrs, "fmt=", " ");
}
}
}
Expand All @@ -259,7 +258,6 @@ public void generateWindowList(Module br, Chapter mainCh) {

// Check for possible errors
checkDuplicatedWindows(br, mainCh, anchor);
checkWrongOrder(br, mainCh, anchor);

// Generate window list (for now)
new Hint(ch).add("Under construction");
Expand Down Expand Up @@ -356,35 +354,6 @@ private void checkDuplicatedWindows(Module br, Chapter mainCh, String anchor) {
}
}

private void checkWrongOrder(Module br, Chapter mainCh, String anchor) {
// Check for possible errors based on the window list (like duplicate windows)
Bug bug = null;
List bugList = null;
int lastLayer = -1;
for (WindowManagerState.Window win : mWindowManagerState.windows) {
if (lastLayer != -1) {
if (lastLayer < win.animLayer) {
// Create the bug if needed
if (bug == null) {
bug = new Bug(Bug.Type.PHONE_ERR, Bug.PRIO_WRONG_WINDOW_ORDER, 0, "Wrong window order");
new Para(bug)
.addln("The order of the windows does not match their layers!")
.addln("When this happens, the user might see one window on top, but interact with another one.")
.addln("The following windows are placed incorrectly (too low):");
bugList = new List(List.TYPE_UNORDERED, bug);
}
bugList.add(win.name + " (" + win.animLayer + " > " + lastLayer + ")");
win.warnings++;
}
}
lastLayer = win.animLayer;
}
if (bug != null) {
bug.add(new Link(mainCh.getAnchor(), "(Link to window list)"));
br.addBug(bug);
}
}

static class WindowCount {
String name;
int count;
Expand Down Expand Up @@ -416,15 +385,13 @@ static class Window {
public int parentId;
public int visibity;
public String surfaceId;
public int fmt;
public String fmt;
public int or;
public int flags;
public boolean paused;
public String name;
public int id;
public int num;
public int animLayer;

}

public Vector<Window> windows = new Vector<Window>();
Expand Down
14 changes: 14 additions & 0 deletions core/test/TestSection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import com.sonyericsson.chkbugreport.Module;
import com.sonyericsson.chkbugreport.Section;

public class TestSection extends Section {
TestSection(Module module, String sectionName) {
super(module, sectionName);
}

void setTestLines(String lines) {
for(String line: lines.split("\n")) {
addLine(line);
}
}
}
111 changes: 111 additions & 0 deletions core/test/WindowManagerPluginTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import com.sonyericsson.chkbugreport.BugReportModule;
import com.sonyericsson.chkbugreport.Section;
import com.sonyericsson.chkbugreport.plugins.WindowManagerPlugin;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertNotEquals;
import static org.mockito.Mockito.*;

public class WindowManagerPluginTest {
private static final String WINDOW_DATA = " Window #0 Window{fd184e8 u0 InputMethod}:\n" +
" mDisplayId=0 stackId=0 mSession=Session{ce80bcd 23447:u0a10205} mClient=android.os.BinderProxy@aca0e0b\n" +
" mOwnerUid=10205 mShowToOwnerOnly=true package=com.sonymobile.pobox appop=NONE\n" +
" mAttrs={(0,0)(fillxwrap) gr=BOTTOM CENTER_VERTICAL sim={adjust=pan} ty=INPUT_METHOD fmt=TRANSPARENT wanim=0x1030056\n" +
" fl=NOT_FOCUSABLE LAYOUT_IN_SCREEN SPLIT_TOUCH HARDWARE_ACCELERATED DRAWS_SYSTEM_BAR_BACKGROUNDS}\n" +
" Requested w=2160 h=1008 mLayoutSeq=11766\n" +
" mIsImWindow=true mIsWallpaper=false mIsFloatingLayer=true mWallpaperVisible=false\n" +
" mBaseLayer=151000 mSubLayer=0 mToken=WindowToken{fa9b9bf android.os.Binder@4f743de}\n" +
" mViewVisibility=0x8 mHaveFrame=true mObscured=false\n" +
" mSeq=0 mSystemUiVisibility=0x0\n" +
" mPolicyVisibility=false mLegacyPolicyVisibilityAfterAnim=false mAppOpVisibility=true parentHidden=false mPermanentlyHidden=false mHiddenWhileSuspended=false mForceHideNonSystemOverlayWindow=false\n" +
" mGivenContentInsets=[0,0][0,0] mGivenVisibleInsets=[0,0][0,0]\n" +
" mTouchableInsets=2 mGivenInsetsPending=false\n" +
" touchable region=SkRegion((0,72,2016,1080))\n" +
" mFullConfiguration={1.15 440mcc10mnc [ja_JP,en_US] ldltr sw360dp w360dp h648dp 480dpi nrml long hdr widecg port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 2160) mAppBounds=Rect(0, 0 - 1080, 2016) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.9622}\n" +
" mLastReportedConfiguration={1.15 440mcc10mnc [ja_JP,en_US] ldltr sw360dp w672dp h336dp 480dpi nrml long hdr widecg land finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 2160, 1080) mAppBounds=Rect(0, 0 - 2016, 1080) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_90} s.9526}\n" +
" mHasSurface=false isReadyForDisplay()=false mWindowRemovalAllowed=false\n" +
" Frames: containing=[0,72][2016,1080] parent=[0,72][2016,1080]\n" +
" display=[0,72][2016,1080] overscan=[0,72][2016,1080]\n" +
" content=[0,72][2016,1080] visible=[0,72][2016,1080]\n" +
" decor=[0,0][0,0]\n" +
" outset=[0,0][0,0]\n" +
" mFrame=[0,72][2016,1080] last=[0,72][2016,1080]\n" +
" cutout=DisplayCutout{insets=Rect(0, 0 - 0, 0) boundingRect={Bounds=[Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0)]}} last=DisplayCutout{insets=Rect(0, 0 - 0, 0) boundingRect={Bounds=[Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0)]}}\n" +
" Cur insets: overscan=[0,0][0,0] content=[0,0][0,0] visible=[0,0][0,0] stable=[0,0][0,0] outsets=[0,0][0,0] Lst insets: overscan=[0,0][0,0] content=[0,0][0,0] visible=[0,0][0,0] stable=[0,0][0,0] outset=[0,0][0,0]\n" +
" surface=[0,0][0,0]\n" +
" WindowStateAnimator{b21b80f InputMethod}:\n" +
" mDrawState=NO_SURFACE mLastHidden=true\n" +
" mSystemDecorRect=[0,0][2016,1008] mLastClipRect=[0,0][2016,1008]\n" +
" mOrientationChanging=false configOrientationChanging=true mAppFreezing=false mReportOrientationChanged=true\n" +
" mForceSeamlesslyRotate=false seamlesslyRotate: pending=null finishedFrameNumber=0\n" +
" isOnScreen=false\n" +
" isVisible=false\n" +
" Window #1 Window{32ea425 u0 NavigationBar0}:\n" +
" mDisplayId=0 stackId=0 mSession=Session{aaeba49 29108:u0a10099} mClient=android.os.BinderProxy@61cca69\n" +
" mOwnerUid=10099 mShowToOwnerOnly=false package=com.android.systemui appop=NONE\n" +
" mAttrs={(0,0)(fillxfill) sim={adjust=pan} ty=NAVIGATION_BAR fmt=TRANSLUCENT\n" +
" fl=NOT_FOCUSABLE NOT_TOUCH_MODAL TOUCHABLE_WHEN_WAKING WATCH_OUTSIDE_TOUCH SPLIT_TOUCH HARDWARE_ACCELERATED FLAG_SLIPPERY\n" +
" pfl=COLOR_SPACE_AGNOSTIC}\n" +
" Requested w=1080 h=2160 mLayoutSeq=11936\n" +
" mBaseLayer=231000 mSubLayer=0 mToken=WindowToken{6245cee android.os.BinderProxy@782e4f0}\n" +
" mViewVisibility=0x0 mHaveFrame=true mObscured=false\n" +
" mSeq=0 mSystemUiVisibility=0x0\n" +
" mGivenContentInsets=[0,0][0,0] mGivenVisibleInsets=[0,0][0,0]\n" +
" mFullConfiguration={1.15 440mcc10mnc [ja_JP,en_US] ldltr sw360dp w360dp h648dp 480dpi nrml long hdr widecg port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 2160) mAppBounds=Rect(0, 0 - 1080, 2016) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.9622}\n" +
" mLastReportedConfiguration={1.15 440mcc10mnc [ja_JP,en_US] ldltr sw360dp w360dp h648dp 480dpi nrml long hdr widecg port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 2160) mAppBounds=Rect(0, 0 - 1080, 2016) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.9622}\n" +
" mHasSurface=true isReadyForDisplay()=true mWindowRemovalAllowed=false\n" +
" Frames: containing=[0,2016][1080,2160] parent=[0,2016][1080,2160]\n" +
" display=[0,2016][1080,2160] overscan=[0,2016][1080,2160]\n" +
" content=[0,2016][1080,2160] visible=[0,2016][1080,2160]\n" +
" decor=[0,0][0,0]\n" +
" outset=[-2147483648,-2147483648][2147483647,2147483647]\n" +
" mFrame=[0,2016][1080,2160] last=[0,2016][1080,2160]\n" +
" cutout=DisplayCutout{insets=Rect(0, 0 - 0, 0) boundingRect={Bounds=[Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0)]}} last=DisplayCutout{insets=Rect(0, 0 - 0, 0) boundingRect={Bounds=[Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0)]}}\n" +
" Cur insets: overscan=[0,0][0,0] content=[0,0][0,0] visible=[0,0][0,0] stable=[0,0][0,0] outsets=[0,0][0,0] Lst insets: overscan=[0,0][0,0] content=[0,0][0,0] visible=[0,0][0,0] stable=[0,0][0,0] outset=[0,0][0,0]\n" +
" surface=[0,0][0,0]\n" +
" WindowStateAnimator{992096e NavigationBar0}:\n" +
" mSurface=Surface(name=NavigationBar0)/@0x55c3c21\n" +
" Surface: shown=true layer=0 alpha=1.0 rect=(0.0,0.0) 1080 x 144 transform=(1.0, 0.0, 1.0, 0.0)\n" +
" mDrawState=HAS_DRAWN mLastHidden=false\n" +
" mSystemDecorRect=[0,0][1080,144] mLastClipRect=[0,0][1080,144]\n" +
" mLastFreezeDuration=+1h50m56s282ms\n" +
" mForceSeamlesslyRotate=false seamlesslyRotate: pending=null finishedFrameNumber=0\n" +
" isOnScreen=true\n" +
" isVisible=true";


WindowManagerPlugin spySut;
BugReportModule mockBugReport;
TestSection fakeWindowsSection;

@Before
public void setup() {
WindowManagerPlugin sut = new WindowManagerPlugin();
spySut = spy(sut);

Section mockWindowSection = mock(Section.class);
mockBugReport = mock(BugReportModule.class);
fakeWindowsSection = new TestSection(mockBugReport, Section.WINDOW_MANAGER_WINDOWS);
fakeWindowsSection.clear();
when(mockBugReport.findSection(Section.DUMP_OF_SERVICE_WINDOW)).thenReturn(mockWindowSection);
when(mockBugReport.findSection(Section.WINDOW_MANAGER_WINDOWS)).thenReturn(fakeWindowsSection);
}

@Test
public void instantiates() {
assertNotEquals(null, spySut);
}

@Test
public void parsesWindows() {
fakeWindowsSection.setTestLines(WINDOW_DATA);
spySut.load(mockBugReport);
verify(mockBugReport, never()).addBug(any());
verify(mockBugReport, never()).printErr(anyInt(), contains(Section.DUMP_OF_SERVICE_WINDOW));
verify(mockBugReport, never()).printErr(anyInt(), contains(Section.WINDOW_MANAGER_WINDOWS));

spySut.generate(mockBugReport);
verify(spySut).generateWindowList(any(), any());
}
}

0 comments on commit 2e8ff7b

Please sign in to comment.