Previously, I asked a question on frame for different rotation. You suggested restart the minicap server when rotation is changed.
I am wondering whether there is a way to keep frame always align for one rotation, like landscape, even for portrait app or landscape app. What I saw is the frame is just half for portrait app when the desired rotation of starting minicap server is 90 degree; however, it shows correctly for landscape apps.
First of all, if you're only getting half-sized frames, you're probably giving the parameters incorrectly. Both portrait and landscape images should be full size, although obviously they're landscape and portrait, so you'll actually get something like 720x1280 for portrait mode, and 1280x720 for landscape mode (as long as you restart minicap with the correct parameters).
For locking the orientation, please look at the STF codebase, most of the things you have asked so far have been solved there. If you want to lock rotation, you can use public Android APIs to do that, but have to run the app as the shell user because of permission issues. See here for an example.
Alternatively you should be able to lock the rotation by operating the device manually. Might be OK if you're willing to do that once?
Also, not all views support multiple orientations.
Thanks for your answers. Let me explain the question more clearly. I hope to start minicap server only once, keep landscape mode, frame width 1280 and height 720. For landscape app, it is ok and the frame is normal; while for portrait app, it is half-sized (the 90 degree rotated frame is also accepted). I don't want to lock the orientation since some apps may require it.
I really don't think that's possible with the APIs minicap has access to. SurfaceFlinger unfortunately auto-rotates the frame so that it's always upright. When I made minicap I tried to work around that but was not able to find a way. There are some rotation-related flags that you can use when retrieving a frame, however they appear not to work. Restarting minicap is the only way that works reliably on all devices. Please let me know if you find a way, though.
I also tried screenrecord. The difference is screencap can show the full image, for portrait at beginning and landscape after rotation; however, minicap does not show the full image when starting orientation is changed.
from my understanding, you have to monitor the orientation change and do minicap restart. It seems a heavy operation due to monitoring overhead. In practice, on-demand orientation can decide whether to rotate the image and minicap always show the image at start orientation (no matter orientation change), which is better solution. What do you think?
It's not possible to do it without breaking devices. On at least 4.4 and 5.0, calling the only API that's able to return the current size and orientation to you segfaults on practically every Samsung device because they've customized the DisplayInfo struct. You can test with the -i flag to see what happens on your device.
Also, watching the rotation is not a heavy operation. There's another semi-private API on the Java side called RotationWatcher that simply gets notified when the rotation changes. It's not like it's doing polling.
Screenrecord can access every API more reliably since it's the manufacturer building it with the full modified source code. I think you'll find that if you copy the screenrecord binary from a Nexus to a Galaxy device running the same version of Android, it simply won't work.
Activity
sorccu commentedon Aug 22, 2016
First of all, if you're only getting half-sized frames, you're probably giving the parameters incorrectly. Both portrait and landscape images should be full size, although obviously they're landscape and portrait, so you'll actually get something like 720x1280 for portrait mode, and 1280x720 for landscape mode (as long as you restart minicap with the correct parameters).
For locking the orientation, please look at the STF codebase, most of the things you have asked so far have been solved there. If you want to lock rotation, you can use public Android APIs to do that, but have to run the app as the shell user because of permission issues. See here for an example.
Alternatively you should be able to lock the rotation by operating the device manually. Might be OK if you're willing to do that once?
Also, not all views support multiple orientations.
Anyway minicap by itself cannot do it.
haihaoshen commentedon Aug 22, 2016
Thanks for your answers. Let me explain the question more clearly. I hope to start minicap server only once, keep landscape mode, frame width 1280 and height 720. For landscape app, it is ok and the frame is normal; while for portrait app, it is half-sized (the 90 degree rotated frame is also accepted). I don't want to lock the orientation since some apps may require it.
sorccu commentedon Aug 22, 2016
I really don't think that's possible with the APIs minicap has access to. SurfaceFlinger unfortunately auto-rotates the frame so that it's always upright. When I made minicap I tried to work around that but was not able to find a way. There are some rotation-related flags that you can use when retrieving a frame, however they appear not to work. Restarting minicap is the only way that works reliably on all devices. Please let me know if you find a way, though.
harrycrossincode commentedon Aug 25, 2016
I found Android screenrecord can always make the image upright. (no need to restart it several times).
sorccu commentedon Aug 25, 2016
Yeah? The image being upright is the issue.
haihaoshen commentedon Aug 26, 2016
I also tried screenrecord. The difference is screencap can show the full image, for portrait at beginning and landscape after rotation; however, minicap does not show the full image when starting orientation is changed.
sorccu commentedon Aug 26, 2016
minicapcan show you the full image after you restart it. Is it really such a big issue that you have to restart it?haihaoshen commentedon Aug 26, 2016
from my understanding, you have to monitor the orientation change and do minicap restart. It seems a heavy operation due to monitoring overhead. In practice, on-demand orientation can decide whether to rotate the image and minicap always show the image at start orientation (no matter orientation change), which is better solution. What do you think?
sorccu commentedon Aug 26, 2016
It's not possible to do it without breaking devices. On at least 4.4 and 5.0, calling the only API that's able to return the current size and orientation to you segfaults on practically every Samsung device because they've customized the DisplayInfo struct. You can test with the
-iflag to see what happens on your device.Also, watching the rotation is not a heavy operation. There's another semi-private API on the Java side called RotationWatcher that simply gets notified when the rotation changes. It's not like it's doing polling.
Screenrecord can access every API more reliably since it's the manufacturer building it with the full modified source code. I think you'll find that if you copy the screenrecord binary from a Nexus to a Galaxy device running the same version of Android, it simply won't work.
haihaoshen commentedon Aug 26, 2016
Could you please pinpoint the code to RotationWatcher ?
sorccu commentedon Aug 26, 2016
There's a link in the README.