diff --git a/airtest/core/android/static/maxpresent.jar b/airtest/core/android/static/apks/maxpresent.jar similarity index 92% rename from airtest/core/android/static/maxpresent.jar rename to airtest/core/android/static/apks/maxpresent.jar index 036c8703..57e8c08f 100644 Binary files a/airtest/core/android/static/maxpresent.jar and b/airtest/core/android/static/apks/maxpresent.jar differ diff --git a/airtest/core/android/static/stf_libs/minicap-shared/Android.mk b/airtest/core/android/static/stf_libs/minicap-shared/Android.mk deleted file mode 100644 index b6ca39bf..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/Android.mk +++ /dev/null @@ -1,17 +0,0 @@ -LOCAL_PATH := $(abspath $(call my-dir)) -include $(CLEAR_VARS) - -LOCAL_MODULE := minicap-shared - -LOCAL_MODULE_FILENAME := minicap - -LOCAL_SRC_FILES := \ - mock/Minicap.cpp \ - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/aosp/include \ - -LOCAL_EXPORT_C_INCLUDES := \ - $(LOCAL_PATH)/aosp/include \ - -include $(BUILD_SHARED_LIBRARY) diff --git a/airtest/core/android/static/stf_libs/minicap-shared/README.md b/airtest/core/android/static/stf_libs/minicap-shared/README.md deleted file mode 100644 index 19fa0ac3..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/README.md +++ /dev/null @@ -1,205 +0,0 @@ -# minicap-shared - -This module provides the shared library used by minicap. Due to the use of private APIs, it must be built inside the AOSP source tree for each SDK level and architecture. We commit and ship prebuilt libraries inside the source tree for convenience purposes, as getting them compiled can be a major obstacle. The rest of this README assumes that you wish to compile the libraries by yourself, possibly due to trust issues and/or modifications. - -## Requirements - -There are several ways to set everything up and build the libraries, so we'll just cover the way we've done it. You may adjust the process however you want, but don't expect us to hold your hand if something goes wrong. Overall getting everything set up takes a considerable amount of time, with moderate skill requirements as well. It would be best if you follow the guide unless you're very confident you can do it. - -### Operating system - -Let's start by saying that **compiling under OS X will not work**. AOSP requires a case-sensitive file system. Furthermore, different branches of the AOSP source tree require different versions of Xcode and JDK, making the process nearly impossible. Try if you're crazy. - -What we use is Linux, latest stable CoreOS to be precise. Our process relies on Docker containers to do the actual compile. The source code is copied via rsync to the Linux machine and then compiled. Any artifacts are transmitted back and added to our source tree so that normal people will not have to go through the whole process. - -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 -* 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. - -### Docker images - -Pull the required docker images on the build server as follows: - -```bash -docker pull openstf/aosp:jdk6 -docker pull openstf/aosp:jdk7 -docker pull openstf/aosp:jdk8 -``` - -These images will be used to both check out code as well as to compile it. - -**A note about security:** containers created from these images currently run under the root user by default. If this is not acceptable to you, you will need to modify the `Makefile` and most of the commands below as you see fit. - -### AOSP branches - -Currently the following branches are required to build the libraries for all supported SDK levels and architectures: - -| Branch | SDK | Docker image to build with | -|---------------------|-----|-------------------------------| -| android-2.3_r1 | 9 | openstf/aosp:jdk6 | -| android-2.3.3_r1 | 10 | openstf/aosp:jdk6 | -| android-4.0.1_r1 | 14 | openstf/aosp:jdk6 | -| android-4.0.3_r1 | 15 | openstf/aosp:jdk6 | -| android-4.1.1_r1 | 16 | openstf/aosp:jdk6 | -| android-4.2_r1 | 17 | openstf/aosp:jdk6 | -| android-4.3_r1 | 18 | openstf/aosp:jdk6 | -| 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-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 | -| android-8.0.0_r1 | 26 | openstf/aosp:jdk8 | -| android-8.1.0_r1 | 27 | openstf/aosp:jdk8 | -| android-9.0.0_r1 | 28 | openstf/aosp:jdk8 | - -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 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. - -Our recommended solution is to use a mirror and use it for all the branches you can, and if a branch fails due to a missing repo, then checkout that branch directly from the server. - -### AOSP authentication - -AOSP has fairly recently introduced heavy bandwidth caps on their repos. You may have to authenticate yourself [as explained](https://source.android.com/source/downloading.html#using-authentication) by the download guide. Use the link in the guide to get your `.gitcookies` file. - -You'll need to put the file on your build machine. It needs to have correct permissions (i.e. `0600`) and belong to the user checking out the code. Since our process uses the root user inside the containers, make sure to set the owner and group as well. - -```bash -chown root:root .gitcookies -chmod 0600 .gitcookies -``` - -Use sudo where required. - -We will later mount this file on our containers when checking out code. Note that if you still run into bandwidth caps you may just have to wait. - -### Get familiar with the checkout/build wrapper script - -There are bundled helper scripts inside the docker images. To see what commands you have available, run the following command. - -```bash -docker run -ti --rm openstf/aosp:jdk7 /aosp.sh help -``` - -### Creating an AOSP mirror - -Now that we're a bit more familiar with the helper script, let's start fetching our mirror. - -```bash -docker run -ti --rm \ - -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 `/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. - -### Check out branches (using mirror) - -We had a table of the needed AOSP branches earlier. The docker image for each SDK level may be different, but it should not make much difference when simply checking out code, so you should be able to use one image to check out all branches. However, if you do run into problems, you may also wish to try using the proper JDK when checking out. Check out the branch table above to see which one to use for each branch. - -For each branch in the table, run the following command: - -```bash -docker run -ti --rm \ - -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 -``` - -Note that the branch name is both in the mounted folder name and an option to the checkout-branch command. You have to replace both when checking out other branches. - -Checking out a single branch should not take that long, perhaps 10-20 minutes per branch. Use a faster disk for better results. - -Should an error occur, you can try running the command again. However, since we're using the mirror, errors shouldn't really happen. Like explained earlier, the mirror may be incomplete. If that's the case, you may have to try a direct download instead, explained next. - -### Check out branches (using direct download) - -For each branch you wish to download directly from the AOSP servers, run the following command: - -```bash -docker run -ti --rm \ - -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 -``` - -Note that the branch name is both in the mounted folder name and an option to the checkout-branch command. You have to replace both when checking out other branches. - -Should an error occur, you can try running the command again. Depending on your luck you may have to run the command several times, and if you hit a bandwidth cap, distribute your downloads over several days. - -Checking out a single branch will easily take a few hours, but it is considerably faster than setting up a full mirror. - -### Saving disk space (optional) - -If you're sure that you'll never need to use the Android `repo` tool on a branch you've already checked out, you can save ~40-50% of disk space by deleting the `.repo` folder inside each branch. However, be very careful not to delete the mirror's `.repo`, since you'll probably want to update it at some point in the future. - -### Building - -There's a `Makefile` in the `aosp` folder containing a build command for each SDK level and architecture we're interested in. If you're developing on Linux directly you may be able to `make` the libraries directly. - -More likely, though, you'll actually want to use the `build-remote.sh` script at the root of the minicap repo. It's not very pretty but it works. It transmits the source code to the target machine and uses one of the docker images to run `make` inside a docker container (which is done because CoreOS doesn't come with make). - -First, you'll need to tell the script where you're building. - -```bash -export BUILD_HOST=core@stf-build001 -``` - -This will be passed to SSH and rsync, and is able to benefit from your SSH config (which you must set up yourself as you like). - -Now, run the build script: - -```bash -./build-remote.sh -``` - -The first compile will take a long, long time, since it needs to compile all dependencies on the first run, for each architecture. - -### Rebuilding - -Any recompile after the first time will benefit from the already build dependencies and will go a lot faster, although it will still take a considerable amount of time. The `Makefile` attemps to be intelligent about which branches need to be rebuilt, but touching the common code base or the `Android.mk` file will usually require a recompile on each SDK and architecture. That by itself is reasonably fast, but setting up the AOSP build takes the most time anyway. It may take 5-15 minutes in total to do an "empty run" for each branch and architecture. - -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`. diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/.rsync-filter b/airtest/core/android/static/stf_libs/minicap-shared/aosp/.rsync-filter deleted file mode 100644 index d07b72d4..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/.rsync-filter +++ /dev/null @@ -1,2 +0,0 @@ -- .git -- libs diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/Android.mk b/airtest/core/android/static/stf_libs/minicap-shared/aosp/Android.mk deleted file mode 100644 index 40a4981b..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/Android.mk +++ /dev/null @@ -1,66 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := minicap - -LOCAL_MODULE_TAGS := optional - -ifneq ($(OVERRIDE_PLATFORM_SDK_VERSION),) -LOCAL_SRC_FILES += src/minicap_$(OVERRIDE_PLATFORM_SDK_VERSION).cpp -else ifeq ($(PLATFORM_SDK_VERSION),29) -LOCAL_SRC_FILES += src/minicap_29.cpp -else ifeq ($(PLATFORM_SDK_VERSION),28) -LOCAL_SRC_FILES += src/minicap_28.cpp -else ifeq ($(PLATFORM_SDK_VERSION),27) -LOCAL_SRC_FILES += src/minicap_27.cpp -else ifeq ($(PLATFORM_SDK_VERSION),26) -LOCAL_SRC_FILES += src/minicap_26.cpp -else 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) -LOCAL_SRC_FILES += src/minicap_22.cpp -else ifeq ($(PLATFORM_SDK_VERSION),21) -LOCAL_SRC_FILES += src/minicap_21.cpp -else ifeq ($(PLATFORM_SDK_VERSION),19) -LOCAL_SRC_FILES += src/minicap_19.cpp -else ifeq ($(PLATFORM_SDK_VERSION),18) -LOCAL_SRC_FILES += src/minicap_18.cpp -else ifeq ($(PLATFORM_SDK_VERSION),17) -LOCAL_SRC_FILES += src/minicap_17.cpp -else ifeq ($(PLATFORM_SDK_VERSION),16) -LOCAL_SRC_FILES += src/minicap_16.cpp -else ifeq ($(PLATFORM_SDK_VERSION),15) -LOCAL_SRC_FILES += src/minicap_14.cpp -else ifeq ($(PLATFORM_SDK_VERSION),14) -LOCAL_SRC_FILES += src/minicap_14.cpp -else ifeq ($(PLATFORM_SDK_VERSION),10) -LOCAL_SRC_FILES += src/minicap_9.cpp -else ifeq ($(PLATFORM_SDK_VERSION),9) -LOCAL_SRC_FILES += src/minicap_9.cpp -endif - -LOCAL_PRELINK_MODULE := false - -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libutils \ - libbinder \ - libui \ - liblog \ - -ifeq ($(PLATFORM_SDK_VERSION),$(filter $(PLATFORM_SDK_VERSION),10 9)) -LOCAL_SHARED_LIBRARIES += libsurfaceflinger_client -else -LOCAL_SHARED_LIBRARIES += libgui -endif - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/include \ - -LOCAL_CFLAGS += -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) - -include $(BUILD_SHARED_LIBRARY) diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/Makefile b/airtest/core/android/static/stf_libs/minicap-shared/aosp/Makefile deleted file mode 100644 index 0dd853dc..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/Makefile +++ /dev/null @@ -1,618 +0,0 @@ -this_dir = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -SOURCES := Android.mk include/Minicap.hpp - -all: \ - libs/android-9/armeabi-v7a/minicap.so \ - libs/android-10/armeabi-v7a/minicap.so \ - libs/android-14/armeabi-v7a/minicap.so \ - libs/android-14/x86/minicap.so \ - libs/android-15/armeabi-v7a/minicap.so \ - libs/android-15/x86/minicap.so \ - libs/android-16/armeabi-v7a/minicap.so \ - libs/android-16/x86/minicap.so \ - libs/android-17/armeabi-v7a/minicap.so \ - libs/android-17/x86/minicap.so \ - libs/android-18/armeabi-v7a/minicap.so \ - libs/android-18/x86/minicap.so \ - libs/android-19/armeabi-v7a/minicap.so \ - libs/android-19/x86/minicap.so \ - libs/android-21/armeabi-v7a/minicap.so \ - libs/android-21/arm64-v8a/minicap.so \ - libs/android-21/x86/minicap.so \ - libs/android-21/x86_64/minicap.so \ - libs/android-22/armeabi-v7a/minicap.so \ - libs/android-22/arm64-v8a/minicap.so \ - libs/android-22/x86/minicap.so \ - libs/android-22/x86_64/minicap.so \ - libs/android-23/armeabi-v7a/minicap.so \ - libs/android-23/arm64-v8a/minicap.so \ - libs/android-23/x86/minicap.so \ - libs/android-23/x86_64/minicap.so \ - libs/android-24/armeabi-v7a/minicap.so \ - libs/android-24/arm64-v8a/minicap.so \ - libs/android-24/x86/minicap.so \ - libs/android-24/x86_64/minicap.so \ - libs/android-25/armeabi-v7a/minicap.so \ - libs/android-25/arm64-v8a/minicap.so \ - libs/android-25/x86/minicap.so \ - libs/android-25/x86_64/minicap.so \ - libs/android-26/armeabi-v7a/minicap.so \ - libs/android-26/arm64-v8a/minicap.so \ - libs/android-26/x86/minicap.so \ - libs/android-26/x86_64/minicap.so \ - libs/android-27/armeabi-v7a/minicap.so \ - libs/android-27/arm64-v8a/minicap.so \ - libs/android-27/x86/minicap.so \ - libs/android-27/x86_64/minicap.so \ - libs/android-28/armeabi-v7a/minicap.so \ - libs/android-28/arm64-v8a/minicap.so \ - libs/android-28/x86/minicap.so \ - libs/android-28/x86_64/minicap.so \ - libs/android-29/arm64-v8a/minicap.so \ - -libs/android-9/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_9.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-2.3_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build generic-eng minicap - -libs/android-10/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_9.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-2.3.3_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build generic-eng minicap - -libs/android-14/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_14.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.0.1_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build full-eng minicap - -libs/android-14/x86/minicap.so: $(SOURCES) src/minicap_14.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.0.1_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build full_x86-eng minicap - -libs/android-15/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_14.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.0.3_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build full-eng minicap - -libs/android-15/x86/minicap.so: $(SOURCES) src/minicap_14.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.0.3_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build full_x86-eng minicap - -libs/android-16/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_16.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.1.1_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build full-eng minicap - -libs/android-16/x86/minicap.so: $(SOURCES) src/minicap_16.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.1.1_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build full_x86-eng minicap - -libs/android-17/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_17.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.2_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build full-eng minicap - -libs/android-17/x86/minicap.so: $(SOURCES) src/minicap_17.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.2_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build full_x86-eng minicap - -libs/android-18/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_18.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.3_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build aosp_arm-eng minicap - -libs/android-18/x86/minicap.so: $(SOURCES) src/minicap_18.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.3_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build aosp_x86-eng minicap - -libs/android-19/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_19.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.4_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build aosp_arm-eng minicap - -libs/android-19/x86/minicap.so: $(SOURCES) src/minicap_19.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-4.4_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk6 /aosp.sh build aosp_x86-eng minicap - -libs/android-21/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_21.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.0.1_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_arm-eng minicap - -libs/android-21/arm64-v8a/minicap.so: $(SOURCES) src/minicap_21.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.0.1_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_arm64-eng minicap - -libs/android-21/x86/minicap.so: $(SOURCES) src/minicap_21.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.0.1_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_x86-eng minicap - -libs/android-21/x86_64/minicap.so: $(SOURCES) src/minicap_21.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.0.1_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_x86_64-eng minicap - -libs/android-21/mips/minicap.so: $(SOURCES) src/minicap_21.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.0.1_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_mips-eng minicap - -libs/android-21/mips64/minicap.so: $(SOURCES) src/minicap_21.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.0.1_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_mips64-eng minicap - -libs/android-22/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_22.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_arm-eng minicap - -libs/android-22/arm64-v8a/minicap.so: $(SOURCES) src/minicap_22.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_arm64-eng minicap - -libs/android-22/x86/minicap.so: $(SOURCES) src/minicap_22.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_x86-eng minicap - -libs/android-22/x86_64/minicap.so: $(SOURCES) src/minicap_22.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_x86_64-eng minicap - -libs/android-22/mips/minicap.so: $(SOURCES) src/minicap_22.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_mips-eng minicap - -libs/android-22/mips64/minicap.so: $(SOURCES) src/minicap_22.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-5.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_mips64-eng minicap - -libs/android-23/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_23.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-6.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_arm-eng minicap - -libs/android-23/arm64-v8a/minicap.so: $(SOURCES) src/minicap_23.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-6.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_arm64-eng minicap - -libs/android-23/x86/minicap.so: $(SOURCES) src/minicap_23.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-6.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_x86-eng minicap - -libs/android-23/x86_64/minicap.so: $(SOURCES) src/minicap_23.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-6.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_x86_64-eng minicap - -libs/android-23/mips/minicap.so: $(SOURCES) src/minicap_23.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-6.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_mips-eng minicap - -libs/android-23/mips64/minicap.so: $(SOURCES) src/minicap_23.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-6.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk7 /aosp.sh build aosp_mips64-eng minicap - -libs/android-24/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_24.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm-eng minicap - -libs/android-24/arm64-v8a/minicap.so: $(SOURCES) src/minicap_24.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm64-eng minicap - -libs/android-24/x86/minicap.so: $(SOURCES) src/minicap_24.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_x86-eng minicap - -libs/android-24/x86_64/minicap.so: $(SOURCES) src/minicap_24.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_x86_64-eng minicap - -libs/android-24/mips/minicap.so: $(SOURCES) src/minicap_24.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_mips-eng minicap - -libs/android-24/mips64/minicap.so: $(SOURCES) src/minicap_24.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_mips64-eng minicap - -libs/android-25/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_25.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm-eng minicap - -libs/android-25/arm64-v8a/minicap.so: $(SOURCES) src/minicap_25.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm64-eng minicap - -libs/android-25/x86/minicap.so: $(SOURCES) src/minicap_25.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_x86-eng minicap - -libs/android-25/x86_64/minicap.so: $(SOURCES) src/minicap_25.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_x86_64-eng minicap - -libs/android-25/mips/minicap.so: $(SOURCES) src/minicap_25.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_mips-eng minicap - -libs/android-25/mips64/minicap.so: $(SOURCES) src/minicap_25.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-7.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_mips64-eng minicap - -libs/android-26/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_26.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm-eng minicap - -libs/android-26/arm64-v8a/minicap.so: $(SOURCES) src/minicap_26.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm64-eng minicap - -libs/android-26/x86/minicap.so: $(SOURCES) src/minicap_26.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_x86-eng minicap - -libs/android-26/x86_64/minicap.so: $(SOURCES) src/minicap_26.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_x86_64-eng minicap - -libs/android-26/mips/minicap.so: $(SOURCES) src/minicap_26.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_mips-eng minicap - -libs/android-26/mips64/minicap.so: $(SOURCES) src/minicap_26.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_mips64-eng minicap - -libs/android-27/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_27.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm-eng minicap - -libs/android-27/arm64-v8a/minicap.so: $(SOURCES) src/minicap_27.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm64-eng minicap - -libs/android-27/x86/minicap.so: $(SOURCES) src/minicap_27.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_x86-eng minicap - -libs/android-27/x86_64/minicap.so: $(SOURCES) src/minicap_27.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_x86_64-eng minicap - -libs/android-27/mips/minicap.so: $(SOURCES) src/minicap_27.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_mips-eng minicap - -libs/android-27/mips64/minicap.so: $(SOURCES) src/minicap_27.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-8.1.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_mips64-eng minicap - -libs/android-28/armeabi-v7a/minicap.so: $(SOURCES) src/minicap_28.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-9.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm-eng minicap - -libs/android-28/arm64-v8a/minicap.so: $(SOURCES) src/minicap_28.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-9.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm64-eng minicap - -libs/android-28/x86/minicap.so: $(SOURCES) src/minicap_28.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-9.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_x86-eng minicap - -libs/android-28/x86_64/minicap.so: $(SOURCES) src/minicap_28.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-9.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_x86_64-eng minicap - -libs/android-28/mips/minicap.so: $(SOURCES) src/minicap_28.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-9.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_mips-eng minicap - -libs/android-28/mips64/minicap.so: $(SOURCES) src/minicap_28.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-9.0.0_r1:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_mips64-eng minicap - -libs/android-29/arm64-v8a/minicap.so: $(SOURCES) src/minicap_29.cpp - mkdir -p $(@D) - docker run --rm \ - -a stdout -a stderr \ - -v /media/aosp/android-10.0.0_r2:/aosp \ - -v $(this_dir):/app \ - -v $(this_dir)$(@D):/artifacts \ - openstf/aosp:jdk8 /aosp.sh build aosp_arm64-eng minicap diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/include/Minicap.hpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/include/Minicap.hpp deleted file mode 100644 index 970968a4..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/include/Minicap.hpp +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef MINICAP_HPP -#define MINICAP_HPP - -#include - -class Minicap { -public: - enum CaptureMethod { - METHOD_FRAMEBUFFER = 1, - METHOD_SCREENSHOT = 2, - METHOD_VIRTUAL_DISPLAY = 3, - }; - - enum Format { - FORMAT_NONE = 0x01, - FORMAT_CUSTOM = 0x02, - FORMAT_TRANSLUCENT = 0x03, - FORMAT_TRANSPARENT = 0x04, - FORMAT_OPAQUE = 0x05, - FORMAT_RGBA_8888 = 0x06, - FORMAT_RGBX_8888 = 0x07, - FORMAT_RGB_888 = 0x08, - FORMAT_RGB_565 = 0x09, - FORMAT_BGRA_8888 = 0x0a, - FORMAT_RGBA_5551 = 0x0b, - FORMAT_RGBA_4444 = 0x0c, - FORMAT_UNKNOWN = 0x00, - }; - - enum Orientation { - ORIENTATION_0 = 0, - ORIENTATION_90 = 1, - ORIENTATION_180 = 2, - ORIENTATION_270 = 3, - }; - - struct DisplayInfo { - uint32_t width; - uint32_t height; - float fps; - float density; - float xdpi; - float ydpi; - float size; - uint8_t orientation; - bool secure; - }; - - struct Frame { - void const* data; - Format format; - uint32_t width; - uint32_t height; - uint32_t stride; - uint32_t bpp; - size_t size; - }; - - struct FrameAvailableListener { - virtual - ~FrameAvailableListener() {} - - virtual void - onFrameAvailable() = 0; - }; - - Minicap() {} - - virtual - ~Minicap() {} - - // Applies changes made by setDesiredInfo() and setRealInfo(). Must be - // called before attempting to wait or consume frames. - virtual int - applyConfigChanges() = 0; - - // Consumes a frame. Must be called after waitForFrame(). - virtual int - consumePendingFrame(Frame* frame) = 0; - - // Peek behind the scenes to see which capture method is actually - // being used. - virtual CaptureMethod - getCaptureMethod() = 0; - - // Get display ID. - virtual int32_t - getDisplayId() = 0; - - // Release all resources. - virtual void - release() = 0; - - // Releases a consumed frame so that it can be reused by Android again. - // Must be called before consumePendingFrame() is called again. - virtual void - releaseConsumedFrame(Frame* frame) = 0; - - // Set desired information about the display. Currently, only the - // following properties are actually used: width, height and orientation. - // After the configuration has been applied, new frames should satisfy - // the requirements. - virtual int - setDesiredInfo(const DisplayInfo& info) = 0; - - // Sets the frame available listener. - virtual void - setFrameAvailableListener(FrameAvailableListener* listener) = 0; - - // Set the display's real information. This cannot be accessed automatically - // due to manufacturers (mainly Samsung) having customized - // android::DisplayInfo. The information has to be gathered somehow and then - // passed on here. Currently only the following properties are actually - // used: width and height. - virtual int - setRealInfo(const DisplayInfo& info) = 0; -}; - -// Attempt to get information about the given display. This may segfault -// on some devices due to manufacturer (mainly Samsung) customizations. -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info); - -// Creates a new Minicap instance for the current platform. -Minicap* -minicap_create(int32_t displayId); - -// Frees a Minicap instance. Don't call delete yourself as it won't have -// access to the platform-specific modifications. -void -minicap_free(Minicap* mc); - -// Starts an Android thread pool. Must be called before doing anything else. -void -minicap_start_thread_pool(); - -#endif diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/include/mcdebug.h b/airtest/core/android/static/stf_libs/minicap-shared/aosp/include/mcdebug.h deleted file mode 100644 index 0c6f2853..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/include/mcdebug.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __minicap_dbg_h__ -#define __minicap_dbg_h__ - -// These macros were originally from -// http://c.learncodethehardway.org/book/ex20.html - -#include -#include -#include - -#ifdef NDEBUG -#define MCDEBUG(M, ...) -#else -#define MCDEBUG(M, ...) fprintf(stderr, "DEBUG: %s:%d: " M "\n", __FILE__, __LINE__, ##__VA_ARGS__) -#endif - -#define MCCLEAN_ERRNO() (errno == 0 ? "None" : strerror(errno)) - -#define MCERROR(M, ...) fprintf(stderr, "ERROR: (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, MCCLEAN_ERRNO(), ##__VA_ARGS__) - -#define MCWARN(M, ...) fprintf(stderr, "WARN: (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, MCCLEAN_ERRNO(), ##__VA_ARGS__) - -#define MCINFO(M, ...) fprintf(stderr, "INFO: (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__) - -#define MCCHECK(A, M, ...) if(!(A)) { MCERROR(M, ##__VA_ARGS__); errno=0; goto error; } - -#define MCSENTINEL(M, ...) { MCERROR(M, ##__VA_ARGS__); errno=0; goto error; } - -#define MCCHECK_MEM(A) check((A), "Out of memory.") - -#define MCCHECK_DEBUG(A, M, ...) if(!(A)) { MCDEBUG(M, ##__VA_ARGS__); errno=0; goto error; } - -#endif diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/arm64-v8a/minicap.so b/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/arm64-v8a/minicap.so index ecddadae..f242d0a9 100644 Binary files a/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/arm64-v8a/minicap.so and b/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/arm64-v8a/minicap.so differ diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/armeabi-v7a/minicap.so b/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/armeabi-v7a/minicap.so new file mode 100644 index 00000000..38728b22 Binary files /dev/null and b/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/armeabi-v7a/minicap.so differ diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/x86/minicap.so b/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/x86/minicap.so new file mode 100644 index 00000000..f7f83828 Binary files /dev/null and b/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/x86/minicap.so differ diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/x86_64/minicap.so b/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/x86_64/minicap.so new file mode 100644 index 00000000..e34a95cb Binary files /dev/null and b/airtest/core/android/static/stf_libs/minicap-shared/aosp/libs/android-29/x86_64/minicap.so differ diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_14.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_14.cpp deleted file mode 100644 index 3b4e8090..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_14.cpp +++ /dev/null @@ -1,227 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class MinicapImpl: public Minicap { -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mComposer(android::ComposerService::getComposerService()), - mDesiredWidth(0), - mDesiredHeight(0) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - mUserFrameAvailableListener->onFrameAvailable(); - return 0; - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - uint32_t width, height; - android::PixelFormat format; - android::status_t err; - - mHeap = NULL; - err = mComposer->captureScreen(mDisplayId, &mHeap, - &width, &height, &format, mDesiredWidth, mDesiredHeight, 0, -1UL); - - if (err != android::NO_ERROR) { - MCERROR("ComposerService::captureScreen() failed %s", error_name(err)); - return err; - } - - frame->data = mHeap->getBase(); - frame->width = width; - frame->height = height; - frame->format = convertFormat(format); - frame->stride = width; - frame->bpp = android::bytesPerPixel(format); - frame->size = mHeap->getSize(); - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_SCREENSHOT; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - mHeap = NULL; - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - mHeap = NULL; - return mUserFrameAvailableListener->onFrameAvailable(); - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - return 0; - } - -private: - int32_t mDisplayId; - android::sp mComposer; - android::sp mHeap; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::DisplayInfo dinfo; - android::status_t err = android::SurfaceComposerClient::getDisplayInfo(displayId, &dinfo); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = false; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_16.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_16.cpp deleted file mode 100644 index 2699070e..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_16.cpp +++ /dev/null @@ -1,229 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include - -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class MinicapImpl: public Minicap { -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mComposer(android::ComposerService::getComposerService()), - mDesiredWidth(0), - mDesiredHeight(0) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - mUserFrameAvailableListener->onFrameAvailable(); - return 0; - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - uint32_t width, height; - android::PixelFormat format; - android::status_t err; - - mHeap = NULL; - err = mComposer->captureScreen(mDisplayId, &mHeap, - &width, &height, &format, mDesiredWidth, mDesiredHeight, 0, -1UL); - - if (err != android::NO_ERROR) { - MCERROR("ComposerService::captureScreen() failed %s", error_name(err)); - return err; - } - - frame->data = mHeap->getBase(); - frame->width = width; - frame->height = height; - frame->format = convertFormat(format); - frame->stride = width; - frame->bpp = android::bytesPerPixel(format); - frame->size = mHeap->getSize(); - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_SCREENSHOT; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - mHeap = NULL; - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - mHeap = NULL; - return mUserFrameAvailableListener->onFrameAvailable(); - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - return 0; - } - -private: - int32_t mDisplayId; - android::sp mComposer; - android::sp mHeap; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::DisplayInfo dinfo; - android::status_t err = android::SurfaceComposerClient::getDisplayInfo(displayId, &dinfo); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = false; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_17.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_17.cpp deleted file mode 100644 index 81f07bd5..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_17.cpp +++ /dev/null @@ -1,372 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable() { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferQueue; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating CPU consumer"); - // Some devices have a modified, larger CpuConsumer. Try to account - // for that by increasing the size. - mConsumer = new(operator new(sizeof(android::CpuConsumer) + 100)) android::CpuConsumer(3); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating buffer queue"); - mBufferQueue = mConsumer->getBufferQueue(); - mBufferQueue->setSynchronousMode(false); - mBufferQueue->setDefaultBufferSize(targetWidth, targetHeight); - mBufferQueue->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::openGlobalTransaction(); - android::SurfaceComposerClient::setDisplaySurface(mVirtualDisplay, mBufferQueue); - android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack - android::SurfaceComposerClient::closeGlobalTransaction(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferQueue = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::DisplayInfo dinfo; - android::status_t err = android::SurfaceComposerClient::getDisplayInfo(dpy, &dinfo); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_18.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_18.cpp deleted file mode 100644 index 13cef1cc..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_18.cpp +++ /dev/null @@ -1,369 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable() { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferQueue; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating CPU consumer"); - mConsumer = new android::CpuConsumer(3, false); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating buffer queue"); - mBufferQueue = mConsumer->getBufferQueue(); - mBufferQueue->setDefaultBufferSize(targetWidth, targetHeight); - mBufferQueue->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::openGlobalTransaction(); - android::SurfaceComposerClient::setDisplaySurface(mVirtualDisplay, mBufferQueue); - android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack - android::SurfaceComposerClient::closeGlobalTransaction(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferQueue = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::DisplayInfo dinfo; - android::status_t err = android::SurfaceComposerClient::getDisplayInfo(dpy, &dinfo); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_19.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_19.cpp deleted file mode 100644 index d208d489..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_19.cpp +++ /dev/null @@ -1,384 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -// Terrible hack to access ScreenshotClient's mBufferQueue. It's too risky -// to do `new android::BufferQueue()` by ourselves, makers tend to customize -// it. -#define private public -#include -#undef private - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable() { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferQueue; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - android::ScreenshotClient mScreenshotClient; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating buffer queue"); - // Many devices fail if we create a BufferQueue by ourselves. - // Fortunately, we can steal one from the very stable ScreenshotClient - // and repurpose it. - mScreenshotClient.getCpuConsumer(); - mBufferQueue = mScreenshotClient.mBufferQueue; - - MCINFO("Creating CPU consumer"); - // Some devices have a modified, larger CpuConsumer. Try to account - // for that by increasing the size. Example devices include Asus MeMO - // Pad 7 (ME176). - mConsumer = new(operator new(sizeof(android::CpuConsumer) + 100)) android::CpuConsumer(mBufferQueue, 3, false); - mConsumer->setName(android::String8("minicap")); - mConsumer->setDefaultBufferSize(targetWidth, targetHeight); - mConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::openGlobalTransaction(); - android::SurfaceComposerClient::setDisplaySurface(mVirtualDisplay, mBufferQueue); - android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack - android::SurfaceComposerClient::closeGlobalTransaction(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - android::SurfaceComposerClient::destroyDisplay(mVirtualDisplay); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferQueue = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::DisplayInfo dinfo; - android::status_t err = android::SurfaceComposerClient::getDisplayInfo(dpy, &dinfo); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_21.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_21.cpp deleted file mode 100644 index b84fa9ba..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_21.cpp +++ /dev/null @@ -1,379 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable() { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferProducer; - android::sp mBufferConsumer; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating buffer queue"); - android::BufferQueue::createBufferQueue(&mBufferProducer, &mBufferConsumer); - mBufferConsumer->setDefaultBufferSize(targetWidth, targetHeight); - mBufferConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating CPU consumer"); - mConsumer = new android::CpuConsumer(mBufferConsumer, 3, false); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::openGlobalTransaction(); - android::SurfaceComposerClient::setDisplaySurface(mVirtualDisplay, mBufferProducer); - android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack - android::SurfaceComposerClient::closeGlobalTransaction(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - android::SurfaceComposerClient::destroyDisplay(mVirtualDisplay); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferProducer = NULL; - mBufferConsumer = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::Vector configs; - android::status_t err = android::SurfaceComposerClient::getDisplayConfigs(dpy, &configs); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - int activeConfig = android::SurfaceComposerClient::getActiveConfig(dpy); - if(static_cast(activeConfig) >= configs.size()) { - MCERROR("Active config %d not inside configs (size %zu)\n", activeConfig, configs.size()); - return android::BAD_VALUE; - } - android::DisplayInfo dinfo = configs[activeConfig]; - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_22.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_22.cpp deleted file mode 100644 index 65efd2a6..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_22.cpp +++ /dev/null @@ -1,386 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -// This trick is needed for many Samsung devices running 5.1. Examples include -// Galaxy S5 Neo, Galaxy J1, Galaxy A8 and so on. -struct CompatFrameAvailableListener : public virtual android::RefBase { - virtual void onFrameAvailable(const android::BufferItem& item) = 0; - virtual void onFrameReplaced() {}; -}; - -class FrameProxy: public CompatFrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable(const android::BufferItem& /* item */) { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferProducer; - android::sp mBufferConsumer; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating buffer queue"); - android::BufferQueue::createBufferQueue(&mBufferProducer, &mBufferConsumer); - mBufferConsumer->setDefaultBufferSize(targetWidth, targetHeight); - mBufferConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating CPU consumer"); - mConsumer = new android::CpuConsumer(mBufferConsumer, 3, false); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating frame waiter"); - mFrameProxy = reinterpret_cast(new FrameProxy(mUserFrameAvailableListener)); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::openGlobalTransaction(); - android::SurfaceComposerClient::setDisplaySurface(mVirtualDisplay, mBufferProducer); - android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack - android::SurfaceComposerClient::closeGlobalTransaction(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - android::SurfaceComposerClient::destroyDisplay(mVirtualDisplay); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferProducer = NULL; - mBufferConsumer = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::Vector configs; - android::status_t err = android::SurfaceComposerClient::getDisplayConfigs(dpy, &configs); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - int activeConfig = android::SurfaceComposerClient::getActiveConfig(dpy); - if(static_cast(activeConfig) >= configs.size()) { - MCERROR("Active config %d not inside configs (size %zu)\n", activeConfig, configs.size()); - return android::BAD_VALUE; - } - android::DisplayInfo dinfo = configs[activeConfig]; - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_23.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_23.cpp deleted file mode 100644 index 63152f8e..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_23.cpp +++ /dev/null @@ -1,379 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable(const android::BufferItem& /* item */) { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferProducer; - android::sp mBufferConsumer; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating buffer queue"); - android::BufferQueue::createBufferQueue(&mBufferProducer, &mBufferConsumer); - mBufferConsumer->setDefaultBufferSize(targetWidth, targetHeight); - mBufferConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating CPU consumer"); - mConsumer = new android::CpuConsumer(mBufferConsumer, 3, false); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::openGlobalTransaction(); - android::SurfaceComposerClient::setDisplaySurface(mVirtualDisplay, mBufferProducer); - android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack - android::SurfaceComposerClient::closeGlobalTransaction(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - android::SurfaceComposerClient::destroyDisplay(mVirtualDisplay); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferProducer = NULL; - mBufferConsumer = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::Vector configs; - android::status_t err = android::SurfaceComposerClient::getDisplayConfigs(dpy, &configs); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - int activeConfig = android::SurfaceComposerClient::getActiveConfig(dpy); - if(static_cast(activeConfig) >= configs.size()) { - MCERROR("Active config %d not inside configs (size %zu)\n", activeConfig, configs.size()); - return android::BAD_VALUE; - } - android::DisplayInfo dinfo = configs[activeConfig]; - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_24.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_24.cpp deleted file mode 100644 index 63152f8e..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_24.cpp +++ /dev/null @@ -1,379 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable(const android::BufferItem& /* item */) { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferProducer; - android::sp mBufferConsumer; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating buffer queue"); - android::BufferQueue::createBufferQueue(&mBufferProducer, &mBufferConsumer); - mBufferConsumer->setDefaultBufferSize(targetWidth, targetHeight); - mBufferConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating CPU consumer"); - mConsumer = new android::CpuConsumer(mBufferConsumer, 3, false); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::openGlobalTransaction(); - android::SurfaceComposerClient::setDisplaySurface(mVirtualDisplay, mBufferProducer); - android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack - android::SurfaceComposerClient::closeGlobalTransaction(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - android::SurfaceComposerClient::destroyDisplay(mVirtualDisplay); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferProducer = NULL; - mBufferConsumer = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::Vector configs; - android::status_t err = android::SurfaceComposerClient::getDisplayConfigs(dpy, &configs); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - int activeConfig = android::SurfaceComposerClient::getActiveConfig(dpy); - if(static_cast(activeConfig) >= configs.size()) { - MCERROR("Active config %d not inside configs (size %zu)\n", activeConfig, configs.size()); - return android::BAD_VALUE; - } - android::DisplayInfo dinfo = configs[activeConfig]; - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_25.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_25.cpp deleted file mode 100644 index a70fd728..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_25.cpp +++ /dev/null @@ -1,403 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable(const android::BufferItem& /* item */) { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferProducer; - android::sp mBufferConsumer; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating buffer queue"); - android::BufferQueue::createBufferQueue(&mBufferProducer, &mBufferConsumer); - mBufferConsumer->setDefaultBufferSize(targetWidth, targetHeight); - mBufferConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating CPU consumer"); - mConsumer = new android::CpuConsumer(mBufferConsumer, 3, false); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::openGlobalTransaction(); - - // Well, this is just horrible. Thanks 7.1 Developer Preview. - typedef void (*setDisplaySurfaceAOSP_t)(android::sp const&, android::sp const&); - typedef void (*setDisplaySurface71DP_t)(android::sp const&, android::sp); - - // This is the standard AOSP symbol. - setDisplaySurfaceAOSP_t setDisplaySurfaceAOSP = (setDisplaySurfaceAOSP_t) dlsym(RTLD_DEFAULT, "_ZN7android21SurfaceComposerClient17setDisplaySurfaceERKNS_2spINS_7IBinderEEERKNS1_INS_22IGraphicBufferProducerEEE"); - if (setDisplaySurfaceAOSP != NULL) { - // Yay! Things are like they're supposed to be! - setDisplaySurfaceAOSP(mVirtualDisplay, mBufferProducer); - } - else { - // This is the 7.1 Developer Preview symbol. - setDisplaySurface71DP_t setDisplaySurface71DP = (setDisplaySurface71DP_t) dlsym(RTLD_DEFAULT, "_ZN7android21SurfaceComposerClient17setDisplaySurfaceERKNS_2spINS_7IBinderEEENS1_INS_22IGraphicBufferProducerEEE"); - if (setDisplaySurface71DP != NULL) { - MCINFO("Found 7.1 Developer Preview SurfaceComposerClient::setDisplaySurface"); - setDisplaySurface71DP(mVirtualDisplay, mBufferProducer); - } - else { - MCERROR("Unable to find AOSP or 7.1 DP style SurfaceComposerClient::setDisplaySurface"); - return android::NAME_NOT_FOUND; - } - } - - android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack - android::SurfaceComposerClient::closeGlobalTransaction(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - android::SurfaceComposerClient::destroyDisplay(mVirtualDisplay); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferProducer = NULL; - mBufferConsumer = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::Vector configs; - android::status_t err = android::SurfaceComposerClient::getDisplayConfigs(dpy, &configs); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - int activeConfig = android::SurfaceComposerClient::getActiveConfig(dpy); - if(static_cast(activeConfig) >= configs.size()) { - MCERROR("Active config %d not inside configs (size %zu)\n", activeConfig, configs.size()); - return android::BAD_VALUE; - } - android::DisplayInfo dinfo = configs[activeConfig]; - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_26.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_26.cpp deleted file mode 100644 index 823585b9..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_26.cpp +++ /dev/null @@ -1,386 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable(const android::BufferItem& /* item */) { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferProducer; - android::sp mBufferConsumer; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // This is now REQUIRED in O Developer Preview 1 or there's a segfault - // when the sp goes out of scope. - sc = NULL; - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating buffer queue"); - android::BufferQueue::createBufferQueue(&mBufferProducer, &mBufferConsumer, false); - - MCINFO("Setting buffer options"); - mBufferConsumer->setDefaultBufferSize(targetWidth, targetHeight); - mBufferConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating CPU consumer"); - mConsumer = new android::CpuConsumer(mBufferConsumer, 3, false); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::openGlobalTransaction(); - android::SurfaceComposerClient::setDisplaySurface(mVirtualDisplay, mBufferProducer); - android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack - android::SurfaceComposerClient::closeGlobalTransaction(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - android::SurfaceComposerClient::destroyDisplay(mVirtualDisplay); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferProducer = NULL; - mBufferConsumer = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::Vector configs; - android::status_t err = android::SurfaceComposerClient::getDisplayConfigs(dpy, &configs); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - int activeConfig = android::SurfaceComposerClient::getActiveConfig(dpy); - if(static_cast(activeConfig) >= configs.size()) { - MCERROR("Active config %d not inside configs (size %zu)\n", activeConfig, configs.size()); - return android::BAD_VALUE; - } - android::DisplayInfo dinfo = configs[activeConfig]; - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_27.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_27.cpp deleted file mode 100644 index 823585b9..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_27.cpp +++ /dev/null @@ -1,386 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable(const android::BufferItem& /* item */) { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferProducer; - android::sp mBufferConsumer; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // This is now REQUIRED in O Developer Preview 1 or there's a segfault - // when the sp goes out of scope. - sc = NULL; - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating buffer queue"); - android::BufferQueue::createBufferQueue(&mBufferProducer, &mBufferConsumer, false); - - MCINFO("Setting buffer options"); - mBufferConsumer->setDefaultBufferSize(targetWidth, targetHeight); - mBufferConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating CPU consumer"); - mConsumer = new android::CpuConsumer(mBufferConsumer, 3, false); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::openGlobalTransaction(); - android::SurfaceComposerClient::setDisplaySurface(mVirtualDisplay, mBufferProducer); - android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack - android::SurfaceComposerClient::closeGlobalTransaction(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - android::SurfaceComposerClient::destroyDisplay(mVirtualDisplay); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferProducer = NULL; - mBufferConsumer = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::Vector configs; - android::status_t err = android::SurfaceComposerClient::getDisplayConfigs(dpy, &configs); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - int activeConfig = android::SurfaceComposerClient::getActiveConfig(dpy); - if(static_cast(activeConfig) >= configs.size()) { - MCERROR("Active config %d not inside configs (size %zu)\n", activeConfig, configs.size()); - return android::BAD_VALUE; - } - android::DisplayInfo dinfo = configs[activeConfig]; - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_28.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_28.cpp deleted file mode 100644 index c5a04d39..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_28.cpp +++ /dev/null @@ -1,386 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable(const android::BufferItem& /* item */) { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferProducer; - android::sp mBufferConsumer; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // This is now REQUIRED in O Developer Preview 1 or there's a segfault - // when the sp goes out of scope. - sc = NULL; - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating buffer queue"); - android::BufferQueue::createBufferQueue(&mBufferProducer, &mBufferConsumer, false); - - MCINFO("Setting buffer options"); - mBufferConsumer->setDefaultBufferSize(targetWidth, targetHeight); - mBufferConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating CPU consumer"); - mConsumer = new android::CpuConsumer(mBufferConsumer, 3, false); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::Transaction t; - t.setDisplaySurface(mVirtualDisplay, mBufferProducer); - t.setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - t.setDisplayLayerStack(mVirtualDisplay, 0); // default stack - t.apply(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - android::SurfaceComposerClient::destroyDisplay(mVirtualDisplay); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferProducer = NULL; - mBufferConsumer = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); - - android::Vector configs; - android::status_t err = android::SurfaceComposerClient::getDisplayConfigs(dpy, &configs); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - int activeConfig = android::SurfaceComposerClient::getActiveConfig(dpy); - if(static_cast(activeConfig) >= configs.size()) { - MCERROR("Active config %d not inside configs (size %zu)\n", activeConfig, configs.size()); - return android::BAD_VALUE; - } - android::DisplayInfo dinfo = configs[activeConfig]; - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_29.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_29.cpp deleted file mode 100644 index fc4bea20..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_29.cpp +++ /dev/null @@ -1,386 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - case android::FDS_NOT_ALLOWED: - return "FDS_NOT_ALLOWED"; - default: - return "UNMAPPED_ERROR"; - } -} - -class FrameProxy: public android::ConsumerBase::FrameAvailableListener { -public: - FrameProxy(Minicap::FrameAvailableListener* listener): mUserListener(listener) { - } - - virtual void - onFrameAvailable(const android::BufferItem& /* item */) { - mUserListener->onFrameAvailable(); - } - -private: - Minicap::FrameAvailableListener* mUserListener; -}; - -class MinicapImpl: public Minicap -{ -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mRealWidth(0), - mRealHeight(0), - mDesiredWidth(0), - mDesiredHeight(0), - mDesiredOrientation(0), - mHaveBuffer(false), - mHaveRunningDisplay(false) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - if (mHaveRunningDisplay) { - destroyVirtualDisplay(); - } - - return createVirtualDisplay(); - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - android::status_t err; - - if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { - if (err == -EINTR) { - return err; - } - else { - MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); - return err; - } - } - - frame->data = mBuffer.data; - frame->format = convertFormat(mBuffer.format); - frame->width = mBuffer.width; - frame->height = mBuffer.height; - frame->stride = mBuffer.stride; - frame->bpp = android::bytesPerPixel(mBuffer.format); - frame->size = mBuffer.stride * mBuffer.height * frame->bpp; - - mHaveBuffer = true; - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_VIRTUAL_DISPLAY; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - destroyVirtualDisplay(); - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - mDesiredOrientation = info.orientation; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - mRealWidth = info.width; - mRealHeight = info.height; - return 0; - } - -private: - int32_t mDisplayId; - uint32_t mRealWidth; - uint32_t mRealHeight; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - uint8_t mDesiredOrientation; - android::sp mBufferProducer; - android::sp mBufferConsumer; - android::sp mConsumer; - android::sp mVirtualDisplay; - android::sp mFrameProxy; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - bool mHaveBuffer; - bool mHaveRunningDisplay; - android::CpuConsumer::LockedBuffer mBuffer; - - int - createVirtualDisplay() { - uint32_t sourceWidth, sourceHeight; - uint32_t targetWidth, targetHeight; - android::status_t err; - - switch (mDesiredOrientation) { - case Minicap::ORIENTATION_90: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_270: - sourceWidth = mRealHeight; - sourceHeight = mRealWidth; - targetWidth = mDesiredHeight; - targetHeight = mDesiredWidth; - break; - case Minicap::ORIENTATION_180: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - case Minicap::ORIENTATION_0: - default: - sourceWidth = mRealWidth; - sourceHeight = mRealHeight; - targetWidth = mDesiredWidth; - targetHeight = mDesiredHeight; - break; - } - - // Set up virtual display size. - android::Rect layerStackRect(sourceWidth, sourceHeight); - android::Rect visibleRect(targetWidth, targetHeight); - - // Create a Surface for the virtual display to write to. - MCINFO("Creating SurfaceComposerClient"); - android::sp sc = new android::SurfaceComposerClient(); - - MCINFO("Performing SurfaceComposerClient init check"); - if ((err = sc->initCheck()) != android::NO_ERROR) { - MCERROR("Unable to initialize SurfaceComposerClient"); - return err; - } - - // This is now REQUIRED in O Developer Preview 1 or there's a segfault - // when the sp goes out of scope. - sc = NULL; - - // Create virtual display. - MCINFO("Creating virtual display"); - mVirtualDisplay = android::SurfaceComposerClient::createDisplay( - /* const String8& displayName */ android::String8("minicap"), - /* bool secure */ true - ); - - MCINFO("Creating buffer queue"); - android::BufferQueue::createBufferQueue(&mBufferProducer, &mBufferConsumer, false); - - MCINFO("Setting buffer options"); - mBufferConsumer->setDefaultBufferSize(targetWidth, targetHeight); - mBufferConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888); - - MCINFO("Creating CPU consumer"); - mConsumer = new android::CpuConsumer(mBufferConsumer, 3, false); - mConsumer->setName(android::String8("minicap")); - - MCINFO("Creating frame waiter"); - mFrameProxy = new FrameProxy(mUserFrameAvailableListener); - mConsumer->setFrameAvailableListener(mFrameProxy); - - MCINFO("Publishing virtual display"); - android::SurfaceComposerClient::Transaction t; - t.setDisplaySurface(mVirtualDisplay, mBufferProducer); - t.setDisplayProjection(mVirtualDisplay, - android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect); - t.setDisplayLayerStack(mVirtualDisplay, 0); // default stack - t.apply(); - - mHaveRunningDisplay = true; - - return 0; - } - - void - destroyVirtualDisplay() { - MCINFO("Destroying virtual display"); - android::SurfaceComposerClient::destroyDisplay(mVirtualDisplay); - - if (mHaveBuffer) { - mConsumer->unlockBuffer(mBuffer); - mHaveBuffer = false; - } - - mBufferProducer = NULL; - mBufferConsumer = NULL; - mConsumer = NULL; - mFrameProxy = NULL; - mVirtualDisplay = NULL; - - mHaveRunningDisplay = false; - } - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::sp dpy = android::SurfaceComposerClient::getPhysicalDisplayToken(displayId); - - android::Vector configs; - android::status_t err = android::SurfaceComposerClient::getDisplayConfigs(dpy, &configs); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - int activeConfig = android::SurfaceComposerClient::getActiveConfig(dpy); - if(static_cast(activeConfig) >= configs.size()) { - MCERROR("Active config %d not inside configs (size %zu)\n", activeConfig, configs.size()); - return android::BAD_VALUE; - } - android::DisplayInfo dinfo = configs[activeConfig]; - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = dinfo.secure; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_9.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_9.cpp deleted file mode 100644 index 5c4a39b7..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/minicap_9.cpp +++ /dev/null @@ -1,225 +0,0 @@ -#include "Minicap.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -#include "mcdebug.h" - -static const char* -error_name(int32_t err) { - switch (err) { - case android::NO_ERROR: // also android::OK - return "NO_ERROR"; - case android::UNKNOWN_ERROR: - return "UNKNOWN_ERROR"; - case android::NO_MEMORY: - return "NO_MEMORY"; - case android::INVALID_OPERATION: - return "INVALID_OPERATION"; - case android::BAD_VALUE: - return "BAD_VALUE"; - case android::BAD_TYPE: - return "BAD_TYPE"; - case android::NAME_NOT_FOUND: - return "NAME_NOT_FOUND"; - case android::PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case android::NO_INIT: - return "NO_INIT"; - case android::ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case android::DEAD_OBJECT: // also android::JPARKS_BROKE_IT - return "DEAD_OBJECT"; - case android::FAILED_TRANSACTION: - return "FAILED_TRANSACTION"; - case android::BAD_INDEX: - return "BAD_INDEX"; - case android::NOT_ENOUGH_DATA: - return "NOT_ENOUGH_DATA"; - case android::WOULD_BLOCK: - return "WOULD_BLOCK"; - case android::TIMED_OUT: - return "TIMED_OUT"; - case android::UNKNOWN_TRANSACTION: - return "UNKNOWN_TRANSACTION"; - default: - return "UNMAPPED_ERROR"; - } -} - -class MinicapImpl: public Minicap { -public: - MinicapImpl(int32_t displayId) - : mDisplayId(displayId), - mComposer(android::ComposerService::getComposerService()), - mDesiredWidth(0), - mDesiredHeight(0) { - } - - virtual - ~MinicapImpl() { - release(); - } - - virtual int - applyConfigChanges() { - mUserFrameAvailableListener->onFrameAvailable(); - return 0; - } - - virtual int - consumePendingFrame(Minicap::Frame* frame) { - uint32_t width, height; - android::PixelFormat format; - android::status_t err; - - mHeap = NULL; - err = mComposer->captureScreen(mDisplayId, &mHeap, - &width, &height, &format, mDesiredWidth, mDesiredHeight); - - if (err != android::NO_ERROR) { - MCERROR("ComposerService::captureScreen() failed %s", error_name(err)); - return err; - } - - frame->data = mHeap->getBase(); - frame->width = width; - frame->height = height; - frame->format = convertFormat(format); - frame->stride = width; - frame->bpp = android::bytesPerPixel(format); - frame->size = mHeap->getSize(); - - return 0; - } - - virtual Minicap::CaptureMethod - getCaptureMethod() { - return METHOD_SCREENSHOT; - } - - virtual int32_t - getDisplayId() { - return mDisplayId; - } - - virtual void - release() { - mHeap = NULL; - } - - virtual void - releaseConsumedFrame(Minicap::Frame* /* frame */) { - mHeap = NULL; - return mUserFrameAvailableListener->onFrameAvailable(); - } - - virtual int - setDesiredInfo(const Minicap::DisplayInfo& info) { - mDesiredWidth = info.width; - mDesiredHeight = info.height; - return 0; - } - - virtual void - setFrameAvailableListener(Minicap::FrameAvailableListener* listener) { - mUserFrameAvailableListener = listener; - } - - virtual int - setRealInfo(const Minicap::DisplayInfo& info) { - return 0; - } - -private: - int32_t mDisplayId; - android::sp mComposer; - android::sp mHeap; - uint32_t mDesiredWidth; - uint32_t mDesiredHeight; - Minicap::FrameAvailableListener* mUserFrameAvailableListener; - - static Minicap::Format - convertFormat(android::PixelFormat format) { - switch (format) { - case android::PIXEL_FORMAT_NONE: - return FORMAT_NONE; - case android::PIXEL_FORMAT_CUSTOM: - return FORMAT_CUSTOM; - case android::PIXEL_FORMAT_TRANSLUCENT: - return FORMAT_TRANSLUCENT; - case android::PIXEL_FORMAT_TRANSPARENT: - return FORMAT_TRANSPARENT; - case android::PIXEL_FORMAT_OPAQUE: - return FORMAT_OPAQUE; - case android::PIXEL_FORMAT_RGBA_8888: - return FORMAT_RGBA_8888; - case android::PIXEL_FORMAT_RGBX_8888: - return FORMAT_RGBX_8888; - case android::PIXEL_FORMAT_RGB_888: - return FORMAT_RGB_888; - case android::PIXEL_FORMAT_RGB_565: - return FORMAT_RGB_565; - case android::PIXEL_FORMAT_BGRA_8888: - return FORMAT_BGRA_8888; - case android::PIXEL_FORMAT_RGBA_5551: - return FORMAT_RGBA_5551; - case android::PIXEL_FORMAT_RGBA_4444: - return FORMAT_RGBA_4444; - default: - return FORMAT_UNKNOWN; - } - } -}; - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - android::DisplayInfo dinfo; - android::status_t err = android::SurfaceComposerClient::getDisplayInfo(displayId, &dinfo); - - if (err != android::NO_ERROR) { - MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); - return err; - } - - info->width = dinfo.w; - info->height = dinfo.h; - info->orientation = dinfo.orientation; - info->fps = dinfo.fps; - info->density = dinfo.density; - info->xdpi = dinfo.xdpi; - info->ydpi = dinfo.ydpi; - info->secure = false; - info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); - - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return new MinicapImpl(displayId); -} - -void -minicap_free(Minicap* mc) { - delete mc; -} - -void -minicap_start_thread_pool() { - android::ProcessState::self()->startThreadPool(); -} diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/ConsumerBase.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/ConsumerBase.cpp deleted file mode 100644 index c4ec8578..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/ConsumerBase.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "ConsumerBase" -#define ATRACE_TAG ATRACE_TAG_GRAPHICS -//#define LOG_NDEBUG 0 - -#define EGL_EGLEXT_PROTOTYPES - -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - -// Macros for including the ConsumerBase name in log messages -#define CB_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__) -#define CB_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__) -#define CB_LOGI(x, ...) ALOGI("[%s] "x, mName.string(), ##__VA_ARGS__) -#define CB_LOGW(x, ...) ALOGW("[%s] "x, mName.string(), ##__VA_ARGS__) -#define CB_LOGE(x, ...) ALOGE("[%s] "x, mName.string(), ##__VA_ARGS__) - -namespace android { - -// Get an ID that's unique within this process. -static int32_t createProcessUniqueId() { - static volatile int32_t globalCounter = 0; - return android_atomic_inc(&globalCounter); -} - -ConsumerBase::ConsumerBase(const sp& bufferQueue, bool controlledByApp) : - mAbandoned(false), - mConsumer(bufferQueue) { - // Choose a name using the PID and a process-unique ID. - mName = String8::format("unnamed-%d-%d", getpid(), createProcessUniqueId()); - - // Note that we can't create an sp<...>(this) in a ctor that will not keep a - // reference once the ctor ends, as that would cause the refcount of 'this' - // dropping to 0 at the end of the ctor. Since all we need is a wp<...> - // that's what we create. - wp listener = static_cast(this); - sp proxy = new BufferQueue::ProxyConsumerListener(listener); - - status_t err = mConsumer->consumerConnect(proxy, controlledByApp); - if (err != NO_ERROR) { - CB_LOGE("ConsumerBase: error connecting to BufferQueue: %s (%d)", - strerror(-err), err); - } else { - mConsumer->setConsumerName(mName); - } -} - -ConsumerBase::~ConsumerBase() { - CB_LOGV("~ConsumerBase"); - Mutex::Autolock lock(mMutex); - - // Verify that abandon() has been called before we get here. This should - // be done by ConsumerBase::onLastStrongRef(), but it's possible for a - // derived class to override that method and not call - // ConsumerBase::onLastStrongRef(). - LOG_ALWAYS_FATAL_IF(!mAbandoned, "[%s] ~ConsumerBase was called, but the " - "consumer is not abandoned!", mName.string()); -} - -void ConsumerBase::onLastStrongRef(const void* id) { - abandon(); -} - -void ConsumerBase::freeBufferLocked(int slotIndex) { - CB_LOGV("freeBufferLocked: slotIndex=%d", slotIndex); - mSlots[slotIndex].mGraphicBuffer = 0; - mSlots[slotIndex].mFence = Fence::NO_FENCE; - mSlots[slotIndex].mFrameNumber = 0; -} - -void ConsumerBase::onFrameAvailable() { - CB_LOGV("onFrameAvailable"); - - sp listener; - { // scope for the lock - Mutex::Autolock lock(mMutex); - listener = mFrameAvailableListener.promote(); - } - - if (listener != NULL) { - CB_LOGV("actually calling onFrameAvailable"); - listener->onFrameAvailable(); - } -} - -void ConsumerBase::onBuffersReleased() { - Mutex::Autolock lock(mMutex); - - CB_LOGV("onBuffersReleased"); - - if (mAbandoned) { - // Nothing to do if we're already abandoned. - return; - } - - uint32_t mask = 0; - mConsumer->getReleasedBuffers(&mask); - for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { - if (mask & (1 << i)) { - freeBufferLocked(i); - } - } -} - -void ConsumerBase::abandon() { - CB_LOGV("abandon"); - Mutex::Autolock lock(mMutex); - - if (!mAbandoned) { - abandonLocked(); - mAbandoned = true; - } -} - -void ConsumerBase::abandonLocked() { - CB_LOGV("abandonLocked"); - for (int i =0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { - freeBufferLocked(i); - } - // disconnect from the BufferQueue - mConsumer->consumerDisconnect(); - mConsumer.clear(); -} - -void ConsumerBase::setFrameAvailableListener( - const wp& listener) { - CB_LOGV("setFrameAvailableListener"); - Mutex::Autolock lock(mMutex); - mFrameAvailableListener = listener; -} - -void ConsumerBase::dump(String8& result) const { - dump(result, ""); -} - -void ConsumerBase::dump(String8& result, const char* prefix) const { - Mutex::Autolock _l(mMutex); - dumpLocked(result, prefix); -} - -void ConsumerBase::dumpLocked(String8& result, const char* prefix) const { - result.appendFormat("%smAbandoned=%d\n", prefix, int(mAbandoned)); - - if (!mAbandoned) { - mConsumer->dump(result, prefix); - } -} - -status_t ConsumerBase::acquireBufferLocked(BufferQueue::BufferItem *item, - nsecs_t presentWhen) { - status_t err = mConsumer->acquireBuffer(item, presentWhen); - if (err != NO_ERROR) { - return err; - } - - if (item->mGraphicBuffer != NULL) { - mSlots[item->mBuf].mGraphicBuffer = item->mGraphicBuffer; - } - - mSlots[item->mBuf].mFrameNumber = item->mFrameNumber; - mSlots[item->mBuf].mFence = item->mFence; - - CB_LOGV("acquireBufferLocked: -> slot=%d/%llu", - item->mBuf, item->mFrameNumber); - - return OK; -} - -status_t ConsumerBase::addReleaseFence(int slot, - const sp graphicBuffer, const sp& fence) { - Mutex::Autolock lock(mMutex); - return addReleaseFenceLocked(slot, graphicBuffer, fence); -} - -status_t ConsumerBase::addReleaseFenceLocked(int slot, - const sp graphicBuffer, const sp& fence) { - CB_LOGV("addReleaseFenceLocked: slot=%d", slot); - - // If consumer no longer tracks this graphicBuffer, we can safely - // drop this fence, as it will never be received by the producer. - if (!stillTracking(slot, graphicBuffer)) { - return OK; - } - - if (!mSlots[slot].mFence.get()) { - mSlots[slot].mFence = fence; - } else { - sp mergedFence = Fence::merge( - String8::format("%.28s:%d", mName.string(), slot), - mSlots[slot].mFence, fence); - if (!mergedFence.get()) { - CB_LOGE("failed to merge release fences"); - // synchronization is broken, the best we can do is hope fences - // signal in order so the new fence will act like a union - mSlots[slot].mFence = fence; - return BAD_VALUE; - } - mSlots[slot].mFence = mergedFence; - } - - return OK; -} - -status_t ConsumerBase::releaseBufferLocked( - int slot, const sp graphicBuffer, - EGLDisplay display, EGLSyncKHR eglFence) { - // If consumer no longer tracks this graphicBuffer (we received a new - // buffer on the same slot), the buffer producer is definitely no longer - // tracking it. - if (!stillTracking(slot, graphicBuffer)) { - return OK; - } - - CB_LOGV("releaseBufferLocked: slot=%d/%llu", - slot, mSlots[slot].mFrameNumber); - status_t err = mConsumer->releaseBuffer(slot, mSlots[slot].mFrameNumber, - display, eglFence, mSlots[slot].mFence); - if (err == BufferQueue::STALE_BUFFER_SLOT) { - freeBufferLocked(slot); - } - - mSlots[slot].mFence = Fence::NO_FENCE; - - return err; -} - -bool ConsumerBase::stillTracking(int slot, - const sp graphicBuffer) { - if (slot < 0 || slot >= BufferQueue::NUM_BUFFER_SLOTS) { - return false; - } - return (mSlots[slot].mGraphicBuffer != NULL && - mSlots[slot].mGraphicBuffer->handle == graphicBuffer->handle); -} - -} // namespace android diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/ConsumerBase.h b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/ConsumerBase.h deleted file mode 100644 index fb21185f..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/ConsumerBase.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_GUI_CONSUMERBASE_H -#define ANDROID_GUI_CONSUMERBASE_H - -#include - -#include - -#include -#include -#include -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class String8; - -// ConsumerBase is a base class for BufferQueue consumer end-points. It -// handles common tasks like management of the connection to the BufferQueue -// and the buffer pool. -class ConsumerBase : public virtual RefBase, - protected ConsumerListener { -public: - struct FrameAvailableListener : public virtual RefBase { - // onFrameAvailable() is called each time an additional frame becomes - // available for consumption. This means that frames that are queued - // while in asynchronous mode only trigger the callback if no previous - // frames are pending. Frames queued while in synchronous mode always - // trigger the callback. - // - // This is called without any lock held and can be called concurrently - // by multiple threads. - virtual void onFrameAvailable() = 0; - }; - - virtual ~ConsumerBase(); - - // abandon frees all the buffers and puts the ConsumerBase into the - // 'abandoned' state. Once put in this state the ConsumerBase can never - // leave it. When in the 'abandoned' state, all methods of the - // IGraphicBufferProducer interface will fail with the NO_INIT error. - // - // Note that while calling this method causes all the buffers to be freed - // from the perspective of the the ConsumerBase, if there are additional - // references on the buffers (e.g. if a buffer is referenced by a client - // or by OpenGL ES as a texture) then those buffer will remain allocated. - void abandon(); - - // set the name of the ConsumerBase that will be used to identify it in - // log messages. - void setName(const String8& name); - - // dump writes the current state to a string. Child classes should add - // their state to the dump by overriding the dumpLocked method, which is - // called by these methods after locking the mutex. - void dump(String8& result) const; - void dump(String8& result, const char* prefix) const; - - // setFrameAvailableListener sets the listener object that will be notified - // when a new frame becomes available. - void setFrameAvailableListener(const wp& listener); - -private: - ConsumerBase(const ConsumerBase&); - void operator=(const ConsumerBase&); - -protected: - // ConsumerBase constructs a new ConsumerBase object to consume image - // buffers from the given IGraphicBufferConsumer. - // The controlledByApp flag indicates that this consumer is under the application's - // control. - ConsumerBase(const sp& consumer, bool controlledByApp = false); - - // onLastStrongRef gets called by RefBase just before the dtor of the most - // derived class. It is used to clean up the buffers so that ConsumerBase - // can coordinate the clean-up by calling into virtual methods implemented - // by the derived classes. This would not be possible from the - // ConsuemrBase dtor because by the time that gets called the derived - // classes have already been destructed. - // - // This methods should not need to be overridden by derived classes, but - // if they are overridden the ConsumerBase implementation must be called - // from the derived class. - virtual void onLastStrongRef(const void* id); - - // Implementation of the IConsumerListener interface. These - // calls are used to notify the ConsumerBase of asynchronous events in the - // BufferQueue. These methods should not need to be overridden by derived - // classes, but if they are overridden the ConsumerBase implementation - // must be called from the derived class. - virtual void onFrameAvailable(); - virtual void onBuffersReleased(); - - // freeBufferLocked frees up the given buffer slot. If the slot has been - // initialized this will release the reference to the GraphicBuffer in that - // slot. Otherwise it has no effect. - // - // Derived classes should override this method to clean up any state they - // keep per slot. If it is overridden, the derived class's implementation - // must call ConsumerBase::freeBufferLocked. - // - // This method must be called with mMutex locked. - virtual void freeBufferLocked(int slotIndex); - - // abandonLocked puts the BufferQueue into the abandoned state, causing - // all future operations on it to fail. This method rather than the public - // abandon method should be overridden by child classes to add abandon- - // time behavior. - // - // Derived classes should override this method to clean up any object - // state they keep (as opposed to per-slot state). If it is overridden, - // the derived class's implementation must call ConsumerBase::abandonLocked. - // - // This method must be called with mMutex locked. - virtual void abandonLocked(); - - // dumpLocked dumps the current state of the ConsumerBase object to the - // result string. Each line is prefixed with the string pointed to by the - // prefix argument. The buffer argument points to a buffer that may be - // used for intermediate formatting data, and the size of that buffer is - // indicated by the size argument. - // - // Derived classes should override this method to dump their internal - // state. If this method is overridden the derived class's implementation - // should call ConsumerBase::dumpLocked. - // - // This method must be called with mMutex locked. - virtual void dumpLocked(String8& result, const char* prefix) const; - - // acquireBufferLocked fetches the next buffer from the BufferQueue and - // updates the buffer slot for the buffer returned. - // - // Derived classes should override this method to perform any - // initialization that must take place the first time a buffer is assigned - // to a slot. If it is overridden the derived class's implementation must - // call ConsumerBase::acquireBufferLocked. - virtual status_t acquireBufferLocked(IGraphicBufferConsumer::BufferItem *item, - nsecs_t presentWhen); - - // releaseBufferLocked relinquishes control over a buffer, returning that - // control to the BufferQueue. - // - // Derived classes should override this method to perform any cleanup that - // must take place when a buffer is released back to the BufferQueue. If - // it is overridden the derived class's implementation must call - // ConsumerBase::releaseBufferLocked.e - virtual status_t releaseBufferLocked(int slot, - const sp graphicBuffer, - EGLDisplay display, EGLSyncKHR eglFence); - - // returns true iff the slot still has the graphicBuffer in it. - bool stillTracking(int slot, const sp graphicBuffer); - - // addReleaseFence* adds the sync points associated with a fence to the set - // of sync points that must be reached before the buffer in the given slot - // may be used after the slot has been released. This should be called by - // derived classes each time some asynchronous work is kicked off that - // references the buffer. - status_t addReleaseFence(int slot, - const sp graphicBuffer, const sp& fence); - status_t addReleaseFenceLocked(int slot, - const sp graphicBuffer, const sp& fence); - - // Slot contains the information and object references that - // ConsumerBase maintains about a BufferQueue buffer slot. - struct Slot { - // mGraphicBuffer is the Gralloc buffer store in the slot or NULL if - // no Gralloc buffer is in the slot. - sp mGraphicBuffer; - - // mFence is a fence which will signal when the buffer associated with - // this buffer slot is no longer being used by the consumer and can be - // overwritten. The buffer can be dequeued before the fence signals; - // the producer is responsible for delaying writes until it signals. - sp mFence; - - // the frame number of the last acquired frame for this slot - uint64_t mFrameNumber; - }; - - // mSlots stores the buffers that have been allocated by the BufferQueue - // for each buffer slot. It is initialized to null pointers, and gets - // filled in with the result of BufferQueue::acquire when the - // client dequeues a buffer from a - // slot that has not yet been used. The buffer allocated to a slot will also - // be replaced if the requested buffer usage or geometry differs from that - // of the buffer allocated to a slot. - Slot mSlots[BufferQueue::NUM_BUFFER_SLOTS]; - - // mAbandoned indicates that the BufferQueue will no longer be used to - // consume images buffers pushed to it using the IGraphicBufferProducer - // interface. It is initialized to false, and set to true in the abandon - // method. A BufferQueue that has been abandoned will return the NO_INIT - // error from all IConsumerBase methods capable of returning an error. - bool mAbandoned; - - // mName is a string used to identify the ConsumerBase in log messages. - // It can be set by the setName method. - String8 mName; - - // mFrameAvailableListener is the listener object that will be called when a - // new frame becomes available. If it is not NULL it will be called from - // queueBuffer. - wp mFrameAvailableListener; - - // The ConsumerBase has-a BufferQueue and is responsible for creating this object - // if none is supplied - sp mConsumer; - - // mMutex is the mutex used to prevent concurrent access to the member - // variables of ConsumerBase objects. It must be locked whenever the - // member variables are accessed or when any of the *Locked methods are - // called. - // - // This mutex is intended to be locked by derived classes. - mutable Mutex mMutex; -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_CONSUMERBASE_H diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/CpuConsumer.cpp b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/CpuConsumer.cpp deleted file mode 100644 index bff55d1b..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/CpuConsumer.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//#define LOG_NDEBUG 0 -#define LOG_TAG "CpuConsumer" -#define ATRACE_TAG ATRACE_TAG_GRAPHICS - -#include -#include -#include - -#define CC_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__) -#define CC_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__) -#define CC_LOGI(x, ...) ALOGI("[%s] "x, mName.string(), ##__VA_ARGS__) -#define CC_LOGW(x, ...) ALOGW("[%s] "x, mName.string(), ##__VA_ARGS__) -#define CC_LOGE(x, ...) ALOGE("[%s] "x, mName.string(), ##__VA_ARGS__) - -namespace android { - -CpuConsumer::CpuConsumer(const sp& bq, - uint32_t maxLockedBuffers, bool controlledByApp) : - ConsumerBase(bq, controlledByApp), - mMaxLockedBuffers(maxLockedBuffers), - mCurrentLockedBuffers(0) -{ - // Create tracking entries for locked buffers - mAcquiredBuffers.insertAt(0, maxLockedBuffers); - - mConsumer->setConsumerUsageBits(GRALLOC_USAGE_SW_READ_OFTEN); - mConsumer->setMaxAcquiredBufferCount(maxLockedBuffers); -} - -CpuConsumer::~CpuConsumer() { - // ConsumerBase destructor does all the work. -} - - - -void CpuConsumer::setName(const String8& name) { - Mutex::Autolock _l(mMutex); - mName = name; - mConsumer->setConsumerName(name); -} - -status_t CpuConsumer::setDefaultBufferSize(uint32_t width, uint32_t height) -{ - Mutex::Autolock _l(mMutex); - return mConsumer->setDefaultBufferSize(width, height); -} - -status_t CpuConsumer::setDefaultBufferFormat(uint32_t defaultFormat) -{ - Mutex::Autolock _l(mMutex); - return mConsumer->setDefaultBufferFormat(defaultFormat); -} - -status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) { - status_t err; - - if (!nativeBuffer) return BAD_VALUE; - if (mCurrentLockedBuffers == mMaxLockedBuffers) { - CC_LOGW("Max buffers have been locked (%d), cannot lock anymore.", - mMaxLockedBuffers); - return NOT_ENOUGH_DATA; - } - - BufferQueue::BufferItem b; - - Mutex::Autolock _l(mMutex); - - err = acquireBufferLocked(&b, 0); - if (err != OK) { - if (err == BufferQueue::NO_BUFFER_AVAILABLE) { - return BAD_VALUE; - } else { - CC_LOGE("Error acquiring buffer: %s (%d)", strerror(err), err); - return err; - } - } - - int buf = b.mBuf; - - if (b.mFence.get()) { - err = b.mFence->waitForever("CpuConsumer::lockNextBuffer"); - if (err != OK) { - CC_LOGE("Failed to wait for fence of acquired buffer: %s (%d)", - strerror(-err), err); - return err; - } - } - - void *bufferPointer = NULL; - android_ycbcr ycbcr = android_ycbcr(); - - if (mSlots[buf].mGraphicBuffer->getPixelFormat() == - HAL_PIXEL_FORMAT_YCbCr_420_888) { - err = mSlots[buf].mGraphicBuffer->lockYCbCr( - GraphicBuffer::USAGE_SW_READ_OFTEN, - b.mCrop, - &ycbcr); - - if (err != OK) { - CC_LOGE("Unable to lock YCbCr buffer for CPU reading: %s (%d)", - strerror(-err), err); - return err; - } - bufferPointer = ycbcr.y; - } else { - err = mSlots[buf].mGraphicBuffer->lock( - GraphicBuffer::USAGE_SW_READ_OFTEN, - b.mCrop, - &bufferPointer); - - if (err != OK) { - CC_LOGE("Unable to lock buffer for CPU reading: %s (%d)", - strerror(-err), err); - return err; - } - } - - size_t lockedIdx = 0; - for (; lockedIdx < mMaxLockedBuffers; lockedIdx++) { - if (mAcquiredBuffers[lockedIdx].mSlot == - BufferQueue::INVALID_BUFFER_SLOT) { - break; - } - } - assert(lockedIdx < mMaxLockedBuffers); - - AcquiredBuffer &ab = mAcquiredBuffers.editItemAt(lockedIdx); - ab.mSlot = buf; - ab.mBufferPointer = bufferPointer; - ab.mGraphicBuffer = mSlots[buf].mGraphicBuffer; - - nativeBuffer->data = - reinterpret_cast(bufferPointer); - nativeBuffer->width = mSlots[buf].mGraphicBuffer->getWidth(); - nativeBuffer->height = mSlots[buf].mGraphicBuffer->getHeight(); - nativeBuffer->format = mSlots[buf].mGraphicBuffer->getPixelFormat(); - nativeBuffer->stride = (ycbcr.y != NULL) ? - ycbcr.ystride : - mSlots[buf].mGraphicBuffer->getStride(); - - nativeBuffer->crop = b.mCrop; - nativeBuffer->transform = b.mTransform; - nativeBuffer->scalingMode = b.mScalingMode; - nativeBuffer->timestamp = b.mTimestamp; - nativeBuffer->frameNumber = b.mFrameNumber; - - nativeBuffer->dataCb = reinterpret_cast(ycbcr.cb); - nativeBuffer->dataCr = reinterpret_cast(ycbcr.cr); - nativeBuffer->chromaStride = ycbcr.cstride; - nativeBuffer->chromaStep = ycbcr.chroma_step; - - mCurrentLockedBuffers++; - - return OK; -} - -status_t CpuConsumer::unlockBuffer(const LockedBuffer &nativeBuffer) { - Mutex::Autolock _l(mMutex); - size_t lockedIdx = 0; - status_t err; - - void *bufPtr = reinterpret_cast(nativeBuffer.data); - for (; lockedIdx < mMaxLockedBuffers; lockedIdx++) { - if (bufPtr == mAcquiredBuffers[lockedIdx].mBufferPointer) break; - } - if (lockedIdx == mMaxLockedBuffers) { - CC_LOGE("%s: Can't find buffer to free", __FUNCTION__); - return BAD_VALUE; - } - - return releaseAcquiredBufferLocked(lockedIdx); -} - -status_t CpuConsumer::releaseAcquiredBufferLocked(int lockedIdx) { - status_t err; - - err = mAcquiredBuffers[lockedIdx].mGraphicBuffer->unlock(); - if (err != OK) { - CC_LOGE("%s: Unable to unlock graphic buffer %d", __FUNCTION__, - lockedIdx); - return err; - } - int buf = mAcquiredBuffers[lockedIdx].mSlot; - - // release the buffer if it hasn't already been freed by the BufferQueue. - // This can happen, for example, when the producer of this buffer - // disconnected after this buffer was acquired. - if (CC_LIKELY(mAcquiredBuffers[lockedIdx].mGraphicBuffer == - mSlots[buf].mGraphicBuffer)) { - releaseBufferLocked( - buf, mAcquiredBuffers[lockedIdx].mGraphicBuffer, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR); - } - - AcquiredBuffer &ab = mAcquiredBuffers.editItemAt(lockedIdx); - ab.mSlot = BufferQueue::INVALID_BUFFER_SLOT; - ab.mBufferPointer = NULL; - ab.mGraphicBuffer.clear(); - - mCurrentLockedBuffers--; - return OK; -} - -void CpuConsumer::freeBufferLocked(int slotIndex) { - ConsumerBase::freeBufferLocked(slotIndex); -} - -} // namespace android diff --git a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/CpuConsumer.h b/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/CpuConsumer.h deleted file mode 100644 index e0e8ef42..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/aosp/src/override-19/CpuConsumer.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_GUI_CPUCONSUMER_H -#define ANDROID_GUI_CPUCONSUMER_H - -#include "ConsumerBase.h" - -#include - -#include -#include -#include - - -namespace android { - -class BufferQueue; - -/** - * CpuConsumer is a BufferQueue consumer endpoint that allows direct CPU - * access to the underlying gralloc buffers provided by BufferQueue. Multiple - * buffers may be acquired by it at once, to be used concurrently by the - * CpuConsumer owner. Sets gralloc usage flags to be software-read-only. - * This queue is synchronous by default. - */ - -class CpuConsumer : public ConsumerBase -{ - public: - typedef ConsumerBase::FrameAvailableListener FrameAvailableListener; - - struct LockedBuffer { - uint8_t *data; - uint32_t width; - uint32_t height; - PixelFormat format; - uint32_t stride; - Rect crop; - uint32_t transform; - uint32_t scalingMode; - int64_t timestamp; - uint64_t frameNumber; - // Values below are only valid when using - // HAL_PIXEL_FORMAT_YCbCr_420_888, in which case LockedBuffer::data - // contains the Y channel, and stride is the Y channel stride. For other - // formats, these will all be 0. - uint8_t *dataCb; - uint8_t *dataCr; - uint32_t chromaStride; - uint32_t chromaStep; - }; - - // Create a new CPU consumer. The maxLockedBuffers parameter specifies - // how many buffers can be locked for user access at the same time. - CpuConsumer(const sp& bq, - uint32_t maxLockedBuffers, bool controlledByApp = false); - - virtual ~CpuConsumer(); - - // set the name of the CpuConsumer that will be used to identify it in - // log messages. - void setName(const String8& name); - - // setDefaultBufferSize is used to set the size of buffers returned by - // requestBuffers when a width and height of zero is requested. - // A call to setDefaultBufferSize() may trigger requestBuffers() to - // be called from the client. Default size is 1x1. - status_t setDefaultBufferSize(uint32_t width, uint32_t height); - - // setDefaultBufferFormat allows CpuConsumer's BufferQueue to create buffers - // of a defaultFormat if no format is specified by producer. Formats are - // enumerated in graphics.h; the initial default is - // HAL_PIXEL_FORMAT_RGBA_8888. - status_t setDefaultBufferFormat(uint32_t defaultFormat); - - // Gets the next graphics buffer from the producer and locks it for CPU use, - // filling out the passed-in locked buffer structure with the native pointer - // and metadata. Returns BAD_VALUE if no new buffer is available, and - // NOT_ENOUGH_DATA if the maximum number of buffers is already locked. - // - // Only a fixed number of buffers can be locked at a time, determined by the - // construction-time maxLockedBuffers parameter. If INVALID_OPERATION is - // returned by lockNextBuffer, then old buffers must be returned to the queue - // by calling unlockBuffer before more buffers can be acquired. - status_t lockNextBuffer(LockedBuffer *nativeBuffer); - - // Returns a locked buffer to the queue, allowing it to be reused. Since - // only a fixed number of buffers may be locked at a time, old buffers must - // be released by calling unlockBuffer to ensure new buffers can be acquired by - // lockNextBuffer. - status_t unlockBuffer(const LockedBuffer &nativeBuffer); - - private: - // Maximum number of buffers that can be locked at a time - uint32_t mMaxLockedBuffers; - - status_t releaseAcquiredBufferLocked(int lockedIdx); - - virtual void freeBufferLocked(int slotIndex); - - // Tracking for buffers acquired by the user - struct AcquiredBuffer { - // Need to track the original mSlot index and the buffer itself because - // the mSlot entry may be freed/reused before the acquired buffer is - // released. - int mSlot; - sp mGraphicBuffer; - void *mBufferPointer; - - AcquiredBuffer() : - mSlot(BufferQueue::INVALID_BUFFER_SLOT), - mBufferPointer(NULL) { - } - }; - Vector mAcquiredBuffers; - - // Count of currently locked buffers - uint32_t mCurrentLockedBuffers; - -}; - -} // namespace android - -#endif // ANDROID_GUI_CPUCONSUMER_H diff --git a/airtest/core/android/static/stf_libs/minicap-shared/mock/Minicap.cpp b/airtest/core/android/static/stf_libs/minicap-shared/mock/Minicap.cpp deleted file mode 100644 index ddd60db8..00000000 --- a/airtest/core/android/static/stf_libs/minicap-shared/mock/Minicap.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// The only purpose of this file is to make the project build without any -// complaints about missing libraries (which exist on the device side). -// While we could also use one of the actual built libs, they might depend -// on other shared libraries, making this right here the easiest way to -// enable interoperability. - -#include "Minicap.hpp" - -int -minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { - return 0; -} - -Minicap* -minicap_create(int32_t displayId) { - return NULL; -} - -void -minicap_free(Minicap* mc) { -} - -void -minicap_start_thread_pool() { -}