Skip to content

Commit

Permalink
Update shared libs up to SDK 25. However, even though SDK 25 builds, it
Browse files Browse the repository at this point in the history
does not run on a Nexus 5X with 7.1 Developer Preview due to a symbol
mismatch. Unclear whether the developer preview is botched or not, there
are certainly other less than complete things as well.
  • Loading branch information
sorccu committed Oct 22, 2016
1 parent 251fa98 commit cac981f
Show file tree
Hide file tree
Showing 20 changed files with 936 additions and 63 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Minicap provides a socket interface for streaming realtime screen capture data out of Android devices. It is meant to be used as a component in a larger program and is therefore not immensely useful just by itself. For example, it is being used in [STF](https://github.com/openstf/stf) for remote control.

Minicap works without root if started via [ADB](http://developer.android.com/tools/help/adb.html) on SDK 22 and lower, as well as on Android M Developer Preview 3. The lowest SDK level we build for is 9 (i.e. Android 2.3). Minicap also works on Android Wear. Emulators, however, are not supported.
Minicap works without root if started via [ADB](http://developer.android.com/tools/help/adb.html) on SDK 25 (Android 7.1) and lower. The lowest SDK level we build for is 9 (i.e. Android 2.3). Minicap also works on Android Wear. Emulators, however, are not supported. Note that Android 3.x is not supported since those versions were never open sourced.

To capture the screen we currently use two methods. For older Android versions we use the ScreenshotClient, a private API in AOSP. For newer versions we use a virtual display, which also requires access to private APIs. The frames are then encoded using SIMD-enabled [libjpeg-turbo](http://libjpeg-turbo.virtualgl.org/) and sent over a socket interface. A planned future improvement to allow for even higher FPS is to use MediaRecorder and friends to take advantage of hardware encoding.

Expand Down
16 changes: 4 additions & 12 deletions build-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,20 @@

set -xueo pipefail

TARGET=/tmp/minicap
builder=$1

rsync \
--rsync-path='nice rsync' \
--recursive \
--copy-links \
--perms \
--times \
-FF ./jni/minicap-shared/aosp/ "$BUILD_HOST":$TARGET
-FF ./jni/minicap-shared/aosp/ "$builder":minicap/

ssh -T "$BUILD_HOST" "docker run --rm \
-a stdout -a stderr \
-v $TARGET:$TARGET \
-v \$(which docker):\$(which docker) \
-v /usr/lib:/usr/lib \
-v /var/run/docker.sock:/var/run/docker.sock \
openstf/aosp:jdk7 bash -c 'cd $TARGET && make -j 1'"
ssh -T "$builder" "cd minicap && make -j 1"

rsync \
--rsync-path='nice rsync' \
--recursive \
--copy-links \
--perms \
--times \
"$BUILD_HOST":$TARGET/libs/ ./jni/minicap-shared/aosp/libs/
"$builder":minicap/libs/ ./jni/minicap-shared/aosp/libs/
42 changes: 33 additions & 9 deletions jni/minicap-shared/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Using this setup, the minimum server-side machine requirements are:
* [docker](https://www.docker.com/)
* [SSH](http://www.openssh.com/)
* A user account with SSH public key authentication and sudo-less access to docker
* Approximately 20GB of disk space per checked out branch, and approximately 60GB for a full mirror. We'll get to the branches later. We recommend a 512GB SSD, possibly more if you wish to compile other things as well (i.e. not just minicap).
* Depending on the SDK version, 25-60GB of disk space per built branch, and approximately 120GB for a full mirror. We'll get to the branches later. We recommend a 1TB SSD, possibly more if you wish to compile other things as well (i.e. not just minicap). With branch and mirror sizes ever growing, 512GB will soon not be enough, so don't bother if you want to keep everything on one disk.

You'll also need [rsync](https://rsync.samba.org/) and [SSH](http://www.openssh.com/) properly set up on your development machine.

Expand Down Expand Up @@ -50,11 +50,13 @@ Currently the following branches are required to build the libraries for all sup
| android-4.4_r1 | 19 | openstf/aosp:jdk6 |
| android-5.0.1_r1 | 21 | openstf/aosp:jdk7 |
| android-5.1.0_r1 | 22 | openstf/aosp:jdk7 |
| android-m-preview-2 | 23 | openstf/aosp:jdk7 |
| android-6.0.0_r1 | 23 | openstf/aosp:jdk7 |
| android-7.0.0_r1 | 24 | openstf/aosp:jdk8 |
| android-7.1.0_r1 | 25 | openstf/aosp:jdk8 |

Furthermore, to make use of our provided Makefile, you should check out the branches to `/srv/aosp` for maximum ease of use.
Furthermore, to make use of our provided Makefile, you should check out the branches to `/media/aosp` for maximum ease of use.

To check out the branches, you have two options. To reduce download time and avoid bandwidth caps (on the server side), it would be advisable to fetch a full local mirror and then checkout out the individual branches from there. What tends to happen, though, is that the mirror manifest does not get updated quickly enough for new branches, and may be missing a repository or two, making it practically impossible to check out the branch you want. Additionally, the mirror takes over 50GB of disk space in addition to the checkouts.
To check out the branches, you have two options. To reduce download time and avoid bandwidth caps (on the server side), it would be advisable to fetch a full local mirror and then checkout out the individual branches from there. What tends to happen, though, is that the mirror manifest does not get updated quickly enough for new branches, and may be missing a repository or two, making it practically impossible to check out the branch you want. Additionally, the mirror takes over 120GB of disk space in addition to the checkouts.

You can also skip the mirror and download each branch directly, but that will stress the AOSP server unnecessarily.

Expand Down Expand Up @@ -89,15 +91,15 @@ Now that we're a bit more familiar with the helper script, let's start fetching

```bash
docker run -ti --rm \
-v /srv/aosp/mirror:/mirror \
-v /media/aosp/mirror:/mirror \
-v $PWD/.gitcookies:/root/.gitcookies:ro \
openstf/aosp:jdk7 \
/aosp.sh create-mirror
```

This will take a LONG time, easily several hours. You may wish to leave it running overnight. If an error occurs (it will tell you), run the same command again and again until it finishes without errors.

When the command is done, you should have a copy of the latest mirror in `/srv/aosp/mirror`. We will mount this mirror when checking out individual branches.
When the command is done, you should have a copy of the latest mirror in `/media/aosp/mirror`. We will mount this mirror when checking out individual branches.

You should rerun the command whenever a new branch you're interested in gets added to AOSP to sync the mirrored repos.

Expand All @@ -109,8 +111,8 @@ For each branch in the table, run the following command:

```bash
docker run -ti --rm \
-v /srv/aosp/mirror:/mirror \
-v /srv/aosp/android-5.1.0_r1:/aosp \
-v /media/aosp/mirror:/mirror \
-v /media/aosp/android-5.1.0_r1:/aosp \
-v $PWD/.gitcookies:/root/.gitcookies:ro \
openstf/aosp:jdk7 \
/aosp.sh checkout-branch android-5.1.0_r1
Expand All @@ -128,7 +130,7 @@ For each branch you wish to download directly from the AOSP servers, run the fol

```bash
docker run -ti --rm \
-v /srv/aosp/android-5.1.0_r1:/aosp \
-v /media/aosp/android-5.1.0_r1:/aosp \
-v $PWD/.gitcookies:/root/.gitcookies:ro \
openstf/aosp:jdk7 \
/aosp.sh checkout-branch --no-mirror android-5.1.0_r1
Expand Down Expand Up @@ -175,3 +177,25 @@ Our advice? Be damn sure your code compiles before actually compiling :)
Alternatively, you may wish to temporarily remove other targets from the `Makefile` all target when working on bigger changes but focusing on a single branch.

In any case, congratulations, you're done!

### Tips

Here's a systemd unit to keep an external disk mounted in `/media/aosp`. It assumes you have a btrfs-formatted partition labeled `AOSP` on a disk somewhere, mine's on an external SSD. Example of how to create one:

```sh
mkfs.btrfs -L AOSP /dev/sdc1
```

And here's the corresponding unit:

```systemd
[Mount]
What=/dev/disk/by-label/AOSP
Where=/media/aosp
Type=btrfs
[Install]
WantedBy=multi-user.target
```

Now just run `systemctl enable media-aosp.mount && systemctl start media-aosp.mount`.
6 changes: 4 additions & 2 deletions jni/minicap-shared/aosp/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ LOCAL_MODULE := minicap

LOCAL_MODULE_TAGS := optional

ifeq ($(OVERRIDE_PLATFORM_SDK_VERSION),23)
LOCAL_SRC_FILES += src/minicap_23.cpp
ifeq ($(PLATFORM_SDK_VERSION),25)
LOCAL_SRC_FILES += src/minicap_25.cpp
else ifeq ($(PLATFORM_SDK_VERSION),24)
LOCAL_SRC_FILES += src/minicap_24.cpp
else ifeq ($(PLATFORM_SDK_VERSION),23)
LOCAL_SRC_FILES += src/minicap_23.cpp
else ifeq ($(PLATFORM_SDK_VERSION),22)
Expand Down
Loading

0 comments on commit cac981f

Please sign in to comment.