Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use curtains to get phone window from decor view
Summary: The official api only let you access this window by going through a views activity, but if a doesn't belong to an activity there is no possible way without reflection tricks. Curtains is a nice library that does this reflection adn a lot of the other reflection hacks that the UIdebugger needs. ## The reason this is important When snapshotting a dialog fragment we were using pixel copy using tryCopyViaInternalSurface approach. The issue is this is the lowest level api and doesnt consider 'surface insets' Surface insets seems to be related to the fact that a surface may be bigger than the content it draws. This ended up manifesting like this {F1372530065} the issue is we create a bitmap sized to the decor view, but we were snapshotting the whole surface which is actually a bit bigger due to the black bars / surface insets. When you pass a android.view.Window to pixel copy it has code to account for the surface insets. https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/graphics/java/android/view/PixelCopy.java;l=291;drc=228276a74bc36e8c0f0fadbb4a15ef013ff6ce24 Before we couldn't pass a window for dialogs since there was no activity to provide it, now curtains gives us this window and we can use the high level api in pxiel copy that does the right thing w.r.t surface insets Reviewed By: passy Differential Revision: D53090570 fbshipit-source-id: 969695198cfa5b848238e734d6ddec29681930e5
- Loading branch information